Added anchor links generation function for refsect1,2,3
Hello.
There is small patch for documentation. Some extend of "Make HTML ids
discoverable" by Brar Piening.
Discussion:
/messages/by-id/CAB8KJ=jpuQU9QJe4+RgWENrK5g9jhoysMw2nvTN_esoOU0=a_w@mail
It adds docbook function, that generates anchor links ("#" symbol
related to any refsect1/2/3).
e.g. for amcheck or pg_restore
You can compile documentation and anchor will be available in local
.html by placing mouse cursor on refsect header.
Best regards, Oleg Gurev.
Attachments:
anchors.patchtext/x-patch; charset=UTF-8; name=anchors.patchDownload
diff --git a/doc/src/sgml/stylesheet-html-common.xsl b/doc/src/sgml/stylesheet-html-common.xsl
index 9dcf96c02e5..03baa994893 100644
--- a/doc/src/sgml/stylesheet-html-common.xsl
+++ b/doc/src/sgml/stylesheet-html-common.xsl
@@ -390,6 +390,45 @@ set toc,title
</xsl:if>
</xsl:template>
+<!-- Add an id link for each refsect entry -->
+<xsl:template match="refsect1/title
+ |refsect2/title
+ |refsect3/title">
+
+ <xsl:param name="section"
+ select="(ancestor::refsect1
+ |ancestor::refsect2
+ |ancestor::refsect3)[last()]"/>
+
+ <!-- Select header size related to section level -->
+ <xsl:variable name="hlevel">
+ <xsl:choose>
+ <xsl:when test="local-name($section) = 'refsect1'">2</xsl:when>
+ <xsl:when test="local-name($section) = 'refsect2'">3</xsl:when>
+ <xsl:when test="local-name($section) = 'refsect3'">4</xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- We need to redo <h[2..4]> tag to make same font size. -->
+ <xsl:text disable-output-escaping="yes"><h</xsl:text>
+ <xsl:value-of select ="$hlevel"/>
+ <xsl:text disable-output-escaping="yes">></xsl:text>
+ <!-- Apply default templates -->
+ <xsl:apply-templates/>
+ <!-- Check that title parent has @id variable -->
+ <xsl:choose>
+ <xsl:when test="$section/@id or $section/@xml:id">
+ <!-- Form and add link -->
+ <xsl:call-template name="pg.id.link">
+ <xsl:with-param name="object" select="$section"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ <!-- We need to redo </h[2..4]> tag to make same font size. -->
+ <xsl:text disable-output-escaping="yes"></h</xsl:text>
+ <xsl:value-of select ="$hlevel"/>
+ <xsl:text disable-output-escaping="yes">></xsl:text>
+</xsl:template>
<!-- Create a link pointing to an id within the document -->
<xsl:template name="pg.id.link">
It adds docbook function, that generates anchor links ("#" symbol
related to any refsect1/2/3).
Hi there! It looks good to me that you've made some changes. Anchors are a
great addition for direct linking. I hope this update will make it easier
to write the documentation.
Best regards, Stepan Neretin.