Skip to content

Commit

Permalink
Don't warn about invalid HTML tags in code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 16, 2020
1 parent 603ab5b commit 7986bb8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librustdoc/passes/html_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::html::markdown::opts;
use core::ops::Range;
use pulldown_cmark::{Event, Parser};
use pulldown_cmark::{Event, Parser, Tag};
use rustc_session::lint;
use std::iter::Peekable;
use std::str::CharIndices;
Expand Down Expand Up @@ -196,14 +196,17 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {

let mut tags = Vec::new();
let mut is_in_comment = None;
let mut in_code_block = false;

let p = Parser::new_ext(&dox, opts()).into_offset_iter();

for (event, range) in p {
match event {
Event::Html(text) | Event::Text(text) => {
Event::Start(Tag::CodeBlock(_)) => in_code_block = true,
Event::Html(text) | Event::Text(text) if !in_code_block => {
extract_tags(&mut tags, &text, range, &mut is_in_comment, &report_diag)
}
Event::End(Tag::CodeBlock(_)) => in_code_block = false,
_ => {}
}
}
Expand Down

0 comments on commit 7986bb8

Please sign in to comment.