From d30aaa6547f09a1cb6d6853075e2b6e852086f9b Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 17 Oct 2014 07:04:50 +0000 Subject: [PATCH] unlexing latex code: no space between closing $ and punctuation --- src/runtime/haskell/PGF/Lexing.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/runtime/haskell/PGF/Lexing.hs b/src/runtime/haskell/PGF/Lexing.hs index d5286a478..b4a3d3fa0 100644 --- a/src/runtime/haskell/PGF/Lexing.hs +++ b/src/runtime/haskell/PGF/Lexing.hs @@ -81,10 +81,13 @@ unlexMixed = capitInit . concat . alternate False where alternate env s = case s of _:_ -> case break (=="$") s of (t,[]) -> unlex env t : [] - (t,c:m) -> unlex env t : sep env c : alternate (not env) m + (t,c:m) -> unlex env t : sep env c m : alternate (not env) m _ -> [] - unlex env = if env then unlexCode else unlexText - sep env c = if env then c ++ " " else " " ++ c + unlex env = if env then unlexCode else (uncapitInit . unlexText) + sep env c m = case (m,env) of + ([p]:_,True) | isPunct p -> c -- closing $ glued to next punct + (_, True) -> c ++ " " -- closing $ otherwise separated by space from what follows + _ -> " " ++ c -- put space before opening $ -- * Additional lexing uitilties