git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: Use Compact style for Plain block elements.

This differentiates between tight and loose lists. Closes #775.

commit72020f17738e5fd3c47d479a80a2de698980e4c6 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 30 Mar 2013, 22:09 (14 years ago) parent5aec167
3 files changed+9−3
README+1−1 data/reference.docx src/Text/Pandoc/Writers/Docx.hs+8−2
README+1−1
@@ -485,7 +485,7 @@ Options affecting specific writers
485485 for a file `reference.docx` in the user data directory (see
486486 `--data-dir`). If this is not found either, sensible defaults will be
487487 used. The following styles are used by pandoc: [paragraph]
488− Normal, Title, Authors, Date, Heading 1, Heading 2, Heading 3,
488+ Normal, Compact, Title, Authors, Date, Heading 1, Heading 2, Heading 3,
489489 Heading 4, Heading 5, Block Quote, Definition Term, Definition,
490490 Body Text, Table Caption, Image Caption; [character] Default
491491 Paragraph Font, Body Text Char, Verbatim Char, Footnote Ref,
data/reference.docx

Binary file not shown.

src/Text/Pandoc/Writers/Docx.hs+8−2
@@ -418,7 +418,8 @@ blockToOpenXML opts (Header lev (ident,_,_) lst) = do
418418 ,("w:name",bookmarkName)] ()
419419 let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
420420 return $ [bookmarkStart] ++ contents ++ [bookmarkEnd]
421−blockToOpenXML opts (Plain lst) = blockToOpenXML opts (Para lst)
421+blockToOpenXML opts (Plain lst) = withParaProp (pStyle "Compact")
422+ $ blockToOpenXML opts (Para lst)
422423-- title beginning with fig: indicates that the image is a figure
423424blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
424425 paraProps <- getParaProps False
@@ -781,7 +782,12 @@ stripLeadingTrailingSpace = go . reverse . go . reverse
781782 go xs = xs
782783
783784fixDisplayMath :: Block -> [Block]
784−fixDisplayMath (Plain lst) = fixDisplayMath (Para lst)
785+fixDisplayMath (Plain lst)
786+ | any isDisplayMath lst && not (all isDisplayMath lst) =
787+ -- chop into several paragraphs so each displaymath is its own
788+ map (Plain . stripLeadingTrailingSpace) $
789+ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) ||
790+ not (isDisplayMath x || isDisplayMath y)) lst
785791fixDisplayMath (Para lst)
786792 | any isDisplayMath lst && not (all isDisplayMath lst) =
787793 -- chop into several paragraphs so each displaymath is its own