You need for every appendix, chapter, section, etc. a small hint (often depicted as “¶”) which points to the division itself. This “permalink” simplies the retrieval and indentification of such a division.
You need an ID attribute on your division (chapter, section,
examples, etc.) to make it work. The
permalinks.xsl
stylesheet is a named
template which expects an id
parameter.
permalinks.xsl
)<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="generate.permalink" select="1"/> <xsl:param name="permalink.text">¶</xsl:param> <xsl:template name="permalink"> <xsl:param name="node" select="."/> <xsl:if test="$generate.permalink != '0'"> <span class="permalink"> <a alt="Permalink" title="Permalink"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$node"/> </xsl:call-template> </xsl:attribute> <xsl:copy-of select="$permalink.text"/> </a> </span> </xsl:if> </xsl:template> </xsl:stylesheet>
Contains parameter
| |
Contains parameter | |
Creates a | |
Creates an HTML | |
Creates a |
This is of course not enough. Use the following steps to include it into your customization layers:
Permalinks are useful as it allows it easily to copy its URL. The DocBook XSL stylesheets allows the addition of permalinks in different locations, but the above customizations make the permalink more “attached” to its title.
All the above customization files create almost the same structure in regards to its permalink. For example, a chapter title looks like this in HTML:
<h2 class="title">The Chapter Title<span class="permalink"><a href="..." title="Permalink" alt="Permalink">¶</a></span> </h1>
With CSS rules, you can style your permalink whatever you like.
Project@GitHub | Issue#10 |