mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Don't generate ident elements as DOM nodes
This commit is contained in:
parent
68f327bcc1
commit
33df8a9655
@ -164,7 +164,8 @@ fn write_pending_elems(
|
||||
/// * If two `Class` have the same variant, then they can be merged.
|
||||
/// * If the other `Class` is unclassified and only contains white characters (backline,
|
||||
/// whitespace, etc), it can be merged.
|
||||
/// * If `Class` is `Ident`, then it can be merged with all unclassified elements.
|
||||
/// * `Class::Ident` is considered the same as unclassified (because it doesn't have an associated
|
||||
/// CSS class).
|
||||
fn can_merge(class1: Option<Class>, class2: Option<Class>, text: &str) -> bool {
|
||||
match (class1, class2) {
|
||||
(Some(c1), Some(c2)) => c1.is_equal_to(c2),
|
||||
@ -264,7 +265,7 @@ enum Class {
|
||||
DocComment,
|
||||
Attribute,
|
||||
KeyWord,
|
||||
// Keywords that do pointer/reference stuff.
|
||||
/// Keywords that do pointer/reference stuff.
|
||||
RefKeyWord,
|
||||
Self_(Span),
|
||||
Macro(Span),
|
||||
@ -272,6 +273,7 @@ enum Class {
|
||||
String,
|
||||
Number,
|
||||
Bool,
|
||||
/// `Ident` isn't rendered in the HTML but we still need it for the `Span` it contains.
|
||||
Ident(Span),
|
||||
Lifetime,
|
||||
PreludeTy,
|
||||
@ -320,7 +322,7 @@ impl Class {
|
||||
Class::String => "string",
|
||||
Class::Number => "number",
|
||||
Class::Bool => "bool-val",
|
||||
Class::Ident(_) => "ident",
|
||||
Class::Ident(_) => "",
|
||||
Class::Lifetime => "lifetime",
|
||||
Class::PreludeTy => "prelude-ty",
|
||||
Class::PreludeVal => "prelude-val",
|
||||
@ -920,7 +922,7 @@ fn string_without_closing_tag<T: Display>(
|
||||
path
|
||||
});
|
||||
}
|
||||
// We don't want to generate links on empty text.
|
||||
|
||||
if let Some(href_context) = href_context {
|
||||
if let Some(href) =
|
||||
href_context.context.shared.span_correspondance_map.get(&def_span).and_then(|href| {
|
||||
@ -954,7 +956,12 @@ fn string_without_closing_tag<T: Display>(
|
||||
// again.
|
||||
write!(out, "<a href=\"{}\">{}", href, text_s);
|
||||
} else {
|
||||
write!(out, "<a class=\"{}\" href=\"{}\">{}", klass.as_html(), href, text_s);
|
||||
let klass_s = klass.as_html();
|
||||
if klass_s.is_empty() {
|
||||
write!(out, "<a href=\"{}\">{}", href, text_s);
|
||||
} else {
|
||||
write!(out, "<a class=\"{}\" href=\"{}\">{}", klass_s, href, text_s);
|
||||
}
|
||||
}
|
||||
return Some("</a>");
|
||||
}
|
||||
@ -963,8 +970,14 @@ fn string_without_closing_tag<T: Display>(
|
||||
write!(out, "{}", text_s);
|
||||
return None;
|
||||
}
|
||||
write!(out, "<span class=\"{}\">{}", klass.as_html(), text_s);
|
||||
Some("</span>")
|
||||
let klass_s = klass.as_html();
|
||||
if klass_s.is_empty() {
|
||||
write!(out, "{}", text_s);
|
||||
Some("")
|
||||
} else {
|
||||
write!(out, "<span class=\"{}\">{}", klass_s, text_s);
|
||||
Some("</span>")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -250,9 +250,6 @@ pre.rust .self {
|
||||
pre.rust .attribute {
|
||||
color: #e6e1cf;
|
||||
}
|
||||
pre.rust .attribute .ident {
|
||||
color: #e6e1cf;
|
||||
}
|
||||
|
||||
.example-wrap > pre.line-number {
|
||||
color: #5c67736e;
|
||||
@ -398,8 +395,7 @@ pre.rust .comment {}
|
||||
.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,
|
||||
.content .fnname {}
|
||||
pre.rust .kw {}
|
||||
pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,
|
||||
pre.rust .attribute .ident {}
|
||||
pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute {}
|
||||
.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype {}
|
||||
pre.rust .doccomment {}
|
||||
.stab.deprecated {}
|
||||
|
@ -202,7 +202,7 @@ pre.rust .kw { color: #ab8ac1; }
|
||||
pre.rust .kw-2, pre.rust .prelude-ty { color: #769acb; }
|
||||
pre.rust .number, pre.rust .string { color: #83a300; }
|
||||
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
|
||||
pre.rust .attribute, pre.rust .attribute .ident { color: #ee6868; }
|
||||
pre.rust .attribute { color: #ee6868; }
|
||||
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
|
||||
pre.rust .lifetime { color: #d97f26; }
|
||||
pre.rust .question-mark {
|
||||
|
@ -184,7 +184,7 @@ pre.rust .kw { color: #8959A8; }
|
||||
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }
|
||||
pre.rust .number, pre.rust .string { color: #718C00; }
|
||||
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
|
||||
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
|
||||
pre.rust .attribute { color: #C82829; }
|
||||
pre.rust .comment { color: #8E908C; }
|
||||
pre.rust .doccomment { color: #4D4D4C; }
|
||||
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
|
||||
|
Loading…
Reference in New Issue
Block a user