Skip to content

Commit

Permalink
fix: multi-paragraph footnotes (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Aug 26, 2024
1 parent 5be3f61 commit 549844b
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ fn gen_footnote_reference(footnote_reference: &FootnoteReference, _: &mut Contex
fn gen_footnote_definition(footnote_definition: &FootnoteDefinition, context: &mut Context) -> PrintItems {
let mut items = PrintItems::new();
items.push_string(format!("[^{}]: ", footnote_definition.name.trim()));
items.extend(gen_nodes(&footnote_definition.children, context));
items.extend(with_indent_times(gen_nodes(&footnote_definition.children, context), 4));
items
}

Expand Down
117 changes: 117 additions & 0 deletions tests/specs/Issues/Issue0076.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
!! should format !!
Some paragraph with a footnote[^1].

[^1]: Footnotes, as well as endnotes, are strings of text placed at the bottom
of a page in a book or document or at the end of a chapter, volume, or the whole
text.

The footnote can provide an author's comments on the main text or
[citations](https://en.wikipedia.org/wiki/Citation) of a reference work in
support of the text.

[expect]
Some paragraph with a footnote[^1].

[^1]: Footnotes, as well as endnotes, are strings of text placed at the bottom
of a page in a book or document or at the end of a chapter, volume, or the whole
text.

The footnote can provide an author's comments on the main text or
[citations](https://en.wikipedia.org/wiki/Citation) of a reference work in
support of the text.

!! should keep footnote indented !!
# Example

[^1]: This is a footnote content.

Here is a simple footnote[^1].
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br> With some additional text after it[^@#$%]
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br> and without disrupting the
blocks[^bignote].
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>

[^bignote]:

The first paragraph of the definition.

Paragraph two of the definition.

> A blockquote with
> multiple lines.

~~~
a code block
~~~

| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |

A \`final\` paragraph before list.

- Item 1
- Item 2
- Subitem 1
- Subitem 2

[^@#$%]: A footnote on the label: "@#$%".

[expect]
# Example

[^1]: This is a footnote content.

Here is a simple footnote[^1].
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br> With some additional text after it[^@#$%]
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br> and without disrupting the
blocks[^bignote].
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>

[^bignote]: The first paragraph of the definition.

Paragraph two of the definition.

> A blockquote with
> multiple lines.

```
a code block
```

| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |

A \`final\` paragraph before list.

- Item 1
- Item 2
- Subitem 1
- Subitem 2

[^@#$%]: A footnote on the label: "@#$%".

0 comments on commit 549844b

Please sign in to comment.