@@ -978,16 +978,16 @@ var util = (function () {
978978 }
979979 }
980980
981- const replaceSemanticInlineStylesWithTags = function ( element , removeLeftoverStyles = false ) {
981+ const replaceSemanticInlineStylesWithTags = function ( element , removeLeftoverStyles = false ) {
982982 if ( element . hasAttribute ( "style" ) ) {
983983 let styleText = element . getAttribute ( "style" ) ;
984984
985985 // Map of style patterns to their semantic HTML equivalents
986986 const styleToTag = [
987- { regex : / f o n t - s t y l e \s * : \s * ( i t a l i c | o b l i q u e ) \s * ; / g, tag : "i" } ,
988- { regex : / f o n t - w e i g h t \s * : \s * ( b o l d | [ 7 - 9 ] \d \d ) \s * ; / g, tag : "b" } ,
989- { regex : / t e x t - d e c o r a t i o n \s * : \s * u n d e r l i n e \s * ; / g, tag : "u" } ,
990- { regex : / t e x t - d e c o r a t i o n \s * : \s * l i n e - t h r o u g h \s * ; / g, tag : "s" }
987+ { regex : / f o n t - s t y l e \s * : \s * ( i t a l i c | o b l i q u e ) \s * ; ? / g, tag : "i" } ,
988+ { regex : / f o n t - w e i g h t \s * : \s * ( b o l d | [ 7 - 9 ] \d \d ) \s * ; ? / g, tag : "b" } ,
989+ { regex : / t e x t - d e c o r a t i o n \s * : \s * u n d e r l i n e \s * ; ? / g, tag : "u" } ,
990+ { regex : / t e x t - d e c o r a t i o n \s * : \s * l i n e - t h r o u g h \s * ; ? / g, tag : "s" }
991991 ] ;
992992
993993 // Apply semantic tags and remove corresponding styles
@@ -1001,7 +1001,7 @@ var util = (function () {
10011001 }
10021002
10031003 // Remove non-semantic font-weight
1004- styleText = styleText . replace ( / f o n t - w e i g h t \s * : \s * ( n o r m a l | [ 1 - 4 ] \d \d ) \s * ; / g, "" ) ;
1004+ styleText = styleText . replace ( / f o n t - w e i g h t \s * : \s * ( n o r m a l | [ 1 - 4 ] \d \d ) \s * ; ? / g, "" ) ;
10051005 styleText = styleText . trim ( ) ;
10061006
10071007 if ( styleText && ( ! removeLeftoverStyles || / i t a l i c | b o l d | f o n t - w e i g h t | u n d e r l i n e | l i n e - t h r o u g h / . test ( styleText ) ) ) {
@@ -1137,43 +1137,3 @@ var util = (function () {
11371137 wrapInnerContentInTag : wrapInnerContentInTag
11381138 } ;
11391139} ) ( ) ;
1140-
1141- class FootnoteExtractor {
1142- scriptElementsToFootnotes ( dom ) {
1143- let indexedFootnotes = new Map ( ) ;
1144- [ ...dom . querySelectorAll ( "script" ) ]
1145- . map ( s => s . textContent )
1146- . filter ( s => s . includes ( "toolTips('.classtoolTips" ) )
1147- . forEach ( s => indexedFootnotes . set ( this . getId ( s ) , this . extractFootnoteText ( s ) ) ) ;
1148-
1149- return this . getIdsUsedOnPage ( dom )
1150- . map ( id => this . makeSpan ( indexedFootnotes . get ( id ) , dom ) ) ;
1151- }
1152-
1153- getIdsUsedOnPage ( dom ) {
1154- let extractId = ( span ) => [ ...span . classList ]
1155- . filter ( s => s . startsWith ( "class" ) ) [ 0 ] ;
1156-
1157- return [ ...dom . querySelectorAll ( "span.tooltipsall" ) ]
1158- . map ( extractId ) ;
1159- }
1160-
1161- getId ( script ) {
1162- return this . extractSubstring ( script , "toolTips('." , "," ) . replace ( "'" , "" ) ;
1163- }
1164-
1165- makeSpan ( content , dom ) {
1166- let span = dom . createElement ( "span" ) ;
1167- span . textContent = content ;
1168- return span ;
1169- }
1170-
1171- extractFootnoteText ( content ) {
1172- return this . extractSubstring ( content , "tt_store_content = \"" , "\"; toolTips('" ) ;
1173- }
1174-
1175- extractSubstring ( content , startTag , endTag ) {
1176- content = content . substring ( content . indexOf ( startTag ) + startTag . length ) ;
1177- return content . substring ( 0 , content . indexOf ( endTag ) ) ;
1178- }
1179- }
0 commit comments