@@ -1271,21 +1271,18 @@ function Highlighter(options = hhDefaultOptions) {
12711271 for ( const paragraph of paragraphs ) {
12721272 const paragraphRect = paragraph . getBoundingClientRect ( ) ;
12731273 const computedParagraphStyle = window . getComputedStyle ( paragraph ) ;
1274- const paragraphLineHeight = parseInt ( ( computedParagraphStyle . lineHeight === 'normal' ? computedParagraphStyle . fontSize : computedParagraphStyle . lineHeight ) . replace ( 'px' , '' ) ) ;
12751274 const paragraphTopPadding = parseInt ( computedParagraphStyle . getPropertyValue ( 'padding-top' ) . replace ( 'px' , '' ) ) ;
12761275
12771276 // Get line positions (bottom edge of each line)
12781277 let linePositions = new Set ( ) ;
12791278 let lineWalker = document . createTreeWalker ( paragraph , NodeFilter . SHOW_TEXT ) ;
12801279 let textNode ;
12811280 while ( textNode = lineWalker . nextNode ( ) ) {
1282- const computedStyle = window . getComputedStyle ( textNode . parentElement ) ;
1283- const lineHeight = parseInt ( ( computedStyle . lineHeight === 'normal' ? computedStyle . fontSize : computedStyle . lineHeight ) . replace ( 'px' , '' ) ) ;
1284- if ( lineHeight >= paragraphLineHeight ) {
1285- const referenceRange = document . createRange ( ) ;
1286- referenceRange . selectNode ( textNode ) ;
1287- for ( const rangeRect of referenceRange . getClientRects ( ) ) linePositions . add ( rangeRect . bottom ) ;
1288- }
1281+ // Skip text nodes in elements that are higher or lower than surrounding text
1282+ if ( textNode . parentElement . closest ( 'sup, sub, rt' ) ) continue ;
1283+ const referenceRange = document . createRange ( ) ;
1284+ referenceRange . selectNode ( textNode ) ;
1285+ for ( const rangeRect of referenceRange . getClientRects ( ) ) linePositions . add ( rangeRect . bottom ) ;
12891286 }
12901287 linePositions = Array . from ( linePositions ) ;
12911288
0 commit comments