@@ -288,7 +288,13 @@ async function recursivelyTranslate(
288288 currentDepth ++ ;
289289
290290 // If we're at depth 2, this is the start of a new segment.
291- if ( node . name == "SCHEME" || node . name == "SCHEMEINLINE" ) return ;
291+ if (
292+ node . name == "SCHEME" ||
293+ node . name == "SCHEMEINLINE" ||
294+ parser . _parser . tag === "SCHEME" ||
295+ parser . _parser . tag === "SCHEMEINLINE"
296+ )
297+ return ;
292298
293299 if ( currentDepth === 2 || isRecording ) {
294300 isRecording = true ;
@@ -303,9 +309,13 @@ async function recursivelyTranslate(
303309
304310 parser . on ( "text" , text => {
305311 text = strongEscapeXML ( text ) ;
306-
312+
307313 // ignore all scheme contents
308- if ( parser . _parser . tag == "SCHEME" || parser . _parser . tag == "SCHEMEINLINE" ) return ;
314+ if (
315+ parser . _parser . tag == "SCHEME" ||
316+ parser . _parser . tag == "SCHEMEINLINE"
317+ )
318+ return ;
309319
310320 if ( isRecording ) {
311321 currentSegment += text ;
@@ -321,7 +331,13 @@ async function recursivelyTranslate(
321331 } ) ;
322332
323333 parser . on ( "closetag" , tagName => {
324- if ( tagName !== "SCHEME" && tagName !== "SCHEMEINLINE" && isRecording ) {
334+ if (
335+ tagName !== "SCHEME" &&
336+ tagName !== "SCHEMEINLINE" &&
337+ parser . _parser . tag !== "SCHEME" &&
338+ parser . _parser . tag !== "SCHEMEINLINE" &&
339+ isRecording
340+ ) {
325341 currentSegment += `</${ tagName } >` ;
326342 }
327343
@@ -464,19 +480,13 @@ async function recursivelyTranslate(
464480
465481 clean . on ( "opentag" , node => {
466482 currDepth ++ ;
467- if (
468- node . name != "WRAPPER" &&
469- node . name != "TRANSLATE"
470- ) {
483+ if ( node . name != "WRAPPER" && node . name != "TRANSLATE" ) {
471484 translatedChunk += `<${ node . name } ${ formatAttributes ( node . attributes ) } >` ;
472485 }
473486 } ) ;
474487
475488 clean . on ( "closetag" , tagName => {
476- if (
477- tagName != "WRAPPER" &&
478- tagName != "TRANSLATE"
479- ) {
489+ if ( tagName != "WRAPPER" && tagName != "TRANSLATE" ) {
480490 translatedChunk += `</${ tagName } >` ;
481491 }
482492 currDepth -- ;
0 commit comments