From 425b731050f48739749cd99c29c15aa011dbcabb Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 13 Aug 2017 12:24:06 -0700 Subject: [PATCH] LaTeX reader: Allow @ as a letter in control sequences. @ is commonly used in macros using `\makeatletter`. Ideally we'd make the tokenizer sensitive to `\makeatletter` and `\makeatother`, but until then this seems a good change. --- src/Text/Pandoc/Readers/LaTeX.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 4852d02c7..0edfc498d 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -320,8 +320,12 @@ totoks (lin,col) t = case T.uncons rest of Nothing -> [Tok (lin, col) Symbol (T.singleton c)] Just (d, rest') - | isLetter d -> - let (ws, rest'') = T.span isLetter rest + | isLetterOrAt d -> + -- \makeatletter is common in macro defs; + -- ideally we should make tokenization sensitive + -- to \makeatletter and \makeatother, but this is + -- probably best for now + let (ws, rest'') = T.span isLetterOrAt rest (ss, rest''') = T.span isSpaceOrTab rest'' in Tok (lin, col) (CtrlSeq ws) ("\\" <> ws <> ss) : totoks (lin, @@ -367,6 +371,8 @@ totoks (lin,col) t = where isSpaceOrTab ' ' = True isSpaceOrTab '\t' = True isSpaceOrTab _ = False + isLetterOrAt '@' = True + isLetterOrAt c = isLetter c isLowerHex :: Char -> Bool isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'