File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/renderer/html_handlebars Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -779,22 +779,36 @@ fn make_data(
779779}
780780
781781/// 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 .
783783fn 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 ( ) ;
785789
786790 if path_id. is_empty ( ) {
787791 return html. to_string ( ) ;
788792 }
789793
790- regex
794+ let temp_html = all_id
791795 . replace_all ( html, |caps : & Captures < ' _ > | {
792796 let mut fixed = String :: new ( ) ;
793797 fixed. push_str ( & path_id) ;
794798 fixed. push_str ( "-" ) ;
795799 fixed. push_str ( & caps[ 2 ] ) ;
796800 format ! ( "{}{}\" " , & caps[ 1 ] , fixed)
797801 } )
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+ } )
798812 . into_owned ( )
799813}
800814
You can’t perform that action at this time.
0 commit comments