aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-08-13 21:52:50 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-08-13 21:52:50 -0400
commita362a62abe55873bf1944e1121fd08c12549ea5a (patch)
tree42bc6b64237fce3b5999e38264723d17479a1d91 /src/Text
parent347d716826249ea7eadc8332f48e1600c469abb0 (diff)
downloadpandoc-a362a62abe55873bf1944e1121fd08c12549ea5a.tar.gz
Docx Writer: Implement user-defined styles.
Divs with a "docx-style" key in the attributes will apply the corresponding key to the contained blocks.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index c3d1351e2..ce8d7837e 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -722,9 +722,15 @@ getUniqueId :: MonadIO m => m String
-- already in word/document.xml.rel
getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique
+-- | Key for specifying user-defined docx styles.
+dynamicStyleKey :: String
+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 (_,["references"],_) bs) = do
let (hs, bs') = span isHeaderBlock bs
header <- blocksToOpenXML opts hs