OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook] creating clickable titles


[switching to docbook-apps list]

That use case sounds reasonable, although in my opinion making
headings links to themselves sounds a little confusing to users. I
typically use the webhelp output format instead of direct HTML so my
output displays the TOC on every page. It's easy for me to copy the
URL for any page from that TOC.

To do what you are describing, I would start by taking a look at the
section.heading template in the html/sections.xsl file. Here's a
snippet from that template:

<xsl:element name="h{$hlevel}">
    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
    <xsl:if test="$css.decoration != '0'">
      <xsl:if test="$hlevel&lt;3">
        <xsl:attribute name="style">clear: both</xsl:attribute>
      </xsl:if>
    </xsl:if>
    <xsl:if test="$allow-anchors != 0">
      <xsl:call-template name="anchor">
        <xsl:with-param name="node" select="$section"/>
        <xsl:with-param name="conditional" select="0"/>
      </xsl:call-template>
    </xsl:if>
    <xsl:copy-of select="$title"/>
  </xsl:element>

The line <xsl:copy-of select="$title"/> enters the text of the
heading. You could experiment with adding an <xsl:element
name="a"><xsl:attribute name="href"> enclosure around that xsl:copy
element.

You'd have to get the ID of the parent section in order to complete
the href attribute. That should be available from the $section
parameter of the template. But the way you get the ID depends on how
your source DocBook is formed.

Also, this would not affect chapter titles. You'd need to hunt down
the template that writes chapter headings and do something similar.

You'll need to get a little intimate with the XSLT in order to do this
my way. I am assuming you already have a customization layer
(http://www.sagehill.net/docbookxsl/CustomMethods.html#CustomizationLayer).
Maybe someone has a simpler solution.

Hope this helps.

Peter

On Tue, Feb 11, 2014 at 11:53 PM, natk <nkershaw@gmail.com> wrote:
> Hi,
>
> Thanks.
>
> The use-case for this is you're reading the document, and you want to
> communicate a particular spot in the document to someone else. You click on
> the document, and that gives you the URL (document#anchor) to send.
>
> Nat
>
>
>
> On Wed, Feb 12, 2014 at 3:48 PM, Peter Desjardins
> <peter.desjardins.us@gmail.com> wrote:
>>
>> Hi.
>>
>> Typically, this sort of question should go to
>> docbook-apps@lists.oasis-open.org because it is about publishing tools
>> rather than the XML source.
>>
>> I can image writing customization code that would do this. It doesn't
>> look too difficult once you find the template that writes the
>> headings.
>>
>> But I'm curious about the intent. Do you want to make each heading a
>> link to itself? I don't understand how that would be useful.
>>
>> Maybe I am not understanding what you are trying to accomplish?
>>
>> Peter
>>
>> On Tue, Feb 11, 2014 at 10:36 PM, natk <nkershaw@gmail.com> wrote:
>> > Hi,
>> >
>> > I wondered if there is any way of creating clickable titles in the HTML
>> > output of docbook.
>> >
>> > The output would look something like:
>> >
>> > <h1 id="title"><a href="#title">Title</a></h1>
>> >
>> > The reason for doing this would be to be able to identify and
>> > communicate
>> > particular sections of a document.
>> >
>> > Nat
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]