From 96d5c8a5dc06e9d14815d9199a5a5e0e66200e7c Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 11 Feb 2015 08:40:19 -0500 Subject: 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". --- src/Text/Pandoc/Writers/Docx.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 5ed96b6f3..8d1721f4d 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -673,15 +673,17 @@ blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do -- fixDisplayMath sometimes produces a Para [] as artifact blockToOpenXML _ (Para []) = return [] blockToOpenXML opts (Para lst) = do - isFirstPara <- gets stFirstPara - if isFirstPara - then do modify $ \s -> s { stFirstPara = False } - withParaProp (pStyle "FirstParagraph") $ blockToOpenXML opts (Para lst) - else do paraProps <- getParaProps $ case lst of - [Math DisplayMath _] -> True - _ -> False - contents <- inlinesToOpenXML opts lst - return [mknode "w:p" [] (paraProps ++ contents)] + isFirstPara <- gets stFirstPara + paraProps <- getParaProps $ case lst of + [Math DisplayMath _] -> True + _ -> False + let paraProps' = case paraProps of + [] | isFirstPara -> [mknode "w:pPr" [] [(pStyle "FirstParagraph")]] + [] -> [mknode "w:pPr" [] [(pStyle "BodyText")]] + ps -> ps + modify $ \s -> s { stFirstPara = False } + contents <- inlinesToOpenXML opts lst + return [mknode "w:p" [] (paraProps' ++ contents)] blockToOpenXML _ (RawBlock format str) | format == Format "openxml" = return [ x | Elem x <- parseXML str ] | otherwise = return [] -- cgit v1.2.3