rst2html5 places <span> tags containing additional IDs for a section incorrectly (after the closing </section> tag instead of right at the beginning of the <section>). Also, rst2html5 creates unnecessary empty <span> tags after inline internal references. This patch fixes both issues.
To reproduce the issues, try filtering the following document through an unpatched rst2html5:
.. _foo:
First section
-------------
Second section
--------------
Third section
-------------
`This link`_ should lead back to the first section but leads to the second
section instead using ``rst2html5``. It works as expected using ``rst2html``.
.. _This link: foo_
rst2html5 produces the following HTML output (irrelevant parts omitted):
<span class="target"></span>
<section id="first-section">
<header><h2>First section</h2></header>
</section>
<span id="foo"></span>
<section id="second-section">
<header><h2>Second section</h2></header>
</section>
<section id="third-section">
<header><h2>Third section</h2></header>
<p>
<a class="reference internal" href="#foo">This link</a> should lead back to the first section but leads to the second section instead using <code>rst2html5</code>. It works as expected using <code>rst2html</code>.
</p>
<span class="target" id="this-link"></span>
</section>
Note the misplaced <span id="foo"> which appears before the second section and not before the first one. Also note the extra <span class="target"> tags.
After patching rst2html5 according to this pull request, the following (correct) output is produced:
<section id="first-section">
<span id="foo"></span>
<header><h2>First section</h2></header>
</section>
<section id="second-section">
<header><h2>Second section</h2></header>
</section>
<section id="third-section">
<header><h2>Third section</h2></header>
<p>
<a class="reference internal" href="#foo">This link</a> should lead back to the first section but leads to the second section instead using <code>rst2html5</code>. It works as expected using <code>rst2html</code>.
</p>
</section>
rst2html5
places<span>
tags containing additional IDs for a section incorrectly (after the closing</section>
tag instead of right at the beginning of the<section>
). Also,rst2html5
creates unnecessary empty<span>
tags after inline internal references. This patch fixes both issues.To reproduce the issues, try filtering the following document through an unpatched
rst2html5
:rst2html5
produces the following HTML output (irrelevant parts omitted):Note the misplaced
<span id="foo">
which appears before the second section and not before the first one. Also note the extra<span class="target">
tags.After patching
rst2html5
according to this pull request, the following (correct) output is produced: