summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2014-10-19 17:43:39 +0000
committeraarne <aarne@chalmers.se>2014-10-19 17:43:39 +0000
commit84bce336fd2acc5b18e0e8792a82b682dacaab37 (patch)
tree886d9b097839f9186afd9aa56fee837b840aa0c4 /src/runtime
parent6c2e0d5ce28e4ed1ff35d7795b80988142190524 (diff)
(un)lexmixed: added the other math environments than $ used in latex
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/haskell/PGF/Lexing.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/haskell/PGF/Lexing.hs b/src/runtime/haskell/PGF/Lexing.hs
index dde39b494..5d7acb398 100644
--- a/src/runtime/haskell/PGF/Lexing.hs
+++ b/src/runtime/haskell/PGF/Lexing.hs
@@ -67,18 +67,18 @@ lexLatexCode = restoreBackslash . lexCode where --- quick hack: postprocess Hask
-- | LaTeX style lexer, with "math" environment using Code between $...$
lexMixed :: String -> [String]
-lexMixed = concat . alternate False where
- alternate env s = case s of
- _:_ -> case break (=='$') s of
- (t,[]) -> lex env t : []
- (t,c:m) -> lex env t : [[c]] : alternate (not env) m
- _ -> []
+lexMixed = concat . alternate False [] where
+ alternate env t s = case s of
+ '$':cs -> lex env (reverse t) : ["$"] : alternate (not env) [] cs
+ '\\':c:cs | elem c "()[]" -> lex env (reverse t) : [['\\',c]] : alternate (not env) [] cs
+ c:cs -> alternate env (c:t) cs
+ _ -> [lex env (reverse t)]
lex env = if env then lexLatexCode else lexText
unlexMixed :: [String] -> String
unlexMixed = capitInit . concat . alternate False where
alternate env s = case s of
- _:_ -> case break (=="$") s of
+ _:_ -> case break (flip elem ["$","\\[","\\]","\\(","\\)"]) s of
(t,[]) -> unlex env t : []
(t,c:m) -> unlex env t : sep env c m : alternate (not env) m
_ -> []