I am converting HTML with paragraphs followed by blockquotes into FO using XSL.
How can I avoid page breaks between the paragraphs and the blockquote that follows?
Page breaks following the blockquotes are fine.
Example:
<p> Some paragraph..</p>
<blockquote>My reference</blockquote>
<p> Another paragraph..</p>
<blockquote>My reference</blockquote>
You need what is called a keep condition between the block generated by a normal p
and the one generated by a blockquote
.
In particular, as p
is a general-purpose tag, I think the best option is to use the attribute keep-with-previous.within-page="always"
in the fo:block
generated for the blockquote
HTML element.
If you are using XSLT to create the XSL-FO output, you need something like this (you may need to adjust namespaces):
<xsl:template match="blockquote">
<fo:block keep-with-previous.within-page="always" ...other attributes...>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
I think the most straightforward way would be to wrap the elements you want to keep together with a fo:block
, and add a keep-with-next.within-page="always"
attribute, as shown here :
<fo:block keep-with-next.within-page="always">
... content of p and blockquote elements
</fo:block>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.