File tree 1 file changed +17
-3
lines changed
src/renderer/html_handlebars
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -779,22 +779,36 @@ fn make_data(
779
779
}
780
780
781
781
/// Goes through part of the rendered print page HTML,
782
- /// add path id prefix to all the elements id.
782
+ /// add path id prefix to all the elements id as well as footnote links .
783
783
fn build_print_element_id ( html : & str , path_id : & str ) -> String {
784
- let regex = Regex :: new ( r#"(<[^>]*?id=")([^"]+?)""# ) . unwrap ( ) ;
784
+ let all_id = Regex :: new ( r#"(<[^>]*?id=")([^"]+?)""# ) . unwrap ( ) ;
785
+ let footnote_id = Regex :: new (
786
+ r##"(<sup [^>]*?class="footnote-reference"[^>]*?>[^<]*?<a [^>]*?href="#)([^"]+?)""## ,
787
+ )
788
+ . unwrap ( ) ;
785
789
786
790
if path_id. is_empty ( ) {
787
791
return html. to_string ( ) ;
788
792
}
789
793
790
- regex
794
+ let temp_html = all_id
791
795
. replace_all ( html, |caps : & Captures < ' _ > | {
792
796
let mut fixed = String :: new ( ) ;
793
797
fixed. push_str ( & path_id) ;
794
798
fixed. push_str ( "-" ) ;
795
799
fixed. push_str ( & caps[ 2 ] ) ;
796
800
format ! ( "{}{}\" " , & caps[ 1 ] , fixed)
797
801
} )
802
+ . into_owned ( ) ;
803
+
804
+ footnote_id
805
+ . replace_all ( & temp_html, |caps : & Captures < ' _ > | {
806
+ let mut fixed = String :: new ( ) ;
807
+ fixed. push_str ( & path_id) ;
808
+ fixed. push_str ( "-" ) ;
809
+ fixed. push_str ( & caps[ 2 ] ) ;
810
+ format ! ( "{}{}\" " , & caps[ 1 ] , fixed)
811
+ } )
798
812
. into_owned ( )
799
813
}
800
814
You can’t perform that action at this time.
0 commit comments