File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/renderer/html_handlebars Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -813,7 +813,9 @@ fn build_header_links(html: &str) -> String {
813
813
814
814
insert_link_into_header (
815
815
level,
816
- caps. get ( 2 ) . map ( |x| x. as_str ( ) ) . unwrap_or ( & caps[ 4 ] ) ,
816
+ & caps[ 4 ] ,
817
+ caps. get ( 2 ) . map ( |x| x. as_str ( ) . to_string ( ) ) ,
818
+ caps. get ( 3 ) . map ( |x| x. as_str ( ) . to_string ( ) ) ,
817
819
& mut id_counter,
818
820
)
819
821
} )
@@ -825,15 +827,19 @@ fn build_header_links(html: &str) -> String {
825
827
fn insert_link_into_header (
826
828
level : usize ,
827
829
content : & str ,
830
+ id : Option < String > ,
831
+ classes : Option < String > ,
828
832
id_counter : & mut HashMap < String , usize > ,
829
833
) -> String {
830
- let id = utils:: unique_id_from_content ( content, id_counter) ;
834
+ let id = id. unwrap_or_else ( || utils:: unique_id_from_content ( content, id_counter) ) ;
835
+ let classes = classes. unwrap_or ( "" . to_string ( ) ) ;
831
836
832
837
format ! (
833
- r##"<h{level} id="{id}"><a class="header" href="#{id}">{text}</a></h{level}>"## ,
838
+ r##"<h{level} id="{id}" classes="{classes}" ><a class="header" href="#{id}">{text}</a></h{level}>"## ,
834
839
level = level,
835
840
id = id,
836
- text = content
841
+ text = content,
842
+ classes = classes
837
843
)
838
844
}
839
845
You can’t perform that action at this time.
0 commit comments