diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-11-29 10:29:51 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-11-29 10:35:20 -0800 |
commit | bff9c129c3579f928a0067759d0a784eb5c07d30 (patch) | |
tree | 22cca1bb1aaa3723d0664d800a3d5616fc4d70cf /src/Text/Pandoc/Readers | |
parent | 83d63b72e1b9eff9f2aa3b9f36b56d348f0909a2 (diff) | |
download | pandoc-bff9c129c3579f928a0067759d0a784eb5c07d30.tar.gz |
LaTeX reader: don't parse `\rule` with width 0 as horizontal rule.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 12 |
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)) |