aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-11-29 10:29:51 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-11-29 10:35:20 -0800
commitbff9c129c3579f928a0067759d0a784eb5c07d30 (patch)
tree22cca1bb1aaa3723d0664d800a3d5616fc4d70cf /src
parent83d63b72e1b9eff9f2aa3b9f36b56d348f0909a2 (diff)
downloadpandoc-bff9c129c3579f928a0067759d0a784eb5c07d30.tar.gz
LaTeX reader: don't parse `\rule` with width 0 as horizontal rule.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 2a9bff746..15a1a19fc 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1225,6 +1225,16 @@ preamble = mconcat <$> many preambleBlock
anyTok
return mempty)
+rule :: PandocMonad m => LP m Blocks
+rule = do
+ skipopts
+ width <- T.takeWhile (\c -> isDigit c || c == '.') . stringify <$> tok
+ _thickness <- tok
+ -- 0-width rules are used to fix spacing issues:
+ case safeRead width of
+ Just (0 :: Double) -> return mempty
+ _ -> return horizontalRule
+
paragraph :: PandocMonad m => LP m Blocks
paragraph = do
x <- trimInlines . mconcat <$> many1 inline
@@ -1595,7 +1605,7 @@ blockCommands = M.fromList
--
, ("hrule", pure horizontalRule)
, ("strut", pure mempty)
- , ("rule", skipopts *> tok *> tok $> horizontalRule)
+ , ("rule", rule)
, ("item", looseItem)
, ("documentclass", skipopts *> braced *> preamble)
, ("centerline", para . trimInlines <$> (skipopts *> tok))