diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-07-11 11:10:58 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-07-11 12:58:44 +0200 |
commit | dc77d6500fc26074895d9b8bb5089261dc7a28b1 (patch) | |
tree | 1c4c7c78bf61e344486c5cd24ed5b01d78dcf031 /data/xslt | |
parent | 8262c7dc22ccf9ce74563bdeee689dc6a03d1182 (diff) | |
download | bison-dc77d6500fc26074895d9b8bb5089261dc7a28b1.tar.gz |
html: don't define several times the same anchors
Currently when we output useless rules, they appear before the
grammar, but using the same invocation. As a result, the anchor is
defined twice, and the wrong one, being first, is honored.
* data/xslt/xml2xhtml.xsl (rule): Take a new 'anchor' parameter to
decide whether being an anchor, or a target.
Let it be true when output the grammar.
* tests/report.at: Adjust.
Diffstat (limited to 'data/xslt')
-rw-r--r-- | data/xslt/xml2xhtml.xsl | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/data/xslt/xml2xhtml.xsl b/data/xslt/xml2xhtml.xsl index b5aeba94..706ff997 100644 --- a/data/xslt/xml2xhtml.xsl +++ b/data/xslt/xml2xhtml.xsl @@ -227,6 +227,7 @@ <xsl:text> </xsl:text> <p class="pre"> <xsl:call-template name="style-rule-set"> + <xsl:with-param name="anchor" select="'true'" /> <xsl:with-param name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']" /> @@ -238,9 +239,11 @@ </xsl:template> <xsl:template name="style-rule-set"> + <xsl:param name="anchor"/> <xsl:param name="rule-set"/> <xsl:for-each select="$rule-set"> <xsl:apply-templates select="."> + <xsl:with-param name="anchor" select="$anchor"/> <xsl:with-param name="pad" select="'3'"/> <xsl:with-param name="prev-lhs"> <xsl:if test="position()>1"> @@ -488,7 +491,12 @@ </xsl:apply-templates> </xsl:template> +<!-- +anchor = 'true': define as an <a> anchor. +itemset = 'true': show the items. + --> <xsl:template match="rule"> + <xsl:param name="anchor"/> <xsl:param name="itemset"/> <xsl:param name="pad"/> <xsl:param name="prev-lhs"/> @@ -499,20 +507,13 @@ <xsl:text> </xsl:text> </xsl:if> - <xsl:if test="$itemset != 'true'"> - <a> - <xsl:attribute name="name"> - <xsl:value-of select="concat('rule_', @number)"/> - </xsl:attribute> - </a> - </xsl:if> <xsl:text> </xsl:text> <xsl:choose> - <xsl:when test="$itemset = 'true'"> + <xsl:when test="$anchor = 'true'"> <a> - <xsl:attribute name="href"> - <xsl:value-of select="concat('#rule_', @number)"/> + <xsl:attribute name="name"> + <xsl:value-of select="concat('rule_', @number)"/> </xsl:attribute> <xsl:call-template name="lpad"> <xsl:with-param name="str" select="string(@number)"/> @@ -521,10 +522,15 @@ </a> </xsl:when> <xsl:otherwise> - <xsl:call-template name="lpad"> - <xsl:with-param name="str" select="string(@number)"/> - <xsl:with-param name="pad" select="number($pad)"/> - </xsl:call-template> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="concat('#rule_', @number)"/> + </xsl:attribute> + <xsl:call-template name="lpad"> + <xsl:with-param name="str" select="string(@number)"/> + <xsl:with-param name="pad" select="number($pad)"/> + </xsl:call-template> + </a> </xsl:otherwise> </xsl:choose> <xsl:text> </xsl:text> |