Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,15 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
}

fn is_forbidden_tag(t: &Tag<'_>) -> bool {
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
matches!(
t,
Tag::CodeBlock(_)
| Tag::Table(_)
| Tag::TableHead
| Tag::TableRow
| Tag::TableCell
| Tag::FootnoteDefinition(_)
)
}

impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
Expand Down Expand Up @@ -589,6 +597,10 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
is_start = false;
check_if_allowed_tag(c)
}
Event::FootnoteReference(_) => {
self.skipped_tags += 1;
false
}
_ => true,
};
if !is_allowed_tag {
Expand Down
17 changes: 17 additions & 0 deletions tests/rustdoc/footnote-in-summary.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This test ensures that no footnote reference is generated inside
// summary doc.

#![crate_name = "foo"]

// @has 'foo/index.html'
// @has - '//*[@class="desc docblock-short"]' 'hello bla'
// @!has - '//*[@class="desc docblock-short"]/sup' '1'

// @has 'foo/struct.S.html'
// @has - '//*[@class="docblock"]//sup' '1'
// @has - '//*[@class="docblock"]' 'hello 1 bla'

/// hello [^foot] bla
///
/// [^foot]: blabla
pub struct S;