diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-08-13 12:24:06 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-08-13 12:24:06 -0700 |
commit | 425b731050f48739749cd99c29c15aa011dbcabb (patch) | |
tree | 71b61a37b40e3ca0f7718d367ec42b3696d808a6 | |
parent | bf9ec6dfd8e832a4d2d550581da482833dfaaa6b (diff) | |
download | pandoc-425b731050f48739749cd99c29c15aa011dbcabb.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 10 |
1 files 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' |