From a362a62abe55873bf1944e1121fd08c12549ea5a Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sat, 13 Aug 2016 21:52:50 -0400 Subject: Docx Writer: Implement user-defined styles. Divs with a "docx-style" key in the attributes will apply the corresponding key to the contained blocks. --- src/Text/Pandoc/Writers/Docx.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Text') 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 -- cgit v1.2.3