diff --git a/src/mistune/plugins/footnotes.py b/src/mistune/plugins/footnotes.py index e426865..a41dc11 100644 --- a/src/mistune/plugins/footnotes.py +++ b/src/mistune/plugins/footnotes.py @@ -108,7 +108,11 @@ def render_footnotes(renderer: "BaseRenderer", text: str) -> str: def render_footnote_item(renderer: "BaseRenderer", text: str, key: str, index: int) -> str: i = str(index) back = '' - text = text.rstrip()[:-4] + back + "

" + text = text.rstrip() + if text.endswith("

"): + text = text[:-4] + back + "

" + else: + text = text + "\n" + back return '
  • ' + text + "
  • \n" diff --git a/tests/fixtures/footnotes.txt b/tests/fixtures/footnotes.txt index aa85d5c..55175e5 100644 --- a/tests/fixtures/footnotes.txt +++ b/tests/fixtures/footnotes.txt @@ -96,6 +96,8 @@ third ```````````````````````````````` +https://github.com/lepture/mistune/issues/378 + ```````````````````````````````` example This is a foo [^foo]. @@ -115,6 +117,8 @@ This is a bar [^bar]. ```````````````````````````````` +https://github.com/lepture/mistune/issues/378 + ```````````````````````````````` example This is body text, and a footnote.[^f] @@ -129,3 +133,22 @@ This is body text, and a footnote.[^f] ```````````````````````````````` + +https://github.com/lepture/mistune/issues/428 + +```````````````````````````````` example +paragraph [^fn] +[^fn]: *emph* + > aaa +. +

    paragraph 1

    +
    +
      +
    1. emph

      +
      +

      aaa

      +
      +
    2. +
    +
    +````````````````````````````````