diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2020-06-09 23:17:31 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2020-11-27 13:28:11 +0200 |
commit | cafb8b7371c5d4de4cc2fa3a4f40ea6b8053a9ba (patch) | |
tree | ad995902da2370d46f09ba68a2361d513c697a5c /src/Text/Pandoc/Readers | |
parent | a9c766291f529ffe50c0415a03f06f9756a0a5f0 (diff) | |
download | pandoc-cafb8b7371c5d4de4cc2fa3a4f40ea6b8053a9ba.tar.gz |
Allow multicols env in LaTeX reader
The multicols environment has a mandatory argument - number of columns.
It is incorrectly parsed as plain string.
Wrap multicols content into nested divs.
Signed-off-by: Igor Pashev <pashev.igor@gmail.com>
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 2a9bff746..de01708f2 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1642,6 +1642,7 @@ environments = M.fromList , ("abstract", mempty <$ (env "abstract" blocks >>= addMeta "abstract")) , ("sloppypar", env "sloppypar" blocks) , ("letter", env "letter" letterContents) + , ("multicols", env "multicols" multicols) , ("minipage", env "minipage" $ skipopts *> spaces *> optional braced *> spaces *> blocks) , ("figure", env "figure" $ skipopts *> figure) @@ -1903,6 +1904,18 @@ letterContents = do _ -> mempty return $ addr <> bs -- sig added by \closing +multicols :: PandocMonad m => LP m Blocks +multicols = do + spaces + n <- fromMaybe 1 . safeRead . untokenize <$> braced + spaces + bs <- blocks + return $ divWith ("", ["columns"], []) $ cols n bs + where + cols :: Int -> Blocks -> Blocks + cols n = foldr1 (.) (replicate n $ divWith ("", ["column"], [])) + + figure :: PandocMonad m => LP m Blocks figure = try $ do resetCaption |