From 72020f17738e5fd3c47d479a80a2de698980e4c6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 30 Mar 2013 22:09:24 -0700 Subject: Docx writer: Use Compact style for Plain block elements. This differentiates between tight and loose lists. Closes #775. --- src/Text/Pandoc/Writers/Docx.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers/Docx.hs') 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 -- cgit v1.2.3