aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-14 23:05:09 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-14 23:17:44 -0700
commit892a4edeb1c9b9810c8386e639d8e457bbae7e86 (patch)
treec9de220c7cef5e6f52fdc282fb2c361533626f00 /src/Text/Pandoc
parent23d29ee10cb93143f48aca6aa6ebb6afc09af797 (diff)
downloadpandoc-892a4edeb1c9b9810c8386e639d8e457bbae7e86.tar.gz
Implement multicolumn support for slide formats.
The structure expected is: <div class="columns"> <div class="column" width="40%"> contents... </div> <div class="column" width="60%"> contents... </div> </div> Support has been added for beamer and all HTML slide formats. Closes #1710. Note: later we could add a more elegant way to create this structure in Markdown than to use raw HTML div elements. This would come for free with a "native div syntax" (#168). Or we could devise something specific to slides
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs8
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs23
2 files changed, 28 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index b899ce96a..c73af4604 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -640,8 +640,14 @@ blockToHtml opts (LineBlock lns) =
let lf = preEscapedString "\n"
htmlLines <- mconcat . intersperse lf <$> mapM (inlineListToHtml opts) lns
return $ H.div ! A.class_ "line-block" $ htmlLines
-blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
+blockToHtml opts (Div attr@(ident, classes, kvs') bs) = do
html5 <- gets stHtml5
+ let kvs = kvs' ++
+ if "column" `elem` classes
+ then let w = fromMaybe "48%" (lookup "width" kvs')
+ in [("style", "width:" ++ w ++ ";min-width:" ++ w ++
+ ";vertical-align:top;")]
+ else []
let speakerNotes = "notes" `elem` classes
-- we don't want incremental output inside speaker notes, see #1394
let opts' = if speakerNotes then opts{ writerIncremental = False } else opts
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index fcc5ad1c6..4a81cd245 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -452,7 +452,25 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) = do
_ -> linkAnchor'
let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir
lang <- toLang $ lookup "lang" kvs
- let wrapDir = case lookup "dir" kvs of
+ let wrapColumns = if "columns" `elem` classes
+ then \contents ->
+ inCmd "begin" "columns" <> brackets "T"
+ $$ contents
+ $$ inCmd "end" "columns"
+ else id
+ wrapColumn = if "column" `elem` classes
+ then \contents ->
+ let fromPct xs =
+ case reverse xs of
+ '%':ds -> '0':'.': reverse ds
+ _ -> xs
+ w = maybe "0.48" fromPct (lookup "width" kvs)
+ in inCmd "begin" "column" <>
+ braces (text w <> "\\textwidth")
+ $$ contents
+ $$ inCmd "end" "column"
+ else id
+ wrapDir = case lookup "dir" kvs of
Just "rtl" -> align "RTL"
Just "ltr" -> align "LTR"
_ -> id
@@ -468,7 +486,8 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) = do
wrapNotes txt = if beamer && "notes" `elem` classes
then "\\note" <> braces txt -- speaker notes
else linkAnchor $$ txt
- fmap (wrapDir . wrapLang . wrapNotes) $ blockListToLaTeX bs
+ fmap (wrapColumns . wrapColumn . wrapDir . wrapLang . wrapNotes)
+ $ blockListToLaTeX bs
blockToLaTeX (Plain lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
-- title beginning with fig: indicates that the image is a figure