forked from GitHub/gf-core
new unlexers ; work on Romance
This commit is contained in:
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/02/18 19:21:16 $
|
-- > CVS $Date: 2005/03/31 15:47:43 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: aarne $
|
||||||
-- > CVS $Revision: 1.6 $
|
-- > CVS $Revision: 1.7 $
|
||||||
--
|
--
|
||||||
-- elementary text postprocessing. AR 21\/11\/2001.
|
-- elementary text postprocessing. AR 21\/11\/2001.
|
||||||
--
|
--
|
||||||
@@ -22,6 +22,8 @@ module Text (untokWithXML,
|
|||||||
formatAsTextLit,
|
formatAsTextLit,
|
||||||
formatAsCodeLit,
|
formatAsCodeLit,
|
||||||
formatAsText,
|
formatAsText,
|
||||||
|
formatAsHTML,
|
||||||
|
formatAsLatex,
|
||||||
formatAsCode,
|
formatAsCode,
|
||||||
performBinds,
|
performBinds,
|
||||||
unStringLit,
|
unStringLit,
|
||||||
@@ -56,20 +58,26 @@ formatAsTextLit = formatAsText . unwords . map unStringLit . words
|
|||||||
formatAsCodeLit :: String -> String
|
formatAsCodeLit :: String -> String
|
||||||
formatAsCodeLit = formatAsCode . unwords . map unStringLit . words
|
formatAsCodeLit = formatAsCode . unwords . map unStringLit . words
|
||||||
|
|
||||||
formatAsText :: String -> String
|
formatAsText,formatAsHTML,formatAsLatex :: String -> String
|
||||||
formatAsText = unwords . format . cap . words where
|
formatAsText = formatAsTextGen (=="&-") (=="&-")
|
||||||
|
formatAsHTML = formatAsTextGen ((=="<") . take 1) (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
|
format ws = case ws of
|
||||||
w : c : ww | major c -> (w ++ c) : format (cap ww)
|
w : c : ww | major c -> format $ (w ++ c) :(cap ww)
|
||||||
w : c : ww | minor c -> (w ++ c) : format ww
|
w : c : ww | minor c -> format $ (w ++ c) : ww
|
||||||
|
p : c : ww | openp p -> format $ (p ++ c) :ww
|
||||||
c : ww | para c -> "\n\n" : format ww
|
c : ww | para c -> "\n\n" : format ww
|
||||||
w : ww -> w : format ww
|
w : ww -> w : format ww
|
||||||
[] -> []
|
[] -> []
|
||||||
cap (p:(c:cs):ww) | para p = p : (toUpper c : cs) : ww
|
cap (p:ww) | tag p = p : cap ww
|
||||||
cap ((c:cs):ww) = (toUpper c : cs) : ww
|
cap ((c:cs):ww) = (toUpper c : cs) : ww
|
||||||
cap [] = []
|
cap [] = []
|
||||||
major = flip elem (map singleton ".!?")
|
major = flip elem (map singleton ".!?")
|
||||||
minor = flip elem (map singleton ",:;")
|
minor = flip elem (map singleton ",:;)")
|
||||||
para = (=="&-")
|
openp = all (flip elem "(")
|
||||||
|
|
||||||
formatAsCode :: String -> String
|
formatAsCode :: String -> String
|
||||||
formatAsCode = rend 0 . words where
|
formatAsCode = rend 0 . words where
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/29 13:26:37 $
|
-- > CVS $Date: 2005/03/31 15:47:43 $
|
||||||
-- > CVS $Author: aarne $
|
-- > CVS $Author: aarne $
|
||||||
-- > CVS $Revision: 1.49 $
|
-- > CVS $Revision: 1.50 $
|
||||||
--
|
--
|
||||||
-- A database for customizable GF shell commands.
|
-- A database for customizable GF shell commands.
|
||||||
--
|
--
|
||||||
@@ -376,6 +376,8 @@ customUntokenizer =
|
|||||||
[
|
[
|
||||||
(strCI "unwords", const $ id) -- DEFAULT
|
(strCI "unwords", const $ id) -- DEFAULT
|
||||||
,(strCI "text", const $ formatAsText)
|
,(strCI "text", const $ formatAsText)
|
||||||
|
,(strCI "html", const $ formatAsHTML)
|
||||||
|
,(strCI "latex", const $ formatAsLatex)
|
||||||
,(strCI "code", const $ formatAsCode)
|
,(strCI "code", const $ formatAsCode)
|
||||||
,(strCI "concat", const $ filter (not . isSpace))
|
,(strCI "concat", const $ filter (not . isSpace))
|
||||||
,(strCI "textlit", const $ formatAsTextLit)
|
,(strCI "textlit", const $ formatAsTextLit)
|
||||||
|
|||||||
Reference in New Issue
Block a user