Skip to content

Commit

Permalink
Properly close lists before opening a footnote
Browse files Browse the repository at this point in the history
Closes GitHub issue #413
  • Loading branch information
marcusklaas committed Nov 18, 2019
1 parent 7777d0e commit ac3b283
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
22 changes: 22 additions & 0 deletions specs/regression.txt
Expand Up @@ -708,3 +708,25 @@ ISSUE 399
the size of <code>usize</code> and have the same alignment.</p>
</blockquote>
````````````````````````````````

ISSUE 413

```````````````````````````````` example
Lorem ipsum.[^a]

An unordered list before the footnotes:
* Ipsum
* Lorem

[^a]: Cool.
.
<p>Lorem ipsum.<sup class="footnote-reference"><a href="#a">1</a></sup></p>
<p>An unordered list before the footnotes:</p>
<ul>
<li>Ipsum</li>
<li>Lorem</li>
</ul>
<div class="footnote-definition" id="a"><sup class="footnote-definition-label">1</sup>
<p>Cool.</p>
</div>
````````````````````````````````
1 change: 1 addition & 0 deletions src/parse.rs
Expand Up @@ -1226,6 +1226,7 @@ impl<'a> FirstPass<'a> {
return None;
}
i += 1;
self.finish_list(start);
self.tree.append(Item {
start,
end: 0, // will get set later
Expand Down
27 changes: 25 additions & 2 deletions tests/suite/regression.rs
Expand Up @@ -405,8 +405,7 @@ fn regression_test_30() {
some text
"##;
let expected =
r##"<table><thead><tr><th>Markdown </th><th> Less </th><th> Pretty</th></tr></thead><tbody>
let expected = r##"<table><thead><tr><th>Markdown </th><th> Less </th><th> Pretty</th></tr></thead><tbody>
</tbody></table>
<p>some text</p>
"##;
Expand Down Expand Up @@ -805,3 +804,27 @@ fn regression_test_59() {

test_markdown_html(original, expected);
}

#[test]
fn regression_test_60() {
let original = r##"Lorem ipsum.[^a]
An unordered list before the footnotes:
* Ipsum
* Lorem
[^a]: Cool.
"##;
let expected = r##"<p>Lorem ipsum.<sup class="footnote-reference"><a href="#a">1</a></sup></p>
<p>An unordered list before the footnotes:</p>
<ul>
<li>Ipsum</li>
<li>Lorem</li>
</ul>
<div class="footnote-definition" id="a"><sup class="footnote-definition-label">1</sup>
<p>Cool.</p>
</div>
"##;

test_markdown_html(original, expected);
}
9 changes: 3 additions & 6 deletions tests/suite/spec.rs
Expand Up @@ -6889,8 +6889,7 @@ fn spec_test_511() {
fn spec_test_512() {
let original = r##"[link *foo **bar** `#`*](/uri)
"##;
let expected =
r##"<p><a href="/uri">link <em>foo <strong>bar</strong> <code>#</code></em></a></p>
let expected = r##"<p><a href="/uri">link <em>foo <strong>bar</strong> <code>#</code></em></a></p>
"##;

test_markdown_html(original, expected);
Expand Down Expand Up @@ -7038,8 +7037,7 @@ fn spec_test_526() {
[ref]: /uri
"##;
let expected =
r##"<p><a href="/uri">link <em>foo <strong>bar</strong> <code>#</code></em></a></p>
let expected = r##"<p><a href="/uri">link <em>foo <strong>bar</strong> <code>#</code></em></a></p>
"##;

test_markdown_html(original, expected);
Expand Down Expand Up @@ -7923,8 +7921,7 @@ fn spec_test_600() {
fn spec_test_601() {
let original = r##"<foo+special@Bar.baz-bar0.com>
"##;
let expected =
r##"<p><a href="mailto:foo+special@Bar.baz-bar0.com">foo+special@Bar.baz-bar0.com</a></p>
let expected = r##"<p><a href="mailto:foo+special@Bar.baz-bar0.com">foo+special@Bar.baz-bar0.com</a></p>
"##;

test_markdown_html(original, expected);
Expand Down
3 changes: 1 addition & 2 deletions tests/suite/table.rs
Expand Up @@ -140,8 +140,7 @@ fn table_test_8() {

#[test]
fn table_test_9() {
let original =
r##"| Target | std |rustc|cargo| notes |
let original = r##"| Target | std |rustc|cargo| notes |
|-------------------------------|-----|-----|-----|----------------------------|
| `x86_64-unknown-linux-musl` | ✓ | | | 64-bit Linux with MUSL |
| `arm-linux-androideabi` | ✓ | | | ARM Android |
Expand Down

0 comments on commit ac3b283

Please sign in to comment.