git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2035 from lierdakil/issue2031

Docx Writer/Reference: Add keepNext to objects w/ captions

commit2b2f7fe15e2632fe123934ec105c8cc72cd593fd authorJohn MacFarlane <jgm@berkeley.edu> dateMon 30 Mar 2015, 20:30 (12 years ago) parentc2cb6430d4d262
3 files changed+23−3
README+4−3 data/docx/word/styles.xml+14 src/Text/Pandoc/Writers/Docx.hs+5
README+4−3
@@ -633,10 +633,11 @@ Options affecting specific writers
633633 `--data-dir`). If this is not found either, sensible defaults will be
634634 used. The following styles are used by pandoc: [paragraph]
635635 Normal, Compact, Title, Subtitle, Authors, Date, Abstract, Heading 1,
636− Heading 2, Heading 3, Heading 4, Heading 5, Block Quote, Definition Term,
637− Definition, Bibliography, Body Text, Table Caption, Image Caption;
636+ Heading 2, Heading 3, Heading 4, Heading 5, Block Text, Definition Term,
637+ Definition, Bibliography, Body Text, Table Caption, Image Caption,
638+ Figure, FigureWithCaption;
638639 [character] Default Paragraph Font, Body Text Char, Verbatim Char,
639− Footnote Ref, Link.
640+ Footnote Reference, Hyperlink.
640641
641642`--epub-stylesheet=`*FILE*
642643
data/docx/word/styles.xml+14
@@ -308,11 +308,25 @@
308308 <w:style w:type="paragraph" w:customStyle="1" w:styleId="TableCaption">
309309 <w:name w:val="Table Caption" />
310310 <w:basedOn w:val="Caption" />
311+ <w:pPr>
312+ <w:keepNext />
313+ </w:pPr>
311314 </w:style>
312315 <w:style w:type="paragraph" w:customStyle="1" w:styleId="ImageCaption">
313316 <w:name w:val="Image Caption" />
314317 <w:basedOn w:val="Caption" />
315318 </w:style>
319+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Figure">
320+ <w:name w:val="Figure" />
321+ <w:basedOn w:val="Normal" />
322+ </w:style>
323+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="FigureWithCaption">
324+ <w:name w:val="Figure with Caption" />
325+ <w:basedOn w:val="Figure" />
326+ <w:pPr>
327+ <w:keepNext />
328+ </w:pPr>
329+ </w:style>
316330 <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar">
317331 <w:name w:val="Body Text Char" />
318332 <w:basedOn w:val="DefaultParagraphFont" />
src/Text/Pandoc/Writers/Docx.hs+5
@@ -741,7 +741,12 @@ blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")
741741-- title beginning with fig: indicates that the image is a figure
742742blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
743743 setFirstPara
744+ pushParaProp $ pCustomStyle $
745+ if null alt
746+ then "Figure"
747+ else "FigureWithCaption"
744748 paraProps <- getParaProps False
749+ popParaProp
745750 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
746751 captionNode <- withParaProp (pCustomStyle "ImageCaption")
747752 $ blockToOpenXML opts (Para alt)