Merge pull request #2035 from lierdakil/issue2031

Docx Writer/Reference: Add keepNext to objects w/ captions
This commit is contained in:
John MacFarlane
2015-03-30 20:30:15 -07:00
3 changed files with 23 additions and 3 deletions
+4 -3
View File
@@ -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*
+14
View File
@@ -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" />
+5
View File
@@ -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)