diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index db30836b43f..177fb1a9426 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -1166,6 +1166,7 @@ fn parse(
let allow_error_code_check = allow_error_code_check.as_bool();
let mut seen_rust_tags = false;
let mut seen_other_tags = false;
+ let mut seen_custom_tag = false;
let mut data = LangString::default();
let mut ignores = vec![];
@@ -1195,6 +1196,9 @@ fn parse(
data.rust = true;
seen_rust_tags = true;
}
+ LangStringToken::LangToken("custom") => {
+ seen_custom_tag = true;
+ }
LangStringToken::LangToken("test_harness") => {
data.test_harness = true;
seen_rust_tags = !seen_other_tags || seen_rust_tags;
@@ -1264,7 +1268,6 @@ fn parse(
data.unknown.push(x.to_owned());
}
LangStringToken::KeyValueAttribute(key, value) => {
- seen_other_tags = true;
if key == "class" {
data.added_classes.push(value.to_owned());
} else if let Some(extra) = extra {
@@ -1273,7 +1276,6 @@ fn parse(
}
}
LangStringToken::ClassAttribute(class) => {
- seen_other_tags = true;
data.added_classes.push(class.to_owned());
}
}
@@ -1284,7 +1286,7 @@ fn parse(
data.ignore = Ignore::Some(ignores);
}
- data.rust &= !seen_other_tags || seen_rust_tags;
+ data.rust &= !seen_custom_tag && (!seen_other_tags || seen_rust_tags);
data
}
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index 35b243d3d29..7d89cb0c4e6 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -64,6 +64,12 @@ fn t(lg: LangString) {
t(LangString { original: "{rust}".into(), rust: true, ..Default::default() });
t(LangString {
original: "{.rust}".into(),
+ rust: true,
+ added_classes: vec!["rust".into()],
+ ..Default::default()
+ });
+ t(LangString {
+ original: "custom,{.rust}".into(),
rust: false,
added_classes: vec!["rust".into()],
..Default::default()
@@ -154,12 +160,24 @@ fn t(lg: LangString) {
t(LangString {
original: "{class=test}".into(),
added_classes: vec!["test".into()],
+ rust: true,
+ ..Default::default()
+ });
+ t(LangString {
+ original: "custom,{class=test}".into(),
+ added_classes: vec!["test".into()],
rust: false,
..Default::default()
});
t(LangString {
original: "{.test}".into(),
added_classes: vec!["test".into()],
+ rust: true,
+ ..Default::default()
+ });
+ t(LangString {
+ original: "custom,{.test}".into(),
+ added_classes: vec!["test".into()],
rust: false,
..Default::default()
});
@@ -172,12 +190,24 @@ fn t(lg: LangString) {
t(LangString {
original: "{class=test:with:colon .test1}".into(),
added_classes: vec!["test:with:colon".into(), "test1".into()],
+ rust: true,
+ ..Default::default()
+ });
+ t(LangString {
+ original: "custom,{class=test:with:colon .test1}".into(),
+ added_classes: vec!["test:with:colon".into(), "test1".into()],
rust: false,
..Default::default()
});
t(LangString {
original: "{class=first,class=second}".into(),
added_classes: vec!["first".into(), "second".into()],
+ rust: true,
+ ..Default::default()
+ });
+ t(LangString {
+ original: "custom,{class=first,class=second}".into(),
+ added_classes: vec!["first".into(), "second".into()],
rust: false,
..Default::default()
});
@@ -206,6 +236,12 @@ fn t(lg: LangString) {
t(LangString {
original: r#"{class="first"}"#.into(),
added_classes: vec!["first".into()],
+ rust: true,
+ ..Default::default()
+ });
+ t(LangString {
+ original: r#"custom,{class="first"}"#.into(),
+ added_classes: vec!["first".into()],
rust: false,
..Default::default()
});