git.iko.soy/typeable/pandoc
on master help sign in
Docx Writer: Add "BodyText" Style

We apply a "BodyText" style to all unstyled paragraphs. This is, essentially, the same as "Normal" up until now -- except that since not everything inherits from "BodyText" (the metadata won't, for example, or the headers or footnote numbers) we can change the text in the body without having to make exceptions for everything. This will still inherit from Normal, so if we want to change *everything*, we can do it through "Normal".

commit96d5c8a5dc06e9d14815d9199a5a5e0e66200e7c authorJesse Rosenthal <jrosenthal@jhu.edu> dateWed 11 Feb 2015, 08:40 (12 years ago) parent25ef68d
1 file changed+11−9
src/Text/Pandoc/Writers/Docx.hs+11−9
src/Text/Pandoc/Writers/Docx.hs+11−9
@@ -673,15 +673,17 @@ blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
673673-- fixDisplayMath sometimes produces a Para [] as artifact
674674blockToOpenXML _ (Para []) = return []
675675blockToOpenXML opts (Para lst) = do
676− isFirstPara <- gets stFirstPara
677− if isFirstPara
678− then do modify $ \s -> s { stFirstPara = False }
679− withParaProp (pStyle "FirstParagraph") $ blockToOpenXML opts (Para lst)
680− else do paraProps <- getParaProps $ case lst of
681− [Math DisplayMath _] -> True
682− _ -> False
683− contents <- inlinesToOpenXML opts lst
684− return [mknode "w:p" [] (paraProps ++ contents)]
676+ isFirstPara <- gets stFirstPara
677+ paraProps <- getParaProps $ case lst of
678+ [Math DisplayMath _] -> True
679+ _ -> False
680+ let paraProps' = case paraProps of
681+ [] | isFirstPara -> [mknode "w:pPr" [] [(pStyle "FirstParagraph")]]
682+ [] -> [mknode "w:pPr" [] [(pStyle "BodyText")]]
683+ ps -> ps
684+ modify $ \s -> s { stFirstPara = False }
685+ contents <- inlinesToOpenXML opts lst
686+ return [mknode "w:p" [] (paraProps' ++ contents)]
685687blockToOpenXML _ (RawBlock format str)
686688 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
687689 | otherwise = return []