File tree 3 files changed +11
-4
lines changed
src/renderer/html_handlebars
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -138,9 +138,11 @@ fn render_item(
138
138
139
139
in_heading = true ;
140
140
}
141
- Event :: End ( Tag :: Heading ( i, .. ) ) if i as u32 <= max_section_depth => {
141
+ Event :: End ( Tag :: Heading ( i, id , _classes ) ) if i as u32 <= max_section_depth => {
142
142
in_heading = false ;
143
- section_id = Some ( utils:: unique_id_from_content ( & heading, & mut id_counter) ) ;
143
+ section_id = id
144
+ . map ( |id| id. to_string ( ) )
145
+ . or_else ( || Some ( utils:: unique_id_from_content ( & heading, & mut id_counter) ) ) ;
144
146
breadcrumbs. push ( heading. clone ( ) ) ;
145
147
}
146
148
Event :: Start ( Tag :: FootnoteDefinition ( name) ) => {
Original file line number Diff line number Diff line change @@ -755,6 +755,7 @@ mod search {
755
755
let no_headers = get_doc_ref ( "first/no-headers.html" ) ;
756
756
let duplicate_headers_1 = get_doc_ref ( "first/duplicate-headers.html#header-text-1" ) ;
757
757
let conclusion = get_doc_ref ( "conclusion.html#conclusion" ) ;
758
+ let heading_attrs = get_doc_ref ( "first/heading-attributes.html#both" ) ;
758
759
759
760
let bodyidx = & index[ "index" ] [ "index" ] [ "body" ] [ "root" ] ;
760
761
let textidx = & bodyidx[ "t" ] [ "e" ] [ "x" ] [ "t" ] ;
@@ -786,6 +787,10 @@ mod search {
786
787
docs[ & no_headers] [ "body" ] ,
787
788
"Capybara capybara capybara. Capybara capybara capybara. ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex."
788
789
) ;
790
+ assert_eq ! (
791
+ docs[ & heading_attrs] [ "breadcrumbs" ] ,
792
+ "First Chapter » Heading Attributes » Heading with id and classes"
793
+ ) ;
789
794
}
790
795
791
796
// Setting this to `true` may cause issues with `cargo watch`,
Original file line number Diff line number Diff line change 23
23
" first/duplicate-headers.html#header-text" ,
24
24
" first/duplicate-headers.html#header-text-1" ,
25
25
" first/duplicate-headers.html#header-text-2" ,
26
- " first/heading-attributes.html#heading-attributes " ,
26
+ " first/heading-attributes.html#attrs " ,
27
27
" first/heading-attributes.html#heading-with-classes" ,
28
- " first/heading-attributes.html#heading-with-id-and-classes " ,
28
+ " first/heading-attributes.html#both " ,
29
29
" second.html#second-chapter" ,
30
30
" second/nested.html#testing-relative-links-for-the-print-page" ,
31
31
" second/nested.html#some-section" ,
You can’t perform that action at this time.
0 commit comments