aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-08-15 10:27:01 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-08-15 10:27:01 -0400
commit6c6860d076388275f9db77032586563447ecf9cc (patch)
treead0fef6a3f5f72e6e3f8f46d7a2a51e2a345e935 /src/Text
parenta362a62abe55873bf1944e1121fd08c12549ea5a (diff)
downloadpandoc-6c6860d076388275f9db77032586563447ecf9cc.tar.gz
Docx Writer: Have state keep track of dynamic styles.
We want to be able to inject these into our styles.xml.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index ce8d7837e..1daae854e 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -110,6 +110,7 @@ data WriterState = WriterState{
, stStyleMaps :: StyleMaps
, stFirstPara :: Bool
, stTocTitle :: [Inline]
+ , stDynamicParaProps :: [String]
}
defaultWriterState :: WriterState
@@ -132,6 +133,7 @@ defaultWriterState = WriterState{
, stStyleMaps = defaultStyleMaps
, stFirstPara = False
, stTocTitle = normalizeInlines [Str "Table of Contents"]
+ , stDynamicParaProps = []
}
type WS a = StateT WriterState IO a
@@ -729,8 +731,10 @@ dynamicStyleKey = "docx-style"
-- | Convert a Pandoc block element to OpenXML.
blockToOpenXML :: WriterOptions -> Block -> WS [Element]
blockToOpenXML _ Null = return []
-blockToOpenXML opts (Div (_,_,kvs) bs) | Just sty <- lookup dynamicStyleKey kvs =
- withParaPropM (pStyleM sty) $ blocksToOpenXML opts bs
+blockToOpenXML opts (Div (_,_,kvs) bs)
+ | Just sty <- lookup dynamicStyleKey kvs = do
+ modify $ \s -> s{stDynamicParaProps = sty : (stDynamicParaProps s)}
+ withParaPropM (pStyleM sty) $ blocksToOpenXML opts bs
blockToOpenXML opts (Div (_,["references"],_) bs) = do
let (hs, bs') = span isHeaderBlock bs
header <- blocksToOpenXML opts hs