@@ -288,7 +288,13 @@ async function recursivelyTranslate(
288
288
currentDepth ++ ;
289
289
290
290
// 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 ;
292
298
293
299
if ( currentDepth === 2 || isRecording ) {
294
300
isRecording = true ;
@@ -303,9 +309,13 @@ async function recursivelyTranslate(
303
309
304
310
parser . on ( "text" , text => {
305
311
text = strongEscapeXML ( text ) ;
306
-
312
+
307
313
// 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 ;
309
319
310
320
if ( isRecording ) {
311
321
currentSegment += text ;
@@ -321,7 +331,13 @@ async function recursivelyTranslate(
321
331
} ) ;
322
332
323
333
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
+ ) {
325
341
currentSegment += `</${ tagName } >` ;
326
342
}
327
343
@@ -464,19 +480,13 @@ async function recursivelyTranslate(
464
480
465
481
clean . on ( "opentag" , node => {
466
482
currDepth ++ ;
467
- if (
468
- node . name != "WRAPPER" &&
469
- node . name != "TRANSLATE"
470
- ) {
483
+ if ( node . name != "WRAPPER" && node . name != "TRANSLATE" ) {
471
484
translatedChunk += `<${ node . name } ${ formatAttributes ( node . attributes ) } >` ;
472
485
}
473
486
} ) ;
474
487
475
488
clean . on ( "closetag" , tagName => {
476
- if (
477
- tagName != "WRAPPER" &&
478
- tagName != "TRANSLATE"
479
- ) {
489
+ if ( tagName != "WRAPPER" && tagName != "TRANSLATE" ) {
480
490
translatedChunk += `</${ tagName } >` ;
481
491
}
482
492
currDepth -- ;
0 commit comments