summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Text
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-06-23 09:19:21 +0000
committeraarne <aarne@cs.chalmers.se>2008-06-23 09:19:21 +0000
commit65b2670ce7c1babe8bb206fa841587c2801f1bec (patch)
tree73d33cc1e888200892f391c6fce608abc48dcf36 /src-3.0/GF/Text
parentf62c70bdd56f27c185ba9237be1ec95cd94bdaca (diff)
html string option
Diffstat (limited to 'src-3.0/GF/Text')
-rw-r--r--src-3.0/GF/Text/Lexing.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src-3.0/GF/Text/Lexing.hs b/src-3.0/GF/Text/Lexing.hs
index beabf217b..1ac2eb498 100644
--- a/src-3.0/GF/Text/Lexing.hs
+++ b/src-3.0/GF/Text/Lexing.hs
@@ -4,6 +4,7 @@ import GF.Text.Transliterations
import GF.Text.UTF8
import Data.Char
+import Data.List (intersperse)
-- lexers and unlexers - they work on space-separated word strings
@@ -20,6 +21,7 @@ stringOp name = case name of
"unlexcode" -> Just $ appUnlexer unlexCode
"unlexmixed" -> Just $ appUnlexer unlexMixed
"unwords" -> Just $ appUnlexer unwords
+ "to_html" -> Just wrapHTML
"to_utf8" -> Just encodeUTF8
"from_utf8" -> Just decodeUTF8
_ -> transliterate name
@@ -30,6 +32,10 @@ appLexer f = unwords . filter (not . null) . f
appUnlexer :: ([String] -> String) -> String -> String
appUnlexer f = unlines . map (f . words) . lines
+wrapHTML :: String -> String
+wrapHTML = unlines . tag . intersperse "<br>" . lines where
+ tag ss = "<html>":"<body>" : ss ++ ["</body>","</html>"]
+
lexText :: String -> [String]
lexText s = case s of
c:cs | isPunct c -> [c] : lexText cs