aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs13
-rw-r--r--test/command/latex-multicols.md14
2 files changed, 27 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
diff --git a/test/command/latex-multicols.md b/test/command/latex-multicols.md
new file mode 100644
index 000000000..81e5577fd
--- /dev/null
+++ b/test/command/latex-multicols.md
@@ -0,0 +1,14 @@
+# `\begin{multicols}`
+
+```
+% pandoc -f latex -t native
+\begin{multicols}{2}
+Hello
+\end{multicols}
+^D
+[Div ("",["columns"],[])
+ [Div ("",["column"],[])
+ [Div ("",["column"],[])
+ [Para [Str "Hello"]]]]]
+```
+