aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-13 12:16:51 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-13 12:16:51 -0700
commitbf9ec6dfd8e832a4d2d550581da482833dfaaa6b (patch)
treeabc10b9321d0538bdf5213670b3b2ac02bf17605 /src/Text/Pandoc/Readers/LaTeX.hs
parentf9656ece4ea1e106296bb3e140c46874df09955a (diff)
downloadpandoc-bf9ec6dfd8e832a4d2d550581da482833dfaaa6b.tar.gz
LaTeX reader: fix `\let\a=0` case, with single character token.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 96e5adbc6..4852d02c7 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1075,18 +1075,23 @@ inlineCommand' = try $ do
lookupListDefault raw names inlineCommands
tok :: PandocMonad m => LP m Inlines
-tok = grouped inline <|> inlineCommand' <|> singleChar
- where singleChar = try $ do
- Tok (lin,col) toktype t <- satisfyTok (tokTypeIn [Word, Symbol])
- guard $ not $ toktype == Symbol &&
- T.any (`Set.member` specialChars) t
- if T.length t > 1
- then do
- let (t1, t2) = (T.take 1 t, T.drop 1 t)
- inp <- getInput
- setInput $ (Tok (lin, col + 1) toktype t2) : inp
- return $ str (T.unpack t1)
- else return $ str (T.unpack t)
+tok = grouped inline <|> inlineCommand' <|> singleChar'
+ where singleChar' = do
+ Tok _ _ t <- singleChar
+ return (str (T.unpack t))
+
+singleChar :: PandocMonad m => LP m Tok
+singleChar = try $ do
+ Tok (lin,col) toktype t <- satisfyTok (tokTypeIn [Word, Symbol])
+ guard $ not $ toktype == Symbol &&
+ T.any (`Set.member` specialChars) t
+ if T.length t > 1
+ then do
+ let (t1, t2) = (T.take 1 t, T.drop 1 t)
+ inp <- getInput
+ setInput $ (Tok (lin, col + 1) toktype t2) : inp
+ return $ Tok (lin,col) toktype t1
+ else return $ Tok (lin,col) toktype t
opt :: PandocMonad m => LP m Inlines
opt = bracketed inline
@@ -1616,7 +1621,7 @@ letmacro = do
Tok _ (CtrlSeq name) _ <- anyControlSeq
optional $ symbol '='
spaces
- contents <- braced <|> ((:[]) <$> anyControlSeq)
+ contents <- braced <|> ((:[]) <$> (anyControlSeq <|> singleChar))
return (name, Macro ExpandWhenDefined 0 Nothing contents)
defmacro :: PandocMonad m => LP m (Text, Macro)