mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
Rollup merge of #79097 - GuillaumeGomez:code-block-invalid-html-tag-lint, r=jyn514
Code block invalid html tag lint Fixes #79095 r? ``@jyn514``
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
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;
|
||||
@@ -196,14 +196,17 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
|
||||
|
||||
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,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,3 +87,24 @@ pub fn h() {}
|
||||
/// <!--
|
||||
//~^ ERROR Unclosed HTML comment
|
||||
pub fn i() {}
|
||||
|
||||
/// hello
|
||||
///
|
||||
/// ```
|
||||
/// uiapp.run(&env::args().collect::<Vec<_>>());
|
||||
/// ```
|
||||
pub fn j() {}
|
||||
|
||||
// Check that nested codeblocks are working as well
|
||||
/// hello
|
||||
///
|
||||
/// ``````markdown
|
||||
/// normal markdown
|
||||
///
|
||||
/// ```
|
||||
/// uiapp.run(&env::args().collect::<Vec<_>>());
|
||||
/// ```
|
||||
///
|
||||
/// <Vec<_> shouldn't warn!
|
||||
/// ``````
|
||||
pub fn k() {}
|
||||
|
||||
Reference in New Issue
Block a user