Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1270 Footnote links broken by nested <a> elements

output: HTML
closed-fixed
nobody
XSL (1066)
5
2012-12-13
2012-12-07
AndyHatton
No

[Apologies if this appears twice - I suffered a browser crash]

Using DocBook 1.77.1 stylesheets, in xhtml/footnote.xsl and html/footnote.xsl links to footnotes are output using nested <a> elements.

The outer <a> element is the link to the footnote, and the inner <a> element is the named anchor for the corresponding link *from* the footnote. Here is an example:

<p>
Microsoft Windows 8 (32-bit and 64-bit)
<a href="#ftn.reqs-client-win8" class="footnote">
<sup class="footnote">
<a id="reqs-client-win8"></a>
[a]
</sup>
</a>
</p>

This is perfectly valid markup. However browsers (I tested Firefox and IE) don't cope very well with <a> elements nested in this way and you end up with no link as the browser tries to "correct" the markup. Firefox for example "corrects" the above markup to the following:

<p>
Microsoft Windows 8 (32-bit and 64-bit)
<a class="footnote" href="#ftn.reqs-client-win8">
<sup class="footnote"></sup>
</a>
<a id="reqs-client-win8"></a>
[a] <=== TEXT MOVED AND LINK NOT RENDERED ===
</p>

If you adjust the output so that the <a> elements are not nested, then the footnote links work as expected.

Option 1 would be to move the named anchor to before the link to the footnote, like this:

<p>
Microsoft Windows 8 (32-bit and 64-bit)
<a id="reqs-client-win8"></a>
<a href="#ftn.reqs-client-win8" class="footnote">
<sup class="footnote">
[a]
</sup>
</a>
</p>

Option 2 would be to create a single <a> element that is both a link and a named anchor, like this:

<p>
Microsoft Windows 8 (32-bit and 64-bit)
<a href="#ftn.reqs-client-win8" id="reqs-client-win8" class="footnote">
<sup class="footnote">
[a]
</sup>
</a>
</p>

Discussion

  • Robert Stayton
    Robert Stayton
    2012-12-10

    Actually, this is already fixed in SVN. Could you test your content with a snapshot build?

     
  • AndyHatton
    AndyHatton
    2012-12-13

    • status: open --> closed-fixed
     
  • AndyHatton
    AndyHatton
    2012-12-13

    Confirmed, tested against the snapshot build as requested.
    The ID is added to the anchor as suggested in option 2 in the bug report.
    Result is that footnote links are working.

    Thanks for fixing, much appreciated.

     
  • AndyHatton
    AndyHatton
    2012-12-13

    A fix for this issue has been added to the current codebase.
    Please test the fix with the latest snapshot from:

    http://docbook.sourceforge.net/snapshots/