Docx writer: Use Compact style for Plain block elements.

This differentiates between tight and loose lists.
Closes #775.
This commit is contained in:
John MacFarlane 2013-03-30 22:09:24 -07:00
parent 5aec167e71
commit 72020f1773
3 changed files with 9 additions and 3 deletions

2
README
View file

@ -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,

Binary file not shown.

View file

@ -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