git.iko.soy/typeable/pandoc
on master help sign in
Docx Writer: Add a style to figure images

Figures with empty captions use style "Figure" Figures with nonempty captions use style "Figure with Caption", which is based on "Figure", and additionally has keepNext set.

commit69d5085c112ccd2a136b08895e268d43f9f2067f authorNikolay Yakimov <root@livid.pp.ru> dateSun 29 Mar 2015, 07:37 (12 years ago) parent2707898
2 files changed+16
data/docx/word/styles.xml+11 src/Text/Pandoc/Writers/Docx.hs+5
data/docx/word/styles.xml+11
@@ -313,6 +313,17 @@
313313 <w:name w:val="Image Caption" />
314314 <w:basedOn w:val="Caption" />
315315 </w:style>
316+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Figure">
317+ <w:name w:val="Figure" />
318+ <w:basedOn w:val="Normal" />
319+ </w:style>
320+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="FigureWithCaption">
321+ <w:name w:val="Figure with Caption" />
322+ <w:basedOn w:val="Figure" />
323+ <w:pPr>
324+ <w:keepNext />
325+ </w:pPr>
326+ </w:style>
316327 <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar">
317328 <w:name w:val="Body Text Char" />
318329 <w:basedOn w:val="DefaultParagraphFont" />
src/Text/Pandoc/Writers/Docx.hs+5
@@ -673,7 +673,12 @@ blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")
673673-- title beginning with fig: indicates that the image is a figure
674674blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
675675 setFirstPara
676+ pushParaProp $ pCustomStyle $
677+ if null alt
678+ then "Figure"
679+ else "FigureWithCaption"
676680 paraProps <- getParaProps False
681+ popParaProp
677682 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
678683 captionNode <- withParaProp (pCustomStyle "ImageCaption")
679684 $ blockToOpenXML opts (Para alt)