aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2015-02-11 08:40:19 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2015-02-11 15:06:36 -0500
commit96d5c8a5dc06e9d14815d9199a5a5e0e66200e7c (patch)
tree5142b98a5684131a0fa0b7956120a20ae9121a8c
parent25ef68d266c437c45a2331d3473673b508cc305f (diff)
downloadpandoc-96d5c8a5dc06e9d14815d9199a5a5e0e66200e7c.tar.gz
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".
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs20
1 files changed, 11 insertions, 9 deletions
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 []