From 017596e61eea15c6890f0fcae44241b36892d1b3 Mon Sep 17 00:00:00 2001 From: brief <91160+brief@users.noreply.github.com> Date: Sun, 28 Mar 2021 08:39:43 -0700 Subject: [PATCH] Keep backlinks with footnote text Inserts a non-breaking space before backlinks to prevent them from being separated from footnote text. --- extension/_test/footnote.txt | 10 +++++----- extension/footnote.go | 2 +- extension/footnote_test.go | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/extension/_test/footnote.txt b/extension/_test/footnote.txt index 0270c62..48e3a58 100644 --- a/extension/_test/footnote.txt +++ b/extension/_test/footnote.txt @@ -12,7 +12,7 @@ That's some text with a footnote.[^1]
  1. And that's the footnote.

    -

    That's the second paragraph. ↩︎

    +

    That's the second paragraph. ↩︎

@@ -37,13 +37,13 @@ This[^3] is[^1] text with footnotes[^2].
  1. -

    Footnote three ↩︎

    +

    Footnote three ↩︎

  2. -

    Footnote one ↩︎

    +

    Footnote one ↩︎

  3. -

    Footnote two ↩︎

    +

    Footnote two ↩︎

@@ -61,7 +61,7 @@ test![^1]
  1. -

    footnote ↩︎

    +

    footnote ↩︎

diff --git a/extension/footnote.go b/extension/footnote.go index 62f5ee6..d4552e5 100644 --- a/extension/footnote.go +++ b/extension/footnote.go @@ -539,7 +539,7 @@ func (r *FootnoteHTMLRenderer) renderFootnoteBacklink(w util.BufWriter, source [ if entering { n := node.(*ast.FootnoteBacklink) is := strconv.Itoa(n.Index) - _, _ = w.WriteString(`
  1. -

    And that's the footnote. ^

    +

    And that's the footnote. ^

  2. -

    Another footnote. ^

    +

    Another footnote. ^

@@ -129,10 +129,10 @@ Another one.[^2]
  1. -

    And that's the footnote. ^

    +

    And that's the footnote. ^

  2. -

    Another footnote. ^

    +

    Another footnote. ^