Skip to content

Commit da5c4c4

Browse files
mschererKeats
authored andcommitted
Filter more than 1 footnote in summary (#2017)
If the summary contains more than 1 footnote, only the 1st is removed, and so dangling links exists for all the others.
1 parent 7000f78 commit da5c4c4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

components/content/src/page.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl Page {
229229
self.summary = res
230230
.summary_len
231231
.map(|l| &res.body[0..l])
232-
.map(|s| FOOTNOTES_RE.replace(s, "").into_owned());
232+
.map(|s| FOOTNOTES_RE.replace_all(s, "").into_owned());
233233
self.content = res.body;
234234
self.toc = res.toc;
235235
self.external_links = res.external_links;
@@ -515,13 +515,17 @@ Hello world
515515
+++
516516
This page use <sup>1.5</sup> and has footnotes, here's one. [^1]
517517
518+
Here's another. [^2]
519+
518520
<!-- more -->
519521
520-
And here's another. [^2]
522+
And here's another. [^3]
521523
522524
[^1]: This is the first footnote.
523525
524-
[^2]: This is the second footnote."#
526+
[^2]: This is the secund footnote.
527+
528+
[^3]: This is the third footnote."#
525529
.to_string();
526530
let res = Page::parse(Path::new("hello.md"), &content, &config, &PathBuf::new());
527531
assert!(res.is_ok());
@@ -536,7 +540,7 @@ And here's another. [^2]
536540
.unwrap();
537541
assert_eq!(
538542
page.summary,
539-
Some("<p>This page use <sup>1.5</sup> and has footnotes, here\'s one. </p>\n".to_string())
543+
Some("<p>This page use <sup>1.5</sup> and has footnotes, here\'s one. </p>\n<p>Here's another. </p>\n".to_string())
540544
);
541545
}
542546

0 commit comments

Comments
 (0)