aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-03-30 22:09:24 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-03-30 22:11:00 -0700
commit72020f17738e5fd3c47d479a80a2de698980e4c6 (patch)
tree1e28c8f97d0df7f828f96720686a11a45b52fe0d
parent5aec167e71b3da98a0f209e3c75af019682ad354 (diff)
downloadpandoc-72020f17738e5fd3c47d479a80a2de698980e4c6.tar.gz
Docx writer: Use Compact style for Plain block elements.
This differentiates between tight and loose lists. Closes #775.
-rw-r--r--README2
-rw-r--r--data/reference.docxbin9757 -> 9782 bytes
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs10
3 files changed, 9 insertions, 3 deletions
diff --git a/README b/README
index 10c3571f4..7efc00e26 100644
--- a/README
+++ b/README
@@ -485,7 +485,7 @@ Options affecting specific writers
for a file `reference.docx` in the user data directory (see
`--data-dir`). If this is not found either, sensible defaults will be
used. The following styles are used by pandoc: [paragraph]
- Normal, Title, Authors, Date, Heading 1, Heading 2, Heading 3,
+ Normal, Compact, Title, Authors, Date, Heading 1, Heading 2, Heading 3,
Heading 4, Heading 5, Block Quote, Definition Term, Definition,
Body Text, Table Caption, Image Caption; [character] Default
Paragraph Font, Body Text Char, Verbatim Char, Footnote Ref,
diff --git a/data/reference.docx b/data/reference.docx
index b1d0ab15d..42c14a906 100644
--- a/data/reference.docx
+++ b/data/reference.docx
Binary files differ
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 0549772af..50e39a2a7 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -418,7 +418,8 @@ blockToOpenXML opts (Header lev (ident,_,_) lst) = do
,("w:name",bookmarkName)] ()
let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
return $ [bookmarkStart] ++ contents ++ [bookmarkEnd]
-blockToOpenXML opts (Plain lst) = blockToOpenXML opts (Para lst)
+blockToOpenXML opts (Plain lst) = withParaProp (pStyle "Compact")
+ $ blockToOpenXML opts (Para lst)
-- title beginning with fig: indicates that the image is a figure
blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
paraProps <- getParaProps False
@@ -781,7 +782,12 @@ stripLeadingTrailingSpace = go . reverse . go . reverse
go xs = xs
fixDisplayMath :: Block -> [Block]
-fixDisplayMath (Plain lst) = fixDisplayMath (Para lst)
+fixDisplayMath (Plain lst)
+ | any isDisplayMath lst && not (all isDisplayMath lst) =
+ -- chop into several paragraphs so each displaymath is its own
+ map (Plain . stripLeadingTrailingSpace) $
+ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) ||
+ not (isDisplayMath x || isDisplayMath y)) lst
fixDisplayMath (Para lst)
| any isDisplayMath lst && not (all isDisplayMath lst) =
-- chop into several paragraphs so each displaymath is its own