git.iko.soy/typeable/pandoc
on master help sign in
Docx Writer: Add a style to figure images
69d5085Nikolay Yakimov
data/docx/word/styles.xml+11
@@ -313,6 +313,17 @@
313 <w:name w:val="Image Caption" />
313 <w:name w:val="Image Caption" />
314 <w:basedOn w:val="Caption" />
314 <w:basedOn w:val="Caption" />
315 </w:style>
315 </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>
316 <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar">
327 <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar">
317 <w:name w:val="Body Text Char" />
328 <w:name w:val="Body Text Char" />
318 <w:basedOn w:val="DefaultParagraphFont" />
329 <w:basedOn w:val="DefaultParagraphFont" />
src/Text/Pandoc/Writers/Docx.hs+5
@@ -673,7 +673,12 @@ blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")
673-- title beginning with fig: indicates that the image is a figure
673-- title beginning with fig: indicates that the image is a figure
674blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
674blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
675 setFirstPara
675 setFirstPara
676+ pushParaProp $ pCustomStyle $
677+ if null alt
678+ then "Figure"
679+ else "FigureWithCaption"
676 paraProps <- getParaProps False
680 paraProps <- getParaProps False
681+ popParaProp
677 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
682 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
678 captionNode <- withParaProp (pCustomStyle "ImageCaption")
683 captionNode <- withParaProp (pCustomStyle "ImageCaption")
679 $ blockToOpenXML opts (Para alt)
684 $ blockToOpenXML opts (Para alt)