• Added conditional processing of page breaks within <question> and <answer> elements.
1 parent aa7a760 commit b57f5910948386952ada4dfb67f2d44e9f3f7b8a
Nigel Stanger authored on 7 Sep 2016
Showing 1 changed file
View
57
modules/basic-page-elements.xml
<!--
Page break. This is only relevant for LaTeX formats at present.
The page break is automatically suppressed if the parent node is "answer" and $showanswers is "no", or the parent node is "question" and $showanswers is "yes". This is to prevent page breaks that look fine in one but not the other.
If you want to force a page break regardless, put after the "answer" element for a question item.
@print-caption: Whether or not to print a caption before the page break.
'yes' => display the caption
otherwise => display nothing [default]
-->
<template name="page-break" match="page-break|new-page|newpage|pagebreak">
<common formats="/latex/xelatex/">
<xsl:if test="@print-caption = 'yes'">
<xsl:text>\begin{flushright}</xsl:text>
<xsl:call-template name="newline-internal" />
<xsl:text>\emph{</xsl:text>
<xsl:choose>
<xsl:when test="@caption-text">
<xsl:value-of select="@caption-text" />
</xsl:when>
<xsl:otherwise>
<xsl:text>continues over\ldots</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>}</xsl:text>
<xsl:call-template name="newline-internal" />
<xsl:text>\end{flushright}</xsl:text>
<xsl:call-template name="newline-internal" />
</xsl:if>
<xsl:text>\newpage</xsl:text>
<xsl:call-template name="newline-internal" />
</common>
</template>
<xsl:variable name="insert" select="
if ((name(..) = 'answer') and ($showanswers = 'no')) then false()
else if ((name(..) = 'question') and ($showanswers = 'yes')) then false()
else true()" />
<xsl:if test="$insert">
<xsl:if test="@print-caption = 'yes'">
<xsl:text>\begin{flushright}</xsl:text>
<xsl:call-template name="newline-internal" />
<xsl:text>\emph{</xsl:text>
<xsl:choose>
<xsl:when test="@caption-text">
<xsl:value-of select="@caption-text" />
</xsl:when>
<xsl:otherwise>
<xsl:text>continues over\ldots</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>}</xsl:text>
<xsl:call-template name="newline-internal" />
<xsl:text>\end{flushright}</xsl:text>
<xsl:call-template name="newline-internal" />
</xsl:if>
<xsl:text>\newpage</xsl:text>
<xsl:call-template name="newline-internal" />
</xsl:if>
</common>
</template>
<!--
Skip a certain amount of space vertically. Probably more relevant to LaTeX than HTML. Is it even possible to vskip a set amount in HTML?? I suppose you could create an empty <div> element with a specified height, but I'm not sure that it even makes sense in HTML to skip more than the standard paragraph separation anyway.