Skip to content

Commit

Permalink
Filter more than 1 footnote in summary (#2017)
Browse files Browse the repository at this point in the history
If the summary contains more than 1 footnote, only the 1st is
removed, and so dangling links exists for all the others.
  • Loading branch information
mscherer authored and Keats committed Feb 16, 2023
1 parent 7000f78 commit da5c4c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/content/src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl Page {
self.summary = res
.summary_len
.map(|l| &res.body[0..l])
.map(|s| FOOTNOTES_RE.replace(s, "").into_owned());
.map(|s| FOOTNOTES_RE.replace_all(s, "").into_owned());
self.content = res.body;
self.toc = res.toc;
self.external_links = res.external_links;
Expand Down Expand Up @@ -515,13 +515,17 @@ Hello world
+++
This page use <sup>1.5</sup> and has footnotes, here's one. [^1]
Here's another. [^2]
<!-- more -->
And here's another. [^2]
And here's another. [^3]
[^1]: This is the first footnote.
[^2]: This is the second footnote."#
[^2]: This is the secund footnote.
[^3]: This is the third footnote."#
.to_string();
let res = Page::parse(Path::new("hello.md"), &content, &config, &PathBuf::new());
assert!(res.is_ok());
Expand All @@ -536,7 +540,7 @@ And here's another. [^2]
.unwrap();
assert_eq!(
page.summary,
Some("<p>This page use <sup>1.5</sup> and has footnotes, here\'s one. </p>\n".to_string())
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())
);
}

Expand Down

0 comments on commit da5c4c4

Please sign in to comment.