1
Fork 0

Unify headings indent and remove useless anchor

This commit is contained in:
Guillaume Gomez 2022-02-09 14:43:44 +01:00
parent 1f0a96862a
commit 6aad08f13f
4 changed files with 12 additions and 33 deletions

View file

@ -565,7 +565,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
self.buf.push_back((Event::Html(format!("</a></h{}>", level).into()), 0..0)); self.buf.push_back((Event::Html(format!("</a></h{}>", level).into()), 0..0));
let start_tags = format!( let start_tags = format!(
"<h{level} id=\"{id}\" class=\"section-header\">\ "<h{level} id=\"{id}\">\
<a href=\"#{id}\">", <a href=\"#{id}\">",
id = id, id = id,
level = level level = level

View file

@ -161,23 +161,23 @@ fn test_header() {
t( t(
"# Foo bar", "# Foo bar",
"<h2 id=\"foo-bar\" class=\"section-header\"><a href=\"#foo-bar\">Foo bar</a></h2>", "<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>",
); );
t( t(
"## Foo-bar_baz qux", "## Foo-bar_baz qux",
"<h3 id=\"foo-bar_baz-qux\" class=\"section-header\">\ "<h3 id=\"foo-bar_baz-qux\">\
<a href=\"#foo-bar_baz-qux\">Foo-bar_baz qux</a></h3>", <a href=\"#foo-bar_baz-qux\">Foo-bar_baz qux</a></h3>",
); );
t( t(
"### **Foo** *bar* baz!?!& -_qux_-%", "### **Foo** *bar* baz!?!& -_qux_-%",
"<h4 id=\"foo-bar-baz--qux-\" class=\"section-header\">\ "<h4 id=\"foo-bar-baz--qux-\">\
<a href=\"#foo-bar-baz--qux-\"><strong>Foo</strong> \ <a href=\"#foo-bar-baz--qux-\"><strong>Foo</strong> \
<em>bar</em> baz!?!&amp; -<em>qux</em>-%</a>\ <em>bar</em> baz!?!&amp; -<em>qux</em>-%</a>\
</h4>", </h4>",
); );
t( t(
"#### **Foo?** & \\*bar?!* _`baz`_ ❤ #qux", "#### **Foo?** & \\*bar?!* _`baz`_ ❤ #qux",
"<h5 id=\"foo--bar--baz--qux\" class=\"section-header\">\ "<h5 id=\"foo--bar--baz--qux\">\
<a href=\"#foo--bar--baz--qux\"><strong>Foo?</strong> &amp; *bar?!* \ <a href=\"#foo--bar--baz--qux\"><strong>Foo?</strong> &amp; *bar?!* \
<em><code>baz</code></em> #qux</a>\ <em><code>baz</code></em> #qux</a>\
</h5>", </h5>",
@ -204,32 +204,32 @@ fn test_header_ids_multiple_blocks() {
t( t(
&mut map, &mut map,
"# Example", "# Example",
"<h2 id=\"example\" class=\"section-header\"><a href=\"#example\">Example</a></h2>", "<h2 id=\"example\"><a href=\"#example\">Example</a></h2>",
); );
t( t(
&mut map, &mut map,
"# Panics", "# Panics",
"<h2 id=\"panics\" class=\"section-header\"><a href=\"#panics\">Panics</a></h2>", "<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>",
); );
t( t(
&mut map, &mut map,
"# Example", "# Example",
"<h2 id=\"example-1\" class=\"section-header\"><a href=\"#example-1\">Example</a></h2>", "<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>",
); );
t( t(
&mut map, &mut map,
"# Search", "# Search",
"<h2 id=\"search-1\" class=\"section-header\"><a href=\"#search-1\">Search</a></h2>", "<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>",
); );
t( t(
&mut map, &mut map,
"# Example", "# Example",
"<h2 id=\"example-2\" class=\"section-header\"><a href=\"#example-2\">Example</a></h2>", "<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>",
); );
t( t(
&mut map, &mut map,
"# Panics", "# Panics",
"<h2 id=\"panics-1\" class=\"section-header\"><a href=\"#panics-1\">Panics</a></h2>", "<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>",
); );
} }

View file

@ -2567,7 +2567,7 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item) {
w, w,
"<div class=\"docblock scraped-example-list\">\ "<div class=\"docblock scraped-example-list\">\
<span></span>\ <span></span>\
<h5 id=\"{id}\" class=\"section-header\">\ <h5 id=\"{id}\">\
<a href=\"#{id}\">Examples found in repository</a>\ <a href=\"#{id}\">Examples found in repository</a>\
</h5>", </h5>",
id = id id = id

View file

@ -1141,16 +1141,6 @@ a.test-arrow {
a.test-arrow:hover{ a.test-arrow:hover{
text-decoration: none; text-decoration: none;
} }
.section-header:hover a:before {
position: absolute;
left: -25px;
padding-right: 10px; /* avoid gap that causes hover to disappear */
content: '\2002\00a7\2002';
}
.section-header:hover a {
text-decoration: none;
}
.code-attribute { .code-attribute {
font-weight: 300; font-weight: 300;
@ -1196,17 +1186,6 @@ h3.variant {
margin-top: 3px; margin-top: 3px;
} }
.top-doc .docblock > .section-header:first-child {
margin-left: 15px;
}
.top-doc .docblock > .section-header:first-child:hover > a:before {
left: -10px;
}
.docblock > .section-header:first-child {
margin-top: 0;
}
:target > code, :target > .code-header { :target > code, :target > .code-header {
opacity: 1; opacity: 1;
} }