diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2021-04-14 15:51:02 -0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2021-04-14 21:00:20 +0200 |
commit | 81014e5cb46166183723ae911f6968e56b403107 (patch) | |
tree | 3a6af1b368ac74dfebea41902ec4185a1dc55383 | |
parent | d5c6af3d35bef4a734dd38725f069b393d02379d (diff) |
Fix sort command in Help pages
After the introduction of the headings h1 ... h6 in the Help
pages the sort command broke. It relied only in the <paragraph>
tag for sorting, usually the first paragraph in the section.
The patch extend the DTD to handle the new descendant="" attribute
to select which tag to sort in the Help page
Default is <paragraph> for backward compatibility.
Pages with <sort> must be revisited.
Change-Id: I3c6f243369429ed7824a68b11757dc15f4555c0f
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/114110
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r-- | help3xsl/online_transform.xsl | 59 | ||||
-rw-r--r-- | helpers/xmlhelp.dtd | 1 |
2 files changed, 56 insertions, 4 deletions
diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index c6e2ee1bbc..d30add9d93 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -589,20 +589,71 @@ <xsl:template match="sort" > <xsl:variable name="order1"> <xsl:choose> - <xsl:when test="string-length(@order) = 0"><xsl:value-of select="'ascending'"/></xsl:when> + <xsl:when test="string-length(@order) = 0"><xsl:value-of select="'ascending'"/></xsl:when> <xsl:otherwise><xsl:value-of select="concat(@order,'ending')"/></xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + <xsl:choose> + <xsl:when test="string-length(@descendant)=0"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h1'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h1"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h2'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h2"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h3'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h3"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h4'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h4"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h5'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h5"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h6'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h6"/></xsl:apply-templates> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template match="sort" mode="embedded"> <xsl:variable name="order1"> <xsl:choose> - <xsl:when test="string-length(@order) = 0"><xsl:value-of select="'ascending'"/></xsl:when> + <xsl:when test="string-length(@order) = 0"><xsl:value-of select="'ascending'"/></xsl:when> <xsl:otherwise><xsl:value-of select="concat(@order,'ending')"/></xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + <xsl:choose> + <xsl:when test="string-length(@descendant)=0"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h1'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h1"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h2'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h2"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h3'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h3"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h4'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h4"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h5'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h5"/></xsl:apply-templates> + </xsl:when> + <xsl:when test="@descendant='h6'"> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::h6"/></xsl:apply-templates> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates><xsl:sort order="{$order1}" select="descendant::paragraph"/></xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> + </xsl:template> <!-- SWITCH --> diff --git a/helpers/xmlhelp.dtd b/helpers/xmlhelp.dtd index 488e7286f8..6a4ef9778b 100644 --- a/helpers/xmlhelp.dtd +++ b/helpers/xmlhelp.dtd @@ -215,6 +215,7 @@ Version Nov 2018 <!ELEMENT sort (section+)> <!ATTLIST sort order (asc | desc) #IMPLIED + descendant (paragraph | h1 | h2 | h3 | h4 | h5 | h6 ) #IMPLIED > <!ELEMENT switch ((case | comment)* | default?)*> |