Author: chatellier Date: 2009-01-15 18:30:52 +0000 (Thu, 15 Jan 2009) New Revision: 247 Modified: jrst/trunk/src/main/resources/xsl/xml2rst.xsl Log: Update xml2rst.xsl stylesheet Modified: jrst/trunk/src/main/resources/xsl/xml2rst.xsl =================================================================== --- jrst/trunk/src/main/resources/xsl/xml2rst.xsl 2009-01-14 11:03:24 UTC (rev 246) +++ jrst/trunk/src/main/resources/xsl/xml2rst.xsl 2009-01-15 18:30:52 UTC (rev 247) @@ -1,6 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE xsl:stylesheet [ +<!ENTITY CR " "> +<!-- Used to create a blank line --> +<!ENTITY tCR "<xsl:text>&CR;</xsl:text>"> +<!-- Used when the line before must be ended --> +<!ENTITY tEOL "<xsl:text>&CR;</xsl:text>"> +<!ENTITY tSP "<xsl:text> </xsl:text>"> +]> - <!-- Copyright (C) 2005, 2006 Stefan Merten, David Priest @@ -36,8 +43,8 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:u="http://www.w3.org/1999/XSL/Transform/u" - xmlns:data="http://a" + xmlns:u="u" + xmlns:data="a" exclude-result-prefixes="data"> <xsl:output @@ -155,6 +162,7 @@ "docinfo" may be transformed from an initial field_list, and "decoration" is usually constructed programmatically. --> + <!-- == structural_element --> <xsl:template match="document"> @@ -166,6 +174,7 @@ </xsl:if> <xsl:call-template name="u:outputClass"> + <xsl:with-param name="blankAfter" select="true()"/> @@ -183,6 +192,7 @@ <!-- == structural_element --> <xsl:template match="section"> + <xsl:call-template name="u:outputClass"/> <xsl:call-template @@ -211,6 +221,7 @@ <xsl:text>.. sidebar:: </xsl:text> <xsl:value-of select="title"/> + &tEOL; <xsl:if test="subtitle"> @@ -229,6 +240,7 @@ </xsl:if> <xsl:call-template name="u:params"/> + <!-- Always blank line after parameter block --> &tCR; <xsl:apply-templates @@ -245,6 +257,7 @@ <!-- == structural_element == directive --> <xsl:template match="topic"> + <xsl:call-template name="u:BandI"/> <xsl:text>.. topic:: </xsl:text> @@ -258,6 +271,7 @@ </xsl:template> <!-- == structural_element == directive --> + <xsl:template match="topic[starts-with(@class, 'contents')]"> <xsl:call-template @@ -273,6 +287,7 @@ <xsl:with-param name="params" select="@*[name() != 'id' and name() != 'name' and name() != 'class']"/> + </xsl:call-template> <xsl:variable name="realClasses" @@ -293,6 +308,7 @@ select="ancestor-or-self::*"/> </xsl:call-template> </xsl:if> + <!-- Autogenerated content is discarded --> &tCR; </xsl:template> @@ -305,6 +321,7 @@ <xsl:text>:</xsl:text> <xsl:apply-templates select="title"/> + <xsl:text>: </xsl:text> &tEOL; <xsl:apply-templates @@ -319,6 +336,7 @@ id, name, dupname, source, and class. --> <!-- == compound_body_element == directive --> + <xsl:template match="admonition"> <xsl:call-template @@ -333,6 +351,7 @@ name="u:indent"/> <xsl:apply-templates select="*[not(self::title)]"/> + </xsl:template> <!-- ******************************************************************** --> @@ -350,6 +369,7 @@ <xsl:call-template name="u:BandI"/> <xsl:text>.. </xsl:text> + <xsl:value-of select="name()"/> <xsl:text>:: </xsl:text> @@ -382,6 +402,7 @@ <!-- == decorative_element --> <xsl:template match="//document/decoration/header"> + <xsl:apply-templates/> </xsl:template> @@ -431,6 +452,7 @@ <xsl:value-of select="name()"/> <xsl:text>: </xsl:text> + </xsl:with-param> </xsl:call-template> </xsl:template> @@ -447,6 +469,7 @@ <!-- no semicolon after final author --> <xsl:if test="generate-id(current()) != generate-id(../*[last()])"> + <xsl:text>; </xsl:text> </xsl:if> </xsl:template> @@ -461,6 +484,7 @@ match="docinfo/field"> <!-- contents handled by ordinary field lists --> <xsl:apply-templates/> + <!-- Supply an EOL because following elements do not recognize this --> &tEOL; </xsl:template> @@ -478,6 +502,7 @@ name="u:outputFolding"> <xsl:with-param name="prefix"> + <xsl:text>:</xsl:text> <xsl:value-of select="name()"/> @@ -501,6 +526,7 @@ &tCR; <!-- req: blank line before --> <xsl:text>-----</xsl:text> &tEOL; + <!-- Add a required blank line after unless class follows immediately --> <xsl:if test="not(following-sibling::*[1]/@class)"> @@ -522,6 +548,7 @@ auto is used to indicate (with value "1") that the title has been numbered automatically. --> + <!-- == structural_subelement --> <xsl:template match="//document/title"> @@ -539,6 +566,7 @@ <xsl:variable name="length" select="string-length($text)"/> + <xsl:call-template name="u:overline"> <xsl:with-param @@ -559,6 +587,7 @@ <xsl:with-param name="depth" select="1"/> + </xsl:call-template> </xsl:template> @@ -581,6 +610,7 @@ name="u:outputClass"/> <xsl:variable name="textWS"> + <!-- catch the title text as it is rendered --> <xsl:apply-templates/> </xsl:variable> @@ -601,6 +631,7 @@ <xsl:with-param name="depth" select="$depth + 2"/> + </xsl:call-template> <xsl:value-of select="$text"/> @@ -617,6 +648,7 @@ <!-- Add a blank line after unless structure follows immediately --> <xsl:if test="not(contains(concat($structural_elements, $compound_body_elements), concat('*', name(following-sibling::*[1]), '*')) or following-sibling::*[1]/@class)"> + &tCR; </xsl:if> </xsl:template> @@ -636,6 +668,7 @@ match="title"> <xsl:call-template name="u:outputClass"> + <xsl:with-param name="alreadyBlanked" select="true()"/> @@ -655,6 +688,7 @@ Attributes: The subtitle element contains only the common attributes: id, name, dupname, source, and class. --> + <!-- == structural_subelement --> <xsl:template match="//document/subtitle"> @@ -688,6 +722,7 @@ &tEOL; <xsl:call-template name="u:underline"> + <xsl:with-param name="length" select="$length"/> @@ -707,6 +742,7 @@ <!-- == structural_subelement --> <xsl:template match="sidebar/subtitle"> + <xsl:call-template name="u:outputClass"/> <xsl:call-template @@ -735,6 +771,7 @@ name="prefix"> <xsl:text>.. </xsl:text> </xsl:with-param> + </xsl:call-template> </xsl:template> @@ -752,6 +789,7 @@ name="u:outputClass"/> <xsl:call-template name="u:BandI"/> + <xsl:apply-templates/> &tEOL; </xsl:template> @@ -763,6 +801,7 @@ <xsl:template match="image"> <xsl:choose> + <xsl:when test="contains($inline_containers, concat('*', name(..), '*')) and @alt"> <!-- An inline image with an `@alt' - must be a substitution @@ -774,6 +813,7 @@ <xsl:text>|</xsl:text> </xsl:when> <xsl:otherwise> + <!-- A directive --> <xsl:if test="not(parent::figure)"> @@ -785,6 +825,7 @@ </xsl:if> <xsl:text>image:: </xsl:text> </xsl:if> + <xsl:value-of select="@uri"/> &tEOL; @@ -802,6 +843,7 @@ <xsl:with-param name="value" select="../@class"/> + <xsl:with-param name="ancestors" select="ancestor::*"/> @@ -817,6 +859,7 @@ </xsl:when> <xsl:when test="parent::substitution_definition"> + <xsl:call-template name="u:params"> <!-- `@alt' only for the real images --> @@ -830,6 +873,7 @@ name="u:params"/> </xsl:otherwise> </xsl:choose> + <xsl:if test="parent::reference"> <!-- A clickable image --> @@ -846,6 +890,7 @@ <!-- An internal link --> <xsl:call-template name="u:inlineReference"> + <xsl:with-param name="text" select="../@refid"/> @@ -858,6 +903,7 @@ </xsl:otherwise> </xsl:choose> </xsl:with-param> + <xsl:with-param name="ancestors" select="ancestor-or-self::*"/> @@ -888,6 +934,7 @@ test="not($isEmbedded)"> <xsl:call-template name="u:blank"/> + </xsl:if> <xsl:apply-templates/> </xsl:template> @@ -904,6 +951,7 @@ match="line"> <xsl:call-template name="u:outputClass"/> + <xsl:variable name="indent"> <xsl:call-template @@ -918,6 +966,7 @@ <xsl:variable name="lineBlockIndent"> <!-- Very special indendation for nested `line_block's --> + <xsl:for-each select="ancestor::line_block[position() > 1]"> <xsl:call-template @@ -933,6 +982,7 @@ <xsl:with-param name="prefix"> <xsl:text>| </xsl:text> + <xsl:value-of select="$lineBlockIndent"/> </xsl:with-param> @@ -944,6 +994,7 @@ <xsl:otherwise> <xsl:text>|</xsl:text> &tEOL; + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -960,6 +1011,7 @@ match="literal_block"> <xsl:call-template name="u:outputClass"/> + <!-- TODO: Support for the (fully) minimized style would be nice but is difficult to accomplish because there is a linefeed already when we arrive here :-( --> @@ -973,6 +1025,7 @@ <xsl:call-template name="u:isQuotedLiteral"/> </xsl:variable> + <!-- Indent correctly depending on quoted literal or not --> <xsl:choose> <xsl:when @@ -987,6 +1040,7 @@ mode="quotedLiteral"/> </xsl:when> <xsl:otherwise> + <xsl:call-template name="u:indent"> <xsl:with-param @@ -1015,6 +1069,7 @@ </xsl:call-template> </xsl:with-param> </xsl:call-template> + </xsl:template> <!-- Determine whether `$text' is a quoted literal and return the quote @@ -1032,6 +1087,7 @@ <!-- Given quote is an adornment character and first character is this quote --> <xsl:choose> + <xsl:when test="contains($text, ' ')"> <!-- Test the remaining lines --> @@ -1047,6 +1103,7 @@ </xsl:when> <xsl:otherwise> <!-- No more lines to test so this is a quoted literal --> + <xsl:value-of select="$quote"/> </xsl:otherwise> @@ -1062,6 +1119,7 @@ name, dupname, source, and class. --> <!-- == simple_body_element == folding_element --> + <xsl:template match="paragraph"> <xsl:variable @@ -1080,6 +1138,7 @@ test="$needsBlank"> &tCR; </xsl:if> + <xsl:if test="$needsIndent"> <xsl:call-template @@ -1098,6 +1157,7 @@ name="alreadyIndented" select="$needsIndent"/> </xsl:call-template> + <xsl:call-template name="u:BandI"/> </xsl:if> @@ -1112,6 +1172,7 @@ match="pending"> <xsl:call-template name="u:notSupported"/> + </xsl:template> <!-- ******************************************************************** --> @@ -1124,6 +1185,7 @@ <xsl:call-template name="u:BandI"/> <xsl:text>.. raw:: </xsl:text> + <xsl:value-of select="@format"/> &tEOL; @@ -1140,6 +1202,7 @@ name="ancestors" select="ancestor-or-self::*"/> </xsl:call-template> + <xsl:apply-templates/> &tEOL; </xsl:template> @@ -1153,6 +1216,7 @@ name="u:BandI"/> <xsl:call-template name="u:outputFolding"> + <xsl:with-param name="prefix"> <xsl:text>.. rubric:: </xsl:text> @@ -1190,6 +1254,7 @@ <xsl:variable name="prefix"> <xsl:text>.. |</xsl:text> + <xsl:value-of select="@name"/> <xsl:text>| </xsl:text> @@ -1204,6 +1269,7 @@ name="u:outputFolding"> <xsl:with-param name="prefix"> + <xsl:value-of select="$prefix"/> <xsl:text>replace:: </xsl:text> @@ -1214,6 +1280,7 @@ <xsl:value-of select="$prefix"/> <xsl:apply-templates/> + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -1230,6 +1297,7 @@ match="block_quote"> <xsl:if test="@class = 'epigraph' or @class = 'highlights' or @class = 'pull-quote'"> + <xsl:call-template name="u:BandI"/> <xsl:text>.. </xsl:text> @@ -1241,6 +1309,7 @@ name="u:params"/> </xsl:if> <xsl:apply-templates/> + </xsl:template> <!-- ******************************************************************** --> @@ -1254,6 +1323,7 @@ &tCR; <xsl:call-template name="u:indent"/> + <xsl:call-template name="u:outputFolding"> <xsl:with-param @@ -1278,6 +1348,7 @@ <xsl:text>] </xsl:text> <xsl:apply-templates select="*[not(self::label)]"/> + </xsl:template> <!-- == simple_body_subelement --> @@ -1289,6 +1360,7 @@ <!-- ******************************************************************** --> <!-- == compound_body_element == directive --> + <xsl:template match="figure"> <xsl:call-template @@ -1300,6 +1372,7 @@ <!-- ******************************************************************** --> <!-- == simple_body_subelement == folding_element --> + <xsl:template match="caption"> <xsl:call-template @@ -1314,6 +1387,7 @@ <xsl:template match="legend"> <xsl:apply-templates/> + </xsl:template> <!-- ******************************************************************** --> @@ -1327,6 +1401,7 @@ <xsl:call-template name="u:BandI"/> <xsl:text>.. [</xsl:text> + <xsl:apply-templates select="label"/> <xsl:text>] </xsl:text> @@ -1340,6 +1415,7 @@ <!-- == compound_body_element == directive --> <xsl:template match="footnote[@auto='1']"> + <xsl:call-template name="u:outputClass"/> <xsl:call-template @@ -1353,6 +1429,7 @@ <xsl:text>] </xsl:text> <xsl:apply-templates select="*[not(self::label)]"/> + </xsl:template> <!-- autosymboled footnotes have @auto --> @@ -1366,6 +1443,7 @@ <xsl:text>.. [*] </xsl:text> <xsl:apply-templates select="*[not(self::label)]"/> + </xsl:template> <!-- == compound_body_element == directive --> @@ -1378,6 +1456,7 @@ <xsl:call-template name="u:BandI"/> <xsl:text>.. target-notes::</xsl:text> + &tEOL; </xsl:if> </xsl:template> @@ -1429,6 +1508,7 @@ Attributes: The definition_list_item element contains only the common attributes: id, name, dupname, source, and class. --> + <!-- == compound_body_subelement --> <xsl:template match="definition_list_item"> @@ -1446,6 +1526,7 @@ Attributes: The term element contains only the common attributes: id, name, dupname, source, and class. --> + <!-- == simple_body_subelement --> <xsl:template match="term"> @@ -1462,6 +1543,7 @@ <!-- == simple_body_subelement --> <xsl:template match="classifier"> + <xsl:text> : </xsl:text> <xsl:apply-templates/> </xsl:template> @@ -1476,6 +1558,7 @@ <!-- == compound_body_subelement --> <xsl:template match="definition"> + <xsl:call-template name="u:outputClass"/> <xsl:apply-templates/> @@ -1509,6 +1592,7 @@ match="enumerated_list"> <xsl:call-template name="u:outputClass"/> + <xsl:apply-templates mode="enumerated_list"/> </xsl:template> @@ -1526,6 +1610,7 @@ <xsl:call-template name="u:outputClass"/> <xsl:apply-templates/> + </xsl:template> <!-- ******************************************************************** --> @@ -1543,6 +1628,7 @@ <xsl:call-template name="u:BandI"/> <xsl:apply-templates/> + </xsl:template> <!-- ********************************************************************** --> @@ -1557,6 +1643,7 @@ match="field_name"> <xsl:text>:</xsl:text> <xsl:apply-templates/> + <xsl:text>: </xsl:text> <!-- no EOL: field_body starts on same line --> </xsl:template> @@ -1571,6 +1658,7 @@ <!-- == compound_body_subelement --> <xsl:template match="field_body"> + <xsl:call-template name="u:outputClass"/> <xsl:apply-templates/> @@ -1588,6 +1676,7 @@ match="option_list"> <xsl:call-template name="u:outputClass"/> + <xsl:call-template name="u:blank"/> <xsl:apply-templates/> @@ -1605,6 +1694,7 @@ match="option_list_item"> <xsl:call-template name="u:outputClass"/> + <xsl:call-template name="u:indent"/> <xsl:apply-templates/> @@ -1621,6 +1711,7 @@ <xsl:template match="option_group"> <xsl:apply-templates/> + &tEOL; </xsl:template> @@ -1637,6 +1728,7 @@ <xsl:call-template name="u:outputClass"/> <xsl:apply-templates/> + <xsl:if test="generate-id(current()) != generate-id(../*[last()])"> <!-- No comma after final option --> @@ -1670,6 +1762,7 @@ or the text between option arguments (typically either "," or " "). --> <!-- == simple_body_subelement --> + <xsl:template match="option_argument"> <xsl:value-of @@ -1687,6 +1780,7 @@ <!-- == compound_body_subelement --> <xsl:template match="description"> + <xsl:call-template name="u:outputClass"/> <xsl:apply-templates/> @@ -1709,6 +1803,7 @@ <xsl:template match="list_item" mode="bullet_list"> + <xsl:call-template name="u:outputClass"/> <xsl:call-template @@ -1740,6 +1835,7 @@ attribute may be omitted. --> + <!-- == compound_body_subelement --> <xsl:template match="list_item" @@ -1755,6 +1851,7 @@ <!-- Outputs a complete enumerator when called in an enumerated_list/list_item --> + <xsl:template name="u:outputEnumerator"> <!-- Use parent's numeration attribute --> @@ -1770,6 +1867,7 @@ <xsl:value-of select="../@start"/> </xsl:when> + <xsl:otherwise> <xsl:value-of select="1"/> @@ -1783,6 +1881,7 @@ name="wanted" select="generate-id()"/> <!-- Generate the right current node list --> + <xsl:for-each select="../list_item"> <xsl:if @@ -1797,6 +1896,7 @@ name="cur"> <xsl:call-template name="u:position2Enumerator"> + <xsl:with-param name="enumType" select="$enumType"/> @@ -1816,6 +1916,7 @@ <xsl:with-param name="enumType" select="$enumType"/> + <xsl:with-param name="position" select="count(../list_item)"/> @@ -1832,6 +1933,7 @@ <xsl:value-of select="../@suffix"/> <!-- Output at least one trailing space --> + &tSP; <!-- Output more whitespace to align with the maximum enumerator --> <xsl:if @@ -1860,6 +1962,7 @@ name="ordinal" select="$start - 1 + $position"/> <xsl:choose> + <xsl:when test="$enumType = 'arabic'"> <xsl:value-of @@ -1875,6 +1978,7 @@ <xsl:value-of select="substring('ABCDEFGHIJKLMNOPQRSTZUVWXYZ', $ordinal, 1)"/> </xsl:when> + <!-- TODO: Support for counting roman numbers --> <xsl:when test="$enumType = 'lowerroman'"> @@ -1885,6 +1989,7 @@ <xsl:text>I</xsl:text> </xsl:when> </xsl:choose> + </xsl:template> <!-- ******************************************************************** --> @@ -1902,6 +2007,7 @@ name="u:outputClass"/> <xsl:call-template name="u:blank"/> + <xsl:apply-templates select="tgroup"/> <xsl:if @@ -1954,6 +2060,7 @@ <!-- == compound_body_subelement --> <xsl:template match="thead"> + <xsl:apply-templates/> </xsl:template> @@ -1987,6 +2094,7 @@ name="u:rowSeparatorLine"/> </xsl:if> <!-- Determine heights in physical lines of all entries --> + <xsl:variable name="heights"> <xsl:for-each @@ -2001,6 +2109,7 @@ <xsl:value-of select="string-length($text) - string-length(translate($text, ' ', '')) - 1"/> &tSP; <!-- A space as a list separator --> + </xsl:for-each> </xsl:variable> <!-- Determine maximum height so every entry must be this high --> @@ -2014,6 +2123,7 @@ </xsl:call-template> </xsl:variable> <!-- Output all the physical lines of this row --> + <xsl:call-template name="u:rowLines"> <xsl:with-param @@ -2031,6 +2141,7 @@ <xsl:with-param name="char"> <!-- Determine correct character for the separator line --> + <xsl:choose> <xsl:when test="parent::thead"> @@ -2043,6 +2154,7 @@ </xsl:otherwise> </xsl:choose> </xsl:with-param> + </xsl:call-template> </xsl:if> </xsl:template> @@ -2057,6 +2169,7 @@ name="maxLine"/> <xsl:if test="$currentLine <= $maxLine"> + <!-- If there are still physical lines to output do it --> <xsl:call-template name="u:indent"/> @@ -2068,6 +2181,7 @@ select="$currentLine"/> </xsl:apply-templates> <!-- End of this physical line --> + &tEOL; <!-- Continue with the next physical line --> <xsl:call-template @@ -2098,6 +2212,7 @@ <xsl:with-param name="length" select="@colwidth"/> + <xsl:with-param name="chars" select="$char"/> @@ -2131,6 +2246,7 @@ <!-- Determine width in characters needed for this entry --> <xsl:variable name="width"> + <xsl:call-template name="u:computeEntryWidth"> <xsl:with-param @@ -2149,6 +2265,7 @@ name="u:outputEntry"> <xsl:with-param name="string"> + <!-- Capture physical lines of the entry in a variable --> <xsl:apply-templates/> </xsl:with-param> @@ -2165,6 +2282,7 @@ <xsl:with-param name="outputLine" select="$currentLine"/> + </xsl:call-template> <!-- Final bar after the entry --> <xsl:text>|</xsl:text> @@ -2176,6 +2294,7 @@ <!-- The colspec elements of all columns --> <xsl:param name="colspecs"/> + <!-- Column of this entry --> <xsl:param name="column"/> @@ -2192,6 +2311,7 @@ <!-- If entry spans multiple columns compute their width --> <xsl:call-template name="u:computeEntryWidth"> + <xsl:with-param name="colspecs" select="$colspecs"/> @@ -2210,6 +2330,7 @@ <xsl:otherwise> <!-- Does not span more columns so return sum and width of this column --> + <xsl:value-of select="$sum + $colspecs[$column]/@colwidth"/> </xsl:otherwise> @@ -2224,6 +2345,7 @@ longer than this width --> <xsl:param name="width"/> + <!-- The string containing the remaining physical lines; may be an empty string --> <xsl:param @@ -2244,6 +2366,7 @@ select="0"/> <!-- Output is wanted if all or the first physical line are to be output --> + <xsl:variable name="doOutput" select="$outputLine = 0 or $outputLine = 1"/> @@ -2259,6 +2382,7 @@ <xsl:otherwise> <xsl:value-of select="$string"/> + </xsl:otherwise> </xsl:choose> </xsl:variable> @@ -2271,6 +2395,7 @@ <xsl:value-of select="substring($stringLFHalfTrimmed, 1, string-length($stringLFHalfTrimmed) - 1)"/> </xsl:when> + <xsl:otherwise> <xsl:value-of select="$stringLFHalfTrimmed"/> @@ -2284,6 +2409,7 @@ test="contains($stringLFTrimmed, ' ')"> <xsl:value-of select="substring-after($stringLFTrimmed, ' ')"/> + </xsl:if> </xsl:variable> <xsl:if @@ -2298,6 +2424,7 @@ <xsl:value-of select="substring-before($stringLFTrimmed, ' ')"/> </xsl:when> + <xsl:otherwise> <xsl:value-of select="$stringLFTrimmed"/> @@ -2311,6 +2438,7 @@ <xsl:if test="string-length($firstLine)"> <!-- Trim only non-empty lines --> + <xsl:value-of select="substring-after($firstLine, $expectedIndent)"/> </xsl:if> @@ -2325,6 +2453,7 @@ <!-- Fill up the width of the entry with spaces --> <xsl:if test="$width - string-length($padded) < 0"> + <xsl:message> <xsl:text>WARNING: Table column too narrow (minimum: </xsl:text> <xsl:value-of @@ -2335,6 +2464,7 @@ </xsl:if> <xsl:call-template name="u:repeat"> + <xsl:with-param name="length" select="$width - string-length($padded)"/> @@ -2349,6 +2479,7 @@ <!-- Output linefeed only if we output all the lines --> &tEOL; </xsl:if> + <!-- Output the remaining lines --> <xsl:call-template name="u:outputEntry"> @@ -2369,6 +2500,7 @@ <xsl:choose> <xsl:when test="$outputLine = 0"> + <xsl:value-of select="0"/> </xsl:when> @@ -2380,6 +2512,7 @@ </xsl:with-param> </xsl:call-template> </xsl:if> + </xsl:template> <!-- ******************************************************************** --> @@ -2391,6 +2524,7 @@ <xsl:call-template name="u:bkslshEscPre"/> <xsl:text>[</xsl:text> + <xsl:apply-templates/> <xsl:text>]_</xsl:text> <xsl:call-template @@ -2402,6 +2536,7 @@ <!-- == inline_element --> <xsl:template match="emphasis"> + <xsl:call-template name="u:bkslshEscPre"/> <xsl:text>*</xsl:text> @@ -2423,6 +2558,7 @@ <xsl:value-of select="text()"/> <xsl:text>]_</xsl:text> + <xsl:call-template name="u:bkslshEscSuf"/> <!-- child paragraph provides blank line --> @@ -2436,6 +2572,7 @@ <xsl:variable name="ref" select="@refid"/> + <xsl:if test="not(starts-with(//footnote[@id=$ref]/@name, 'target_note: '))"> <!-- Not a generated footnote reference for a `.. target-notes::'; @@ -2450,6 +2587,7 @@ select="//footnote[@id=$ref]/@name"/> </xsl:if> <xsl:text>]_</xsl:text> + <xsl:call-template name="u:bkslshEscSuf"/> </xsl:if> @@ -2462,6 +2600,7 @@ <xsl:call-template name="u:bkslshEscPre"/> <xsl:text>[*]_</xsl:text> + <xsl:call-template name="u:bkslshEscSuf"/> </xsl:template> @@ -2477,6 +2616,7 @@ <xsl:call-template name="u:bkslshEscPre"/> <xsl:text>``</xsl:text> + <xsl:apply-templates/> <xsl:text>``</xsl:text> <xsl:call-template @@ -2502,6 +2642,7 @@ --> <!-- Standalone hyperlink --> + <!-- == inline_element --> <xsl:template match="reference[not(@name or @anonymous)]"> @@ -2514,6 +2655,7 @@ <xsl:value-of select="substring-after(., 'PEP ')"/> <xsl:text>`</xsl:text> + </xsl:when> <xsl:when test="starts-with(., 'RFC ')"> @@ -2524,6 +2666,7 @@ </xsl:when> <xsl:otherwise> <xsl:apply-templates/> + </xsl:otherwise> </xsl:choose> <xsl:call-template @@ -2535,6 +2678,7 @@ <xsl:template match="reference[@name and @refuri]"> <!-- Determine normalized name by downcasing it --> + <xsl:variable name="normalized" select="translate(normalize-space(@name), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/> @@ -2553,6 +2697,7 @@ </xsl:template> <!-- Internal references --> + <!-- == inline_element --> <xsl:template match="reference[@name and @refid]"> @@ -2566,6 +2711,7 @@ <!-- Image references --> <!-- == inline_element --> + <xsl:template match="reference[image]"> <!-- All done by the `image' tag --> @@ -2580,6 +2726,7 @@ <!-- == inline_element --> <xsl:template match="strong"> + <xsl:call-template name="u:bkslshEscPre"/> <xsl:text>**</xsl:text> @@ -2601,6 +2748,7 @@ <xsl:text>`</xsl:text> <xsl:call-template name="u:bkslshEscSuf"/> + </xsl:template> <!-- ******************************************************************** --> @@ -2612,6 +2760,7 @@ name="u:bkslshEscPre"/> <xsl:text>:sup:`</xsl:text> <xsl:apply-templates/> + <xsl:text>`</xsl:text> <xsl:call-template name="u:bkslshEscSuf"/> @@ -2624,6 +2773,7 @@ <!-- == simple_body_element == inline_element == directive --> <xsl:template match="target"> + <xsl:choose> <xsl:when test="name(preceding-sibling::*[1]) = 'reference'"> @@ -2638,6 +2788,7 @@ name="isTarget" select="true()"/> </xsl:call-template> + </xsl:when> <xsl:when test="@name"> @@ -2650,6 +2801,7 @@ <xsl:value-of select="@name"/> <xsl:text>:</xsl:text> + <xsl:if test="@refuri"> <xsl:text> </xsl:text> @@ -2661,6 +2813,7 @@ <xsl:when test="@anonymous"> <!-- An anonymous target directive --> + <xsl:call-template name="u:outputClass"/> <xsl:call-template @@ -2673,6 +2826,7 @@ select="@refid"/> <xsl:text>_</xsl:text> </xsl:when> + <xsl:when test="@refuri"> <xsl:value-of @@ -2685,6 +2839,7 @@ <!-- Should not happen --> <xsl:call-template name="u:notSupported"/> + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -2699,6 +2854,7 @@ match="title_reference"> <xsl:call-template name="u:bkslshEscPre"/> + <xsl:text>`</xsl:text> <xsl:apply-templates/> <xsl:text>`</xsl:text> @@ -2711,6 +2867,7 @@ <!-- Content Model: %text.model; --> + <!-- == inline_element --> <xsl:template match="inline"> @@ -2723,6 +2880,7 @@ select="@class"/> <xsl:text>:`</xsl:text> <xsl:apply-templates/> + <xsl:text>`</xsl:text> <xsl:call-template name="u:bkslshEscSuf"/> @@ -2767,6 +2925,7 @@ match="text()"> <xsl:call-template name="u:indentLF"/> + </xsl:template> <!-- ******************************************************************** --> @@ -2796,6 +2955,7 @@ <xsl:template mode="blankSkipInline" match="*"> + <xsl:choose> <!-- Skip all inline elements and body subelements and check their parents --> @@ -2810,6 +2970,7 @@ <xsl:if test="contains($blank_after, concat('*', name(.), '*'))"> &tCR; + </xsl:if> </xsl:otherwise> </xsl:choose> @@ -2821,9 +2982,10 @@ Indent a block if it's a child of... --> <data:lookup> - <node - name="address" + <node + name="address" indent="10"/> + <node name="author" indent="9"/> @@ -2851,6 +3013,7 @@ <node name="version" indent="10"/> + <!-- This is only for `bullet_list/list_item'; `enumerated_list/list_item' is handled special --> <node @@ -2876,6 +3039,7 @@ <node name="attribution" indent="3"/> + </data:lookup> <!-- Do indent according to ancestor --> @@ -2892,6 +3056,7 @@ name="this" select="name()"/> <xsl:choose> + <xsl:when test="contains($directives, concat('*', $this, '*'))"> <xsl:call-template @@ -2909,6 +3074,7 @@ name="enumerator"> <xsl:call-template name="u:outputEnumerator"/> + </xsl:variable> <xsl:call-template name="u:repeat"> @@ -2922,8 +3088,9 @@ name="u:repeat"> <xsl:with-param name="length" - select="document('')//data:lookup/node[@name=$this]/@indent"/> + select="//data:lookup/node[@name=$this]/@indent"/> </xsl:call-template> + </xsl:otherwise> </xsl:choose> </xsl:for-each> @@ -2940,6 +3107,7 @@ <xsl:param name="length" select="0"/> + <xsl:param name="chars" select="' '"/> @@ -2956,6 +3124,7 @@ <xsl:value-of select="substring($string, 1, $length)"/> </xsl:when> + <xsl:otherwise> <xsl:call-template name="u:repeat"> @@ -2986,6 +3155,7 @@ <!-- If not given compute it --> <xsl:call-template name="u:indent"/> + </xsl:param> <xsl:choose> <xsl:when @@ -2998,6 +3168,7 @@ <xsl:value-of select="$indent"/> <!-- Output remaining physical lines --> + <xsl:call-template name="u:indentLF"> <xsl:with-param @@ -3013,6 +3184,7 @@ <xsl:value-of select="$string"/> </xsl:otherwise> + </xsl:choose> </xsl:template> @@ -3026,6 +3198,7 @@ name="prefix" select="''"/> <!-- The indentation for this body --> + <xsl:param name="indent"> <xsl:call-template @@ -3040,6 +3213,7 @@ <!-- TODO: Whitespace count of inline literals must be preserved --> <xsl:apply-templates/> </xsl:variable> + <!-- Always output prefix with all trailing and leading spaces --> <xsl:value-of select="$prefix"/> @@ -3054,6 +3228,7 @@ test="$string = ''"> <!-- Empty strings need no output --> </xsl:when> + <xsl:when test="$normalized = ''"> <!-- Only white-space in string; output a single space here --> @@ -3065,6 +3240,7 @@ test="normalize-space(substring($string, 1, 1)) = ''"> &tSP; </xsl:if> + <xsl:call-template name="u:indentFold"> <xsl:with-param @@ -3082,6 +3258,7 @@ test="normalize-space(substring($string, string-length($string), 1)) = ''"> &tSP; </xsl:if> + </xsl:otherwise> </xsl:choose> </xsl:when> @@ -3105,6 +3282,7 @@ <xsl:param name="indent"/> <!-- Current output column --> + <!-- TODO: This is not a correct assumption for field definitions where the field name effectively determines the column of the first line --> <xsl:param @@ -3122,6 +3300,7 @@ test="contains($string, ' ')"> <xsl:value-of select="substring-before($string, ' ')"/> + </xsl:when> <xsl:otherwise> <xsl:value-of @@ -3135,6 +3314,7 @@ <xsl:choose> <xsl:when test="$string = ''"/> + <xsl:when test="$isNewLine"> <!-- Output at least first word --> @@ -3155,6 +3335,7 @@ name="isNewLine" select="false()"/> </xsl:call-template> + </xsl:when> <xsl:when test="$cursorColumn + 1 + string-length($firstWord) > $fold"> @@ -3173,6 +3354,7 @@ <xsl:with-param name="cursorColumn" select="string-length($indent)"/> + <xsl:with-param name="isNewLine" select="true()"/> @@ -3188,6 +3370,7 @@ <xsl:with-param name="string" select="$rest"/> + <xsl:with-param name="indent" select="$indent"/> @@ -3220,6 +3403,7 @@ <!-- Skip URIs based on parent --> <xsl:if test="name() != 'uri' and name() != 'xml:space'"> + <xsl:call-template name="u:param"> <xsl:with-param @@ -3233,6 +3417,7 @@ <!-- Output one attribute of the current element as a field list --> <xsl:template name="u:param"> + <xsl:param name="name" select="name()"/> @@ -3251,6 +3436,7 @@ select="$ancestors"/> </xsl:call-template> <xsl:text>:</xsl:text> + <xsl:value-of select="$name"/> <xsl:text>: </xsl:text> @@ -3262,6 +3448,7 @@ <!-- ******************************************************************** --> <!-- Output `\' or `\ ' before some inline element if necessary --> + <xsl:template name="u:bkslshEscPre"> <!-- Get the sibling node directly before the current element --> @@ -3276,6 +3463,7 @@ <xsl:when test="name($before)"> <!-- So separate it by a quoted space --> + <xsl:text>\ </xsl:text> </xsl:when> <!-- Node directly before this is text - check it --> @@ -3285,6 +3473,7 @@ <xsl:text>\ </xsl:text> </xsl:when> </xsl:choose> + </xsl:template> <!-- Output `\' or `\ ' after some inline element if necessary --> @@ -3298,6 +3487,7 @@ <!-- No sibling after this node --> <xsl:when test="not($after)"/> + <!-- Element directly after this - must be another inline element handling itself --> <xsl:when @@ -3310,6 +3500,7 @@ <xsl:text>\</xsl:text> </xsl:when> </xsl:choose> + </xsl:template> <!-- ******************************************************************** --> @@ -3322,6 +3513,7 @@ <xsl:value-of select="name(.)"/> <xsl:text>' ########</xsl:text> + &tEOL; </xsl:template> @@ -3336,6 +3528,7 @@ greater than 2 are normal section titles --> <xsl:param name="depth"/> + <!-- Test whether a overline is wanted at all --> <xsl:if test="substring($adornment, 2 * ($depth - 1) + 1, 1) = 'o'"> @@ -3369,6 +3562,7 @@ <xsl:with-param name="chars" select="substring($adornment, 2 * ($depth - 1) + 2, 1)"/> + </xsl:call-template> &tEOL; </xsl:template> @@ -3384,6 +3578,7 @@ <xsl:param name="embedded" select="false()"/> + <!-- Is this a target instead of a reference? --> <xsl:param name="isTarget" @@ -3399,6 +3594,7 @@ <xsl:if test="* or translate($text, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', '') or $embedded"> <xsl:text>`</xsl:text> + </xsl:if> </xsl:variable> <xsl:if @@ -3411,6 +3607,7 @@ select="$text"/> <xsl:if test="$embedded"> + <xsl:text> <</xsl:text> <xsl:value-of select="@refuri"/> @@ -3423,6 +3620,7 @@ <xsl:text>_</xsl:text> <xsl:if test="$anonymous"> + <xsl:text>_</xsl:text> </xsl:if> </xsl:if> @@ -3433,6 +3631,7 @@ <!-- ******************************************************************** --> <!-- Determine the maximum number from a whitespace separated number list --> + <xsl:template name="u:maxNumber"> <xsl:param @@ -3452,6 +3651,7 @@ name="head" select="substring-before($cleanNumbers, ' ')"/> <xsl:choose> + <xsl:when test="$head > $currentMax"> <xsl:call-template @@ -3470,6 +3670,7 @@ <xsl:with-param name="numbers" select="substring-after($cleanNumbers, ' ')"/> + <xsl:with-param name="currentMax" select="$currentMax"/> @@ -3483,6 +3684,7 @@ test="$cleanNumbers > $currentMax"> <xsl:value-of select="$cleanNumbers"/> + </xsl:when> <xsl:otherwise> <xsl:value-of @@ -3507,6 +3709,7 @@ name="alreadyIndented" select="false()"/> <!-- Add a blank line after class directive? --> + <xsl:param name="blankAfter" select="false()"/> @@ -3523,6 +3726,7 @@ <xsl:call-template name="u:indent"/> </xsl:if> + <xsl:text>.. class:: </xsl:text> <xsl:value-of select="@class"/> @@ -3544,6 +3748,7 @@ <xsl:text>`</xsl:text> <xsl:value-of select="name(.)"/> + <xsl:text>' encountered</xsl:text> <xsl:if test="parent::*"> @@ -3553,6 +3758,7 @@ <xsl:text>'</xsl:text> </xsl:if> <xsl:text>, but no template matches.</xsl:text> + </xsl:message> </xsl:template>
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org