Keep footnote backlinks with text

This inserts a non-breaking space before backlinks to prevent them from being separated from footnote text.

Results in the following when text wraps:

```
1. Roses are red, violets are
blue ↩
```

Instead of this:

```
1. Roses are red, violets are blue
↩
```
This commit is contained in:
Brief 2020-08-12 18:05:37 -07:00
parent 91e5269fb0
commit 40a7621c19
2 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@ That's some text with a footnote.[^1]
<ol> <ol>
<li id="fn:1" role="doc-endnote"> <li id="fn:1" role="doc-endnote">
<p>And that's the footnote.</p> <p>And that's the footnote.</p>
<p>That's the second paragraph. <a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p> <p>That's the second paragraph.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li> </li>
</ol> </ol>
</section> </section>
@ -37,13 +37,13 @@ This[^3] is[^1] text with footnotes[^2].
<hr> <hr>
<ol> <ol>
<li id="fn:1" role="doc-endnote"> <li id="fn:1" role="doc-endnote">
<p>Footnote three <a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p> <p>Footnote three&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li> </li>
<li id="fn:2" role="doc-endnote"> <li id="fn:2" role="doc-endnote">
<p>Footnote one <a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p> <p>Footnote one&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li> </li>
<li id="fn:3" role="doc-endnote"> <li id="fn:3" role="doc-endnote">
<p>Footnote two <a href="#fnref:3" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p> <p>Footnote two&#160;<a href="#fnref:3" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li> </li>
</ol> </ol>
</section> </section>
@ -61,7 +61,7 @@ test![^1]
<hr> <hr>
<ol> <ol>
<li id="fn:1" role="doc-endnote"> <li id="fn:1" role="doc-endnote">
<p>footnote <a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p> <p>footnote&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li> </li>
</ol> </ol>
</section> </section>

View file

@ -258,7 +258,7 @@ func (r *FootnoteHTMLRenderer) renderFootnoteBackLink(w util.BufWriter, source [
if entering { if entering {
n := node.(*ast.FootnoteBackLink) n := node.(*ast.FootnoteBackLink)
is := strconv.Itoa(n.Index) is := strconv.Itoa(n.Index)
_, _ = w.WriteString(` <a href="#fnref:`) _, _ = w.WriteString(`&#160;<a href="#fnref:`)
_, _ = w.WriteString(is) _, _ = w.WriteString(is)
_, _ = w.WriteString(`" class="footnote-backref" role="doc-backlink">`) _, _ = w.WriteString(`" class="footnote-backref" role="doc-backlink">`)
_, _ = w.WriteString("&#x21a9;&#xfe0e;") _, _ = w.WriteString("&#x21a9;&#xfe0e;")