git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: fix `\let\a=0` case, with single character token.
bf9ec6dJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+18−13
@@ -1075,18 +1075,23 @@ inlineCommand' = try $ do
1075 lookupListDefault raw names inlineCommands
1075 lookupListDefault raw names inlineCommands
1076
1076
1077tok :: PandocMonad m => LP m Inlines
1077tok :: PandocMonad m => LP m Inlines
1078−tok = grouped inline <|> inlineCommand' <|> singleChar
1078+tok = grouped inline <|> inlineCommand' <|> singleChar'
1079− where singleChar = try $ do
1079+ where singleChar' = do
1080+ Tok _ _ t <- singleChar
1081+ return (str (T.unpack t))
1082+
1083+singleChar :: PandocMonad m => LP m Tok
1084+singleChar = try $ do
1080− Tok (lin,col) toktype t <- satisfyTok (tokTypeIn [Word, Symbol])
1085+ Tok (lin,col) toktype t <- satisfyTok (tokTypeIn [Word, Symbol])
1081− guard $ not $ toktype == Symbol &&
1086+ guard $ not $ toktype == Symbol &&
1082− T.any (`Set.member` specialChars) t
1087+ T.any (`Set.member` specialChars) t
1083− if T.length t > 1
1088+ if T.length t > 1
1084− then do
1089+ then do
1085− let (t1, t2) = (T.take 1 t, T.drop 1 t)
1090+ let (t1, t2) = (T.take 1 t, T.drop 1 t)
1086− inp <- getInput
1091+ inp <- getInput
1087− setInput $ (Tok (lin, col + 1) toktype t2) : inp
1092+ setInput $ (Tok (lin, col + 1) toktype t2) : inp
1088− return $ str (T.unpack t1)
1093+ return $ Tok (lin,col) toktype t1
1089− else return $ str (T.unpack t)
1094+ else return $ Tok (lin,col) toktype t
1090
1095
1091opt :: PandocMonad m => LP m Inlines
1096opt :: PandocMonad m => LP m Inlines
1092opt = bracketed inline
1097opt = bracketed inline
@@ -1616,7 +1621,7 @@ letmacro = do
1616 Tok _ (CtrlSeq name) _ <- anyControlSeq
1621 Tok _ (CtrlSeq name) _ <- anyControlSeq
1617 optional $ symbol '='
1622 optional $ symbol '='
1618 spaces
1623 spaces
1619− contents <- braced <|> ((:[]) <$> anyControlSeq)
1624+ contents <- braced <|> ((:[]) <$> (anyControlSeq <|> singleChar))
1620 return (name, Macro ExpandWhenDefined 0 Nothing contents)
1625 return (name, Macro ExpandWhenDefined 0 Nothing contents)
1621
1626
1622defmacro :: PandocMonad m => LP m (Text, Macro)
1627defmacro :: PandocMonad m => LP m (Text, Macro)