@@ -629,28 +629,28 @@ dollarsMath :: PandocMonad m => LP m Inlines
629629dollarsMath = do
630630 symbol '$'
631631 display <- option False (True <$ symbol '$')
632− (do contents <- try $ T.unpack <$> pDollarsMath 0
632+ (do contents <- try $ T.unpack . untokenize <$> pDollarsMath 0
633633 if display
634634 then (mathDisplay contents <$ symbol '$')
635635 else return $ mathInline contents)
636636 <|> (guard display >> return (mathInline ""))
637637
638638-- Int is number of embedded groupings
639−pDollarsMath :: PandocMonad m => Int -> LP m Text
639+pDollarsMath :: PandocMonad m => Int -> LP m [Tok]
640640pDollarsMath n = do
641− Tok _ toktype t <- anyTok
641+ tk@(Tok _ toktype t) <- anyTok
642642 case toktype of
643643 Symbol | t == "$"
644− , n == 0 -> return mempty
644+ , n == 0 -> return []
645645 | t == "\\" -> do
646− Tok _ _ t' <- anyTok
647− return (t <> t')
648− | t == "{" -> (t <>) <$> pDollarsMath (n+1)
646+ tk' <- anyTok
647+ ((tk :) . (tk' :)) <$> pDollarsMath n
648+ | t == "{" -> (tk :) <$> pDollarsMath (n+1)
649649 | t == "}" ->
650650 if n > 0
651− then (t <>) <$> pDollarsMath (n-1)
651+ then (tk :) <$> pDollarsMath (n-1)
652652 else mzero
653− _ -> (t <>) <$> pDollarsMath n
653+ _ -> (tk :) <$> pDollarsMath n
654654
655655-- citations
656656