Rollup merge of #99873 - notriddle:notriddle/invalid-html-tags-webcomponents, r=GuillaumeGomezp
rustdoc: align invalid-html-tags lint with commonmark spec
This commit is contained in:
commit
852bf84c7b
3 changed files with 28 additions and 2 deletions
|
@ -94,6 +94,14 @@ fn extract_path_backwards(text: &str, end_pos: usize) -> Option<usize> {
|
||||||
if current_pos == end_pos { None } else { Some(current_pos) }
|
if current_pos == end_pos { None } else { Some(current_pos) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_valid_for_html_tag_name(c: char, is_empty: bool) -> bool {
|
||||||
|
// https://spec.commonmark.org/0.30/#raw-html
|
||||||
|
//
|
||||||
|
// > A tag name consists of an ASCII letter followed by zero or more ASCII letters, digits, or
|
||||||
|
// > hyphens (-).
|
||||||
|
c.is_ascii_alphabetic() || !is_empty && (c == '-' || c.is_ascii_digit())
|
||||||
|
}
|
||||||
|
|
||||||
fn extract_html_tag(
|
fn extract_html_tag(
|
||||||
tags: &mut Vec<(String, Range<usize>)>,
|
tags: &mut Vec<(String, Range<usize>)>,
|
||||||
text: &str,
|
text: &str,
|
||||||
|
@ -117,7 +125,7 @@ fn extract_html_tag(
|
||||||
// Checking if this is a closing tag (like `</a>` for `<a>`).
|
// Checking if this is a closing tag (like `</a>` for `<a>`).
|
||||||
if c == '/' && tag_name.is_empty() {
|
if c == '/' && tag_name.is_empty() {
|
||||||
is_closing = true;
|
is_closing = true;
|
||||||
} else if c.is_ascii_alphanumeric() {
|
} else if is_valid_for_html_tag_name(c, tag_name.is_empty()) {
|
||||||
tag_name.push(c);
|
tag_name.push(c);
|
||||||
} else {
|
} else {
|
||||||
if !tag_name.is_empty() {
|
if !tag_name.is_empty() {
|
||||||
|
|
|
@ -108,3 +108,9 @@ pub fn j() {}
|
||||||
/// <Vec<_> shouldn't warn!
|
/// <Vec<_> shouldn't warn!
|
||||||
/// ``````
|
/// ``````
|
||||||
pub fn k() {}
|
pub fn k() {}
|
||||||
|
|
||||||
|
/// Web Components style <dashed-tags>
|
||||||
|
//~^ ERROR unclosed HTML tag `dashed-tags`
|
||||||
|
/// Web Components style </unopened-tag>
|
||||||
|
//~^ ERROR unopened HTML tag `unopened-tag`
|
||||||
|
pub fn m() {}
|
||||||
|
|
|
@ -82,5 +82,17 @@ error: Unclosed HTML comment
|
||||||
LL | /// <!--
|
LL | /// <!--
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 13 previous errors
|
error: unopened HTML tag `unopened-tag`
|
||||||
|
--> $DIR/invalid-html-tags.rs:114:26
|
||||||
|
|
|
||||||
|
LL | /// Web Components style </unopened-tag>
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: unclosed HTML tag `dashed-tags`
|
||||||
|
--> $DIR/invalid-html-tags.rs:112:26
|
||||||
|
|
|
||||||
|
LL | /// Web Components style <dashed-tags>
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 15 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue