summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <unknown>2005-03-31 15:57:35 +0000
committeraarne <unknown>2005-03-31 15:57:35 +0000
commit75c08d7abfbfd533a33d772c650036178c887149 (patch)
treec102b6fa906e4074efab648b807af65cb3b9bee4
parent0151c5c418fb64e01e46c6bff464f0d7b2dd91ba (diff)
capitalization in lexer
-rw-r--r--src/GF/Text/Text.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/GF/Text/Text.hs b/src/GF/Text/Text.hs
index 6eaa27b06..92d8ca9e2 100644
--- a/src/GF/Text/Text.hs
+++ b/src/GF/Text/Text.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/03/31 15:47:43 $
+-- > CVS $Date: 2005/03/31 16:57:35 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.7 $
+-- > CVS $Revision: 1.8 $
--
-- elementary text postprocessing. AR 21\/11\/2001.
--
@@ -60,12 +60,13 @@ formatAsCodeLit = formatAsCode . unwords . map unStringLit . words
formatAsText,formatAsHTML,formatAsLatex :: String -> String
formatAsText = formatAsTextGen (=="&-") (=="&-")
-formatAsHTML = formatAsTextGen ((=="<") . take 1) (const False)
+formatAsHTML = formatAsTextGen (\s -> take 1 s == "<" || last s == '>') (const False)
formatAsLatex = formatAsTextGen ((=="\\") . take 1) (const False)
formatAsTextGen :: (String -> Bool) -> (String -> Bool) -> String -> String
formatAsTextGen tag para = unwords . format . cap . words where
format ws = case ws of
+ w : ww | capit w -> format $ (cap ww)
w : c : ww | major c -> format $ (w ++ c) :(cap ww)
w : c : ww | minor c -> format $ (w ++ c) : ww
p : c : ww | openp p -> format $ (p ++ c) :ww
@@ -75,6 +76,7 @@ formatAsTextGen tag para = unwords . format . cap . words where
cap (p:ww) | tag p = p : cap ww
cap ((c:cs):ww) = (toUpper c : cs) : ww
cap [] = []
+ capit = (=="&|")
major = flip elem (map singleton ".!?")
minor = flip elem (map singleton ",:;)")
openp = all (flip elem "(")