Skip to content

Commit f423ef5

Browse files
Don't render <table> in items' summary
1 parent 05f2326 commit f423ef5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/librustdoc/html/markdown.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) fn opts() -> Options {
5757

5858
/// A subset of [`opts()`] used for rendering summaries.
5959
pub(crate) fn summary_opts() -> Options {
60-
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_SMART_PUNCTUATION
60+
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_SMART_PUNCTUATION | Options::ENABLE_TABLES
6161
}
6262

6363
/// When `to_string` is called, this struct will emit the HTML corresponding to
@@ -522,6 +522,10 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
522522
)
523523
}
524524

525+
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
526+
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
527+
}
528+
525529
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
526530
type Item = Event<'a>;
527531

@@ -535,14 +539,17 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
535539
if let Some(event) = self.inner.next() {
536540
let mut is_start = true;
537541
let is_allowed_tag = match event {
538-
Event::Start(Tag::CodeBlock(_)) | Event::End(Tag::CodeBlock(_)) => {
539-
return None;
540-
}
541542
Event::Start(ref c) => {
543+
if is_forbidden_tag(c) {
544+
return None;
545+
}
542546
self.depth += 1;
543547
check_if_allowed_tag(c)
544548
}
545549
Event::End(ref c) => {
550+
if is_forbidden_tag(c) {
551+
return None;
552+
}
546553
self.depth -= 1;
547554
is_start = false;
548555
check_if_allowed_tag(c)

0 commit comments

Comments
 (0)