git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: don't parse `\rule` with width 0 as horizontal rule.
commitbff9c129c3579f928a0067759d0a784eb5c07d30 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 29 Nov 2020, 10:29 (6 years ago) parent83d63b7
1 file changed+11−1
src/Text/Pandoc/Readers/LaTeX.hs+11−1
src/Text/Pandoc/Readers/LaTeX.hs+11−1
@@ -1225,6 +1225,16 @@ preamble = mconcat <$> many preambleBlock
12251225 anyTok
12261226 return mempty)
12271227
1228+rule :: PandocMonad m => LP m Blocks
1229+rule = do
1230+ skipopts
1231+ width <- T.takeWhile (\c -> isDigit c || c == '.') . stringify <$> tok
1232+ _thickness <- tok
1233+ -- 0-width rules are used to fix spacing issues:
1234+ case safeRead width of
1235+ Just (0 :: Double) -> return mempty
1236+ _ -> return horizontalRule
1237+
12281238paragraph :: PandocMonad m => LP m Blocks
12291239paragraph = do
12301240 x <- trimInlines . mconcat <$> many1 inline
@@ -1595,7 +1605,7 @@ blockCommands = M.fromList
15951605 --
15961606 , ("hrule", pure horizontalRule)
15971607 , ("strut", pure mempty)
1598− , ("rule", skipopts *> tok *> tok $> horizontalRule)
1608+ , ("rule", rule)
15991609 , ("item", looseItem)
16001610 , ("documentclass", skipopts *> braced *> preamble)
16011611 , ("centerline", para . trimInlines <$> (skipopts *> tok))