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.
This commit is contained in:
parent
f9202f5d39
commit
297345098d
1 changed files with 10 additions and 0 deletions
|
@ -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 (=='-')) $
|
||||
|
|
Loading…
Add table
Reference in a new issue