diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-03-30 20:30:15 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-03-30 20:30:15 -0700 |
commit | 2b2f7fe15e2632fe123934ec105c8cc72cd593fd (patch) | |
tree | 0b67631fa4db3e43fc75c6c5c550b453a1a2cc2d | |
parent | c2cb64379ec24eadc43d8f4a48bf3b19b4e33624 (diff) | |
parent | 0d4d26294491b3f16e11231e90dc79ccd16b0b48 (diff) |
Merge pull request #2035 from lierdakil/issue2031
Docx Writer/Reference: Add keepNext to objects w/ captions
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | data/docx/word/styles.xml | 14 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 5 |
3 files changed, 23 insertions, 3 deletions
@@ -633,10 +633,11 @@ Options affecting specific writers `--data-dir`). If this is not found either, sensible defaults will be used. The following styles are used by pandoc: [paragraph] Normal, Compact, Title, Subtitle, Authors, Date, Abstract, Heading 1, - Heading 2, Heading 3, Heading 4, Heading 5, Block Quote, Definition Term, - Definition, Bibliography, Body Text, Table Caption, Image Caption; + Heading 2, Heading 3, Heading 4, Heading 5, Block Text, Definition Term, + Definition, Bibliography, Body Text, Table Caption, Image Caption, + Figure, FigureWithCaption; [character] Default Paragraph Font, Body Text Char, Verbatim Char, - Footnote Ref, Link. + Footnote Reference, Hyperlink. `--epub-stylesheet=`*FILE* diff --git a/data/docx/word/styles.xml b/data/docx/word/styles.xml index 01190ef5a..347e7ff07 100644 --- a/data/docx/word/styles.xml +++ b/data/docx/word/styles.xml @@ -308,11 +308,25 @@ <w:style w:type="paragraph" w:customStyle="1" w:styleId="TableCaption"> <w:name w:val="Table Caption" /> <w:basedOn w:val="Caption" /> + <w:pPr> + <w:keepNext /> + </w:pPr> </w:style> <w:style w:type="paragraph" w:customStyle="1" w:styleId="ImageCaption"> <w:name w:val="Image Caption" /> <w:basedOn w:val="Caption" /> </w:style> + <w:style w:type="paragraph" w:customStyle="1" w:styleId="Figure"> + <w:name w:val="Figure" /> + <w:basedOn w:val="Normal" /> + </w:style> + <w:style w:type="paragraph" w:customStyle="1" w:styleId="FigureWithCaption"> + <w:name w:val="Figure with Caption" /> + <w:basedOn w:val="Figure" /> + <w:pPr> + <w:keepNext /> + </w:pPr> + </w:style> <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar"> <w:name w:val="Body Text Char" /> <w:basedOn w:val="DefaultParagraphFont" /> diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 8bb1d0ced..4e81def60 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -741,7 +741,12 @@ blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact") -- title beginning with fig: indicates that the image is a figure blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do setFirstPara + pushParaProp $ pCustomStyle $ + if null alt + then "Figure" + else "FigureWithCaption" paraProps <- getParaProps False + popParaProp contents <- inlinesToOpenXML opts [Image alt (src,tit)] captionNode <- withParaProp (pCustomStyle "ImageCaption") $ blockToOpenXML opts (Para alt) |