aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-11-16 17:31:13 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-16 17:31:47 -0800
commit2a44140e114a6b31e63056eb2615cf8b99fd0d9b (patch)
treeed028e95418b52fc5d37fdfc99e5860eac02bf4c
parent11fd45817e714b5297251bf5967f957927d2eec5 (diff)
downloadpandoc-2a44140e114a6b31e63056eb2615cf8b99fd0d9b.tar.gz
ConTeXt writer: Use special environment for CSL references.
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 64092dc6b..08fa99451 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -39,6 +39,7 @@ data WriterState =
WriterState { stNextRef :: Int -- number of next URL reference
, stOrderedListLevel :: Int -- level of ordered list
, stOptions :: WriterOptions -- writer options
+ , stHasCslRefs :: Bool -- has CSL citations
}
data Tabl = Xtb | Ntb deriving (Show, Eq)
@@ -52,6 +53,7 @@ writeConTeXt options document =
let defaultWriterState = WriterState { stNextRef = 1
, stOrderedListLevel = 0
, stOptions = options
+ , stHasCslRefs = False
}
in evalStateT (pandocToConTeXt options document) defaultWriterState
@@ -76,6 +78,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do
,("bottom","margin-bottom")
]
mblang <- fromBCP47 (getLang options meta)
+ st <- get
let context = defField "toc" (writerTableOfContents options)
$ defField "placelist"
(mconcat . intersperse ("," :: Doc Text) $
@@ -89,6 +92,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do
$ defField "body" main
$ defField "layout" layoutFromMargins
$ defField "number-sections" (writerNumberSections options)
+ $ defField "csl-refs" (stHasCslRefs st)
$ maybe id (\l ->
defField "context-lang" (literal l :: Doc Text)) mblang
$ (case T.unpack . render Nothing <$>
@@ -183,6 +187,10 @@ blockToConTeXt (CodeBlock _ str) =
blockToConTeXt b@(RawBlock f str)
| f == Format "context" || f == Format "tex" = return $ literal str <> blankline
| otherwise = empty <$ report (BlockNotRendered b)
+blockToConTeXt (Div ("refs",_,_) bs) = do
+ modify $ \st -> st{ stHasCslRefs = True }
+ inner <- blockListToConTeXt bs
+ return $ "\\startcslreferences" $$ inner $$ "\\stopcslreferences"
blockToConTeXt (Div (ident,_,kvs) bs) = do
let align dir txt = "\\startalignment[" <> dir <> "]" $$ txt $$ "\\stopalignment"
mblang <- fromBCP47 (lookup "lang" kvs)