diff --git a/modules/lists.xml b/modules/lists.xml index eacfa1f..d10354b 100755 --- a/modules/lists.xml +++ b/modules/lists.xml @@ -13,10 +13,13 @@ <template name="itemised-list" match="itemised-list|itemize|unordered-list|bulleted-list|bullet-list|bullet-points|UL|ul"> <common formats="/latex/xelatex/"> - \begin{itemize} - <xsl:apply-templates select="item" mode="normal" /> - \end{itemize} - + <xsl:call-template name="newline-internal" /> + <xsl:text>\begin{itemize}</xsl:text> + <xsl:call-template name="newline-internal" /> + <xsl:apply-templates select="item" mode="normal" /> + <xsl:call-template name="newline-internal" /> + <xsl:text>\end{itemize}</xsl:text> + <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <ul> @@ -33,21 +36,24 @@ --> <template name="enumerated-list" match="enumerated-list|enumerate|ordered-list|numbered-list|question-list|OL|ol"> <common formats="/latex/xelatex/"> - \begin{enumerate} - <xsl:if test='@start'> - <!-- - Set the appropriate enum counter according to the depth. Use the format attribute of xsl:number to output it in Roman numerals. Depth must be at least 1 (enumi) and at most 4 (enumiv). Bizarrely, a count(ancestor::xxx) here gives 0 for the outermost element, whereas for section elements it gives 1?!?! - --> - <xsl:text>\setcounter{enum</xsl:text> - <xsl:number value="min( ( 1 + count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> - <xsl:text>}{</xsl:text> - <!-- Remember that LaTeX adds 1 to the counter before using it. --> - <xsl:value-of select="@start - 1" /> - <xsl:text>}</xsl:text> - </xsl:if> - <xsl:apply-templates select="item" mode="enumerated-list" /> - \end{enumerate} - + <xsl:call-template name="newline-internal" /> + <xsl:text>\begin{enumerate}</xsl:text> + <xsl:call-template name="newline-internal" /> + <xsl:if test='@start'> + <!-- + Set the appropriate enum counter according to the depth. Use the format attribute of xsl:number to output it in Roman numerals. Depth must be at least 1 (enumi) and at most 4 (enumiv). + --> + <xsl:text>\setcounter{enum</xsl:text> + <xsl:number value="min( ( 1 + count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> + <xsl:text>}{</xsl:text> + <!-- Remember that LaTeX adds 1 to the counter before using it. --> + <xsl:value-of select="@start - 1" /> + <xsl:text>}</xsl:text> + </xsl:if> + <xsl:apply-templates select="item" mode="enumerated-list" /> + <xsl:call-template name="newline-internal" /> + <xsl:text>\end{enumerate}</xsl:text> + <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <ol> @@ -68,10 +74,13 @@ <!-- Definition or description lists. --> <template name="definition-list" match="definition-list|description-list|DL|dl"> <common formats="/latex/xelatex/"> - \begin{description} - <xsl:apply-templates select="item" mode="definition-list" /> - \end{description} - + <xsl:call-template name="newline-internal" /> + <xsl:text>\begin{description}</xsl:text> + <xsl:call-template name="newline-internal" /> + <xsl:apply-templates select="item" mode="definition-list" /> + <xsl:call-template name="newline-internal" /> + <xsl:text>\end{description}</xsl:text> + <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <!-- @@ -84,13 +93,17 @@ <!-- List items for non-definition lists. --> <template name="list-item" match="item" mode="normal"> - <common formats="/latex/xelatex/"><xsl:text>\item </xsl:text><xsl:apply-templates /></common> + <common formats="/latex/xelatex/"> + <xsl:text>\item </xsl:text> + <xsl:apply-templates /> + <xsl:call-template name="newline-internal" /> + </common> <common formats="/html/xhtml/"> <xsl:choose> <!-- - Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item. If so, let them worry about inserting the <p> tags. + Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item (there are rather a lot of these!). If so, let them worry about inserting the <p> tags. --> - <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> + <xsl:when test="count(paragraph|para|p|question|answer|code-block|itemised-list|itemize|unordered-list|bulleted-list|bullet-list|bullet-points|UL|ul|enumerated-list|enumerate|ordered-list|numbered-list|question-list|OL|ol|definition-list|description-list|DL|dl) != 0"> <li><xsl:apply-templates /></li> </xsl:when> <!-- @@ -117,6 +130,7 @@ <!-- Remember that LaTeX adds 1 to the counter before using it. --> <xsl:value-of select="@value - 1" /> <xsl:text>}</xsl:text> + <xsl:call-template name="newline-internal" /> <xsl:apply-templates select="." mode="normal" /> </common> <!-- @@ -125,11 +139,9 @@ <common formats="/html/xhtml/"> <xsl:choose> <!-- - Check whether there are actual paragraphs or things that - should be treated like paragraphs inside the item. If so, - let them worry about inserting the <p> tags. + Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item (there are rather a lot of these!). If so, let them worry about inserting the <p> tags. --> - <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> + <xsl:when test="count(paragraph|para|p|question|answer|code-block|itemised-list|itemize|unordered-list|bulleted-list|bullet-list|bullet-points|UL|ul|enumerated-list|enumerate|ordered-list|numbered-list|question-list|OL|ol|definition-list|description-list|DL|dl) != 0"> <li> <xsl:attribute name="value" select="@value" /> <xsl:apply-templates /> @@ -164,6 +176,7 @@ <xsl:apply-templates select="keyword|term|topic|DT|dt" /> <xsl:text>] </xsl:text> <xsl:apply-templates select="definition|description|discourse|DD|dd" /> + <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <!-- @@ -179,11 +192,11 @@ --> <xsl:choose> <!-- - If the first sub-node of the <definition> is NOT a <p> node, then the whole thing should be just simple text and contain only basic formatting elements, if anything (i.e., no lists!). We therefore just wrap the <keyword> and <definition> within a <p> with a hanging indent and finish. Note the use of child::node[1|2], because we don't necessarily know what variants of <keyword> and <definition> have actually been used, but we know that they will (should!) always be the first and second children of the <item> respectively. + If the first sub-node of the <definition> is NOT a <p> node, then the whole thing should be just simple text and contain only basic formatting elements, if anything (i.e., no lists!). We therefore just wrap the <keyword> and <definition> within a <p> with a hanging indent and finish. Note the use of child::node()[1|2], because we don't necessarily know what variants of <keyword> and <definition> have actually been used, but we know that they will (should!) always be the first and second children of the <item> respectively. This probably is the most common case, so test for it first. --> - <xsl:when test="not(child::node()[2]/child::node()[1][self::p] or child::node()[2]/child::node()[1][self::paragraph])"> + <xsl:when test="not( child::node()[2]/child::node()[1][self::p] or child::node()[2]/child::node()[1][self::paragraph] )"> <p class="definition1"> <xsl:apply-templates select="child::node()[1]" /> <xsl:text> </xsl:text> @@ -211,15 +224,21 @@ Need to provide some context here as, e.g., <term> is also a standalone element. --> <template name="keyword" match="item/keyword|item/term|item/topic|item/DT|item/dt"> - <common formats="/latex/xelatex/"><xsl:apply-templates /></common> - <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> + <common formats="/latex/xelatex/"> + <xsl:apply-templates /> + </common> + <common formats="/html/xhtml/"> + <strong><xsl:apply-templates /></strong> + </common> </template> <!-- Need to provide some context here as, e.g., <description> is also used within <image>. --> <template name="definition" match="item/definition|item/description|item/discourse|item/DD|item/dd"> - <common><xsl:apply-templates /></common> + <common> + <xsl:apply-templates /> + </common> </template>