diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-22 13:28:11 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-22 13:28:11 -0800 |
commit | 297345098db4b06bcb46cf39d2a74518eb24eb3a (patch) | |
tree | ddb665662aa46eecc9540755e478b50622ee8aa1 /src/Text | |
parent | f9202f5d3918cb99e35ab3c74f09e1bf7f81368a (diff) | |
download | pandoc-297345098db4b06bcb46cf39d2a74518eb24eb3a.tar.gz |
ConTeXt writer: set default layout based on margin-left, etc.
This sets up `\setuplayout` based on the variables `margin-left`,
`margin-right`, `margin-bottom`, and `margin-top`, if no layout
is given.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 446da142c..498e2d10f 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -37,6 +37,7 @@ import Text.Pandoc.Walk (query) import Text.Printf ( printf ) import Data.List ( intercalate, intersperse ) import Data.Char ( ord ) +import Data.Maybe ( catMaybes ) import Control.Monad.State import Text.Pandoc.Pretty import Text.Pandoc.ImageSize @@ -72,6 +73,14 @@ pandocToConTeXt options (Pandoc meta blocks) = do meta body <- mapM (elementToConTeXt options) $ hierarchicalize blocks let main = (render colwidth . vcat) body + let layoutFromMargins = intercalate [','] $ catMaybes $ + map (\(x,y) -> + ((x ++ "=") ++) <$> getField y metadata) + [("leftmargin","margin-left") + ,("rightmargin","margin-right") + ,("top","margin-top") + ,("bottom","margin-bottom") + ] let context = defField "toc" (writerTableOfContents options) $ defField "placelist" (intercalate ("," :: String) $ take (writerTOCDepth options + if writerChapters options @@ -80,6 +89,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do ["chapter","section","subsection","subsubsection", "subsubsubsection","subsubsubsubsection"]) $ defField "body" main + $ defField "layout" layoutFromMargins $ defField "number-sections" (writerNumberSections options) $ metadata let context' = defField "context-lang" (maybe "" (fromBcp47 . splitBy (=='-')) $ |