@gmb/bitmark-parser-generator 1.5.12 → 1.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/browser/bitmark-parser-generator.min.js +1 -1
  2. package/dist/browser/bundle-report.html +2 -2
  3. package/dist/cjs/ast/Ast.js +13 -13
  4. package/dist/cjs/ast/Ast.js.map +1 -1
  5. package/dist/cjs/generated/build-info.js +1 -1
  6. package/dist/cjs/generated/parser/text/text-peggy-parser.js +729 -642
  7. package/dist/cjs/generated/parser/text/text-peggy-parser.js.map +1 -1
  8. package/dist/cjs/generator/AstWalkerGenerator.js +83 -0
  9. package/dist/cjs/generator/AstWalkerGenerator.js.map +1 -0
  10. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +144 -180
  11. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  12. package/dist/cjs/generator/json/JsonGenerator.js +66 -95
  13. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  14. package/dist/cjs/generator/text/TextGenerator.js +36 -73
  15. package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
  16. package/dist/cjs/model/enum/TextNodeType.js +1 -0
  17. package/dist/cjs/model/enum/TextNodeType.js.map +1 -1
  18. package/dist/esm/ast/Ast.js +13 -13
  19. package/dist/esm/ast/Ast.js.map +1 -1
  20. package/dist/esm/generated/build-info.js +1 -1
  21. package/dist/esm/generated/parser/text/text-peggy-parser.js +729 -642
  22. package/dist/esm/generated/parser/text/text-peggy-parser.js.map +1 -1
  23. package/dist/esm/generator/AstWalkerGenerator.js +80 -0
  24. package/dist/esm/generator/AstWalkerGenerator.js.map +1 -0
  25. package/dist/esm/generator/bitmark/BitmarkGenerator.js +144 -180
  26. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  27. package/dist/esm/generator/json/JsonGenerator.js +66 -95
  28. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  29. package/dist/esm/generator/text/TextGenerator.js +36 -73
  30. package/dist/esm/generator/text/TextGenerator.js.map +1 -1
  31. package/dist/esm/model/enum/TextNodeType.js +1 -0
  32. package/dist/esm/model/enum/TextNodeType.js.map +1 -1
  33. package/dist/types/ast/Ast.d.ts +4 -8
  34. package/dist/types/ast/Ast.d.ts.map +1 -1
  35. package/dist/types/generated/parser/text/text-peggy-parser.d.ts.map +1 -1
  36. package/dist/types/generator/AstWalkerGenerator.d.ts +32 -0
  37. package/dist/types/generator/AstWalkerGenerator.d.ts.map +1 -0
  38. package/dist/types/generator/Generator.d.ts +2 -2
  39. package/dist/types/generator/Generator.d.ts.map +1 -1
  40. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +121 -127
  41. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  42. package/dist/types/generator/json/JsonGenerator.d.ts +43 -48
  43. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  44. package/dist/types/generator/text/TextGenerator.d.ts +13 -17
  45. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  46. package/dist/types/model/enum/TextNodeType.d.ts +2 -0
  47. package/dist/types/model/enum/TextNodeType.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -22,13 +22,14 @@ const PropertyTag_1 = require("../../model/enum/PropertyTag");
22
22
  const ResourceTag_1 = require("../../model/enum/ResourceTag");
23
23
  const TextFormat_1 = require("../../model/enum/TextFormat");
24
24
  const BooleanUtils_1 = require("../../utils/BooleanUtils");
25
+ const AstWalkerGenerator_1 = require("../AstWalkerGenerator");
25
26
  const DEFAULT_OPTIONS = {
26
27
  debugGenerationInline: false,
27
28
  };
28
29
  /**
29
30
  * Generate bitmark markup from a bitmark AST
30
31
  */
31
- class BitmarkGenerator {
32
+ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
32
33
  /**
33
34
  * Generate bitmark markup from a bitmark AST
34
35
  *
@@ -45,14 +46,14 @@ class BitmarkGenerator {
45
46
  * @param options - bitmark generation options
46
47
  */
47
48
  constructor(writer, options) {
48
- var _a;
49
+ var _a, _b;
50
+ super();
49
51
  this.ast = new Ast_1.Ast();
50
52
  // State
51
53
  this.skipNLBetweenBitsValue = false;
52
- // Debug
53
- this.printed = false;
54
54
  this.bitmarkVersion = (_a = BitmarkVersion_1.BitmarkVersion.fromValue(options === null || options === void 0 ? void 0 : options.bitmarkVersion)) !== null && _a !== void 0 ? _a : BitmarkVersion_1.DEFAULT_BITMARK_VERSION;
55
55
  this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options === null || options === void 0 ? void 0 : options.bitmarkOptions);
56
+ this.debugGenerationInline = (_b = this.options.debugGenerationInline) !== null && _b !== void 0 ? _b : false;
56
57
  // Set defaults according to bitmark version
57
58
  if (this.bitmarkVersion === BitmarkVersion_1.BitmarkVersion.v2) {
58
59
  if (this.options.cardSetVersion === undefined) {
@@ -115,55 +116,6 @@ class BitmarkGenerator {
115
116
  // Ensure a blank line at end of file
116
117
  this.writeLine();
117
118
  }
118
- enter(node, parent, route) {
119
- let res = void 0;
120
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
- const gen = this;
122
- const funcName = `enter_${node.key}`;
123
- if (!this.printed) {
124
- this.printed = true;
125
- }
126
- if (this.options.debugGenerationInline)
127
- this.writeInlineDebug(node.key, { open: true });
128
- if (typeof gen[funcName] === 'function') {
129
- res = gen[funcName](node, parent, route);
130
- }
131
- return res;
132
- }
133
- between(node, left, right, parent, route) {
134
- let res = void 0;
135
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
- const gen = this;
137
- const funcName = `between_${node.key}`;
138
- if (this.options.debugGenerationInline)
139
- this.writeInlineDebug(node.key, { single: true });
140
- if (typeof gen[funcName] === 'function') {
141
- res = gen[funcName](node, left, right, parent, route);
142
- }
143
- return res;
144
- }
145
- exit(node, parent, route) {
146
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
147
- const gen = this;
148
- const funcName = `exit_${node.key}`;
149
- if (this.options.debugGenerationInline)
150
- this.writeInlineDebug(node.key, { close: true });
151
- if (typeof gen[funcName] === 'function') {
152
- gen[funcName](node, parent, route);
153
- }
154
- }
155
- leaf(node, parent, route) {
156
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
- const gen = this;
158
- const funcName = `leaf_${node.key}`;
159
- if (this.options.debugGenerationInline)
160
- this.writeInlineDebug(node.key, { open: true });
161
- if (typeof gen[funcName] === 'function') {
162
- gen[funcName](node, parent, route);
163
- }
164
- if (this.options.debugGenerationInline)
165
- this.writeInlineDebug(node.key, { close: true });
166
- }
167
119
  //
168
120
  // NODE HANDLERS
169
121
  //
@@ -172,13 +124,13 @@ class BitmarkGenerator {
172
124
  //
173
125
  // bitmark
174
126
  // bitmarkAst -> bits
175
- between_bits(_node, _left, _right, _parent, _route) {
127
+ between_bits(_node, _left, _right, _route) {
176
128
  this.writeNL();
177
129
  this.writeNL();
178
130
  this.writeNL();
179
131
  }
180
132
  // bitmarkAst -> bits -> bitsValue
181
- enter_bitsValue(node, _parent, _route) {
133
+ enter_bitsValue(node, _route) {
182
134
  const bit = node.value;
183
135
  const bitConfig = Config_1.Config.getBitConfig(bit.bitType);
184
136
  const bitResourcesConfig = Config_1.Config.getBitResourcesConfig(bit.bitType, bit.resourceType);
@@ -216,7 +168,7 @@ class BitmarkGenerator {
216
168
  this.writeCL();
217
169
  this.writeNL();
218
170
  }
219
- between_bitsValue(node, left, _right, _parent, _route) {
171
+ between_bitsValue(node, left, _right, _route) {
220
172
  // The following keys are combined with other keys so don't need newlines
221
173
  const noNlKeys = [
222
174
  NodeType_1.NodeType.bitType,
@@ -249,9 +201,10 @@ class BitmarkGenerator {
249
201
  }
250
202
  }
251
203
  // bitmarkAst -> bits -> bitsValue -> internalComment
252
- enter_internalComment(node, parent, _route) {
204
+ enter_internalComment(node, route) {
253
205
  const internalComment = node.value;
254
206
  // Ignore values that are not at the bit level as they might be handled elsewhere
207
+ const parent = this.getParentNode(route);
255
208
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
256
209
  return;
257
210
  for (let i = 0; i < internalComment.length; i++) {
@@ -263,9 +216,10 @@ class BitmarkGenerator {
263
216
  }
264
217
  }
265
218
  // bitmarkAst -> bits -> bitsValue -> labelTrue / labelFalse
266
- enter_labelTrue(node, parent, _route) {
219
+ enter_labelTrue(node, route) {
267
220
  const value = node.value;
268
221
  // Ignore example that is not at the bit level as it are handled elsewhere
222
+ const parent = this.getParentNode(route);
269
223
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
270
224
  return;
271
225
  const bit = parent === null || parent === void 0 ? void 0 : parent.value;
@@ -277,9 +231,10 @@ class BitmarkGenerator {
277
231
  }
278
232
  }
279
233
  // bitmarkAst -> bits -> bitsValue -> imageSource
280
- enter_imageSource(node, parent, _route) {
234
+ enter_imageSource(node, route) {
281
235
  const imageSource = node.value;
282
236
  // Ignore values that are not at the bit level as they might be handled elsewhere
237
+ const parent = this.getParentNode(route);
283
238
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
284
239
  return;
285
240
  const { url, mockupId, size, format, trim } = imageSource;
@@ -296,9 +251,10 @@ class BitmarkGenerator {
296
251
  }
297
252
  }
298
253
  // bitmarkAst -> bits -> bitsValue -> partner
299
- enter_partner(node, parent, _route) {
254
+ enter_partner(node, route) {
300
255
  const partner = node.value;
301
256
  // Ignore values that are not at the bit level as they might be handled elsewhere
257
+ const parent = this.getParentNode(route);
302
258
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
303
259
  return;
304
260
  const { name, avatarImage } = partner;
@@ -308,9 +264,10 @@ class BitmarkGenerator {
308
264
  }
309
265
  }
310
266
  // bitmarkAst -> bits -> bitsValue -> markConfigValue
311
- enter_markConfigValue(node, parent, _route) {
267
+ enter_markConfigValue(node, route) {
312
268
  const markConfig = node.value;
313
269
  // Ignore values that are not at the correct level as they might be handled elsewhere
270
+ const parent = this.getParentNode(route);
314
271
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.markConfig)
315
272
  return;
316
273
  const { mark, color, emphasis } = markConfig;
@@ -325,16 +282,16 @@ class BitmarkGenerator {
325
282
  }
326
283
  // bitmarkAst -> bits -> bitsValue -> sampleSolution
327
284
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> sampleSolution
328
- leaf_sampleSolution(node, _parent, _route) {
285
+ leaf_sampleSolution(node, _route) {
329
286
  this.writeProperty('sampleSolution', node.value);
330
287
  }
331
288
  // bitmarkAst -> bits -> bitsValue -> reasonableNumOfChars
332
289
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> reasonableNumOfChars
333
- leaf_reasonableNumOfChars(node, _parent, _route) {
290
+ leaf_reasonableNumOfChars(node, _route) {
334
291
  this.writeProperty('reasonableNumOfChars', node.value);
335
292
  }
336
293
  // bitmarkAst -> bits -> bitsValue -> itemLead
337
- enter_itemLead(node, _parent, _route) {
294
+ enter_itemLead(node, _route) {
338
295
  const itemLead = node.value;
339
296
  if (itemLead && (itemLead.item || itemLead.lead || itemLead.pageNumber || itemLead.marginNumber)) {
340
297
  // Always write item if item or lead is set
@@ -359,7 +316,7 @@ class BitmarkGenerator {
359
316
  }
360
317
  }
361
318
  // bitmarkAst -> bits -> bitsValue -> body
362
- enter_body(node, _parent, _route) {
319
+ enter_body(node, _route) {
363
320
  // always write a NL before the body content if there is any?
364
321
  const body = node.value;
365
322
  if (body.bodyParts.length > 0) {
@@ -367,7 +324,7 @@ class BitmarkGenerator {
367
324
  }
368
325
  }
369
326
  // bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> solutions
370
- enter_solutions(node, _parent, _route) {
327
+ enter_solutions(node, _route) {
371
328
  const solutions = node.value;
372
329
  if (solutions && solutions.length === 0) {
373
330
  // If there are no solutions, we need to write the special cloze gap [_] to indicate this
@@ -376,7 +333,7 @@ class BitmarkGenerator {
376
333
  }
377
334
  }
378
335
  // bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> solution
379
- leaf_solution(node, _parent, route) {
336
+ leaf_solution(node, route) {
380
337
  var _a;
381
338
  const solution = node.value;
382
339
  // Ignore values that are not at the correct level as they might be handled elsewhere
@@ -390,7 +347,7 @@ class BitmarkGenerator {
390
347
  }
391
348
  }
392
349
  // bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> mark
393
- leaf_mark(node, _parent, route) {
350
+ leaf_mark(node, route) {
394
351
  var _a;
395
352
  const mark = node.value;
396
353
  // Ignore values that are not at the correct level as they might be handled elsewhere
@@ -402,7 +359,7 @@ class BitmarkGenerator {
402
359
  }
403
360
  }
404
361
  // bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> options -> optionsValue
405
- enter_optionsValue(node, _parent, _route) {
362
+ enter_optionsValue(node, _route) {
406
363
  const selectOption = node.value;
407
364
  if (selectOption.isCorrect) {
408
365
  this.writeOPP();
@@ -414,7 +371,7 @@ class BitmarkGenerator {
414
371
  this.writeCL();
415
372
  }
416
373
  // bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> texts -> textsValue
417
- enter_textsValue(node, _parent, _route) {
374
+ enter_textsValue(node, _route) {
418
375
  const highlightText = node.value;
419
376
  if (highlightText.isCorrect) {
420
377
  this.writeOPP();
@@ -426,7 +383,7 @@ class BitmarkGenerator {
426
383
  this.writeCL();
427
384
  }
428
385
  // bitmarkAst -> bits -> bitsValue -> cardNode
429
- enter_cardNode(_node, _parent, route) {
386
+ enter_cardNode(_node, route) {
430
387
  // Ignore cards for xxx-1
431
388
  const isBitType1 = this.isOfBitType1(route);
432
389
  if (isBitType1)
@@ -434,7 +391,7 @@ class BitmarkGenerator {
434
391
  this.writeCardSetStart();
435
392
  this.writeNL();
436
393
  }
437
- between_cardNode(_node, _left, _right, _parent, route) {
394
+ between_cardNode(_node, _left, _right, route) {
438
395
  // Ignore cards for xxx-1
439
396
  const isBitType1 = this.isOfBitType1(route);
440
397
  if (isBitType1)
@@ -443,7 +400,7 @@ class BitmarkGenerator {
443
400
  this.writeCardSetCardDivider();
444
401
  this.writeNL();
445
402
  }
446
- exit_cardNode(_node, _parent, route) {
403
+ exit_cardNode(_node, route) {
447
404
  // Ignore cards for xxx-1
448
405
  const isBitType1 = this.isOfBitType1(route);
449
406
  if (isBitType1)
@@ -453,25 +410,25 @@ class BitmarkGenerator {
453
410
  this.writeNL();
454
411
  }
455
412
  // bitmarkAst -> bits -> bitsValue -> cardNode -> elements
456
- enter_elements(_node, _parent, _route) {
413
+ enter_elements(_node, _route) {
457
414
  //
458
415
  }
459
- between_elements(_node, _left, _right, _parent, _route) {
416
+ between_elements(_node, _left, _right, _route) {
460
417
  this.writeNL();
461
418
  this.writeCardSetVariantDivider();
462
419
  this.writeNL();
463
420
  }
464
- exit_elements(_node, _parent, _route) {
421
+ exit_elements(_node, _route) {
465
422
  //
466
423
  }
467
424
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards
468
- between_flashcards(_node, _left, _right, _parent, _route) {
425
+ between_flashcards(_node, _left, _right, _route) {
469
426
  this.writeNL();
470
427
  this.writeCardSetCardDivider();
471
428
  this.writeNL();
472
429
  }
473
430
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue
474
- between_flashcardsValue(_node, _left, right, _parent, _route) {
431
+ between_flashcardsValue(_node, _left, right, _route) {
475
432
  if (right.key === NodeType_1.NodeType.answer) {
476
433
  this.writeNL();
477
434
  this.writeCardSetSideDivider();
@@ -484,8 +441,9 @@ class BitmarkGenerator {
484
441
  }
485
442
  }
486
443
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> answer
487
- leaf_answer(node, parent, _route) {
444
+ leaf_answer(node, route) {
488
445
  // Ignore responses that are not at the flashcardsValue level as they are handled elsewhere
446
+ const parent = this.getParentNode(route);
489
447
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.flashcardsValue)
490
448
  return;
491
449
  if (node.value) {
@@ -493,14 +451,15 @@ class BitmarkGenerator {
493
451
  }
494
452
  }
495
453
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> alternativeAnswers
496
- between_alternativeAnswers(_node, _parent, _route) {
454
+ between_alternativeAnswers(_node, _route) {
497
455
  this.writeNL();
498
456
  this.writeCardSetVariantDivider();
499
457
  this.writeNL();
500
458
  }
501
459
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> alternativeAnswers -> alternativeAnswersValue
502
- leaf_alternativeAnswersValue(node, parent, _route) {
460
+ leaf_alternativeAnswersValue(node, route) {
503
461
  // Ignore responses that are not at the alternativeAnswers level as they are handled elsewhere
462
+ const parent = this.getParentNode(route);
504
463
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.alternativeAnswers)
505
464
  return;
506
465
  if (node.value) {
@@ -508,10 +467,10 @@ class BitmarkGenerator {
508
467
  }
509
468
  }
510
469
  // bitmarkAst -> bits -> bitsValue -> cardNode -> statements
511
- enter_statements(_node, _parent, _route) {
470
+ enter_statements(_node, _route) {
512
471
  //
513
472
  }
514
- between_statements(_node, _left, _right, _parent, route) {
473
+ between_statements(_node, _left, _right, route) {
515
474
  const isTrueFalse1 = this.isOfBitType(route, BitType_1.BitType.trueFalse1);
516
475
  if (!isTrueFalse1) {
517
476
  this.writeNL();
@@ -519,11 +478,11 @@ class BitmarkGenerator {
519
478
  }
520
479
  this.writeNL();
521
480
  }
522
- exit_statements(_node, _parent, _route) {
481
+ exit_statements(_node, _route) {
523
482
  //
524
483
  }
525
484
  // bitmarkAst -> bits -> bitsValue -> cardNode -> statements -> statementsValue
526
- enter_statementsValue(node, _parent, _route) {
485
+ enter_statementsValue(node, _route) {
527
486
  const statement = node.value;
528
487
  if (statement.isCorrect) {
529
488
  this.writeOPP();
@@ -536,15 +495,15 @@ class BitmarkGenerator {
536
495
  }
537
496
  // bitmarkAst -> bits -> bitsValue -> choices
538
497
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices
539
- between_choices(_node, _left, _right, _parent, _route) {
498
+ between_choices(_node, _left, _right, _route) {
540
499
  this.writeNL();
541
500
  }
542
- exit_choices(_node, _parent, _route) {
501
+ exit_choices(_node, _route) {
543
502
  this.writeNL();
544
503
  }
545
504
  // bitmarkAst -> bits -> bitsValue -> choices -> choicesValue
546
505
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices -> choicesValue
547
- enter_choicesValue(node, _parent, _route) {
506
+ enter_choicesValue(node, _route) {
548
507
  const choice = node.value;
549
508
  if (choice.isCorrect) {
550
509
  this.writeOPP();
@@ -557,15 +516,15 @@ class BitmarkGenerator {
557
516
  }
558
517
  // bitmarkAst -> bits -> bitsValue -> responses
559
518
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses
560
- between_responses(_node, _left, _right, _parent, _route) {
519
+ between_responses(_node, _left, _right, _route) {
561
520
  this.writeNL();
562
521
  }
563
- exit_responses(_node, _parent, _route) {
522
+ exit_responses(_node, _route) {
564
523
  this.writeNL();
565
524
  }
566
525
  // bitmarkAst -> bits -> bitsValue -> responses -> responsesValue
567
526
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses -> responsesValue
568
- enter_responsesValue(node, _parent, _route) {
527
+ enter_responsesValue(node, _route) {
569
528
  const response = node.value;
570
529
  if (response.isCorrect) {
571
530
  this.writeOPP();
@@ -577,183 +536,184 @@ class BitmarkGenerator {
577
536
  this.writeCL();
578
537
  }
579
538
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes
580
- enter_quizzes(_node, _parent, _route) {
539
+ enter_quizzes(_node, _route) {
581
540
  //
582
541
  }
583
- between_quizzes(_node, _left, _right, _parent, _route) {
542
+ between_quizzes(_node, _left, _right, _route) {
584
543
  // this.writeNL();
585
544
  this.writeCardSetCardDivider();
586
545
  this.writeNL();
587
546
  }
588
- exit_quizzes(_node, _parent, _route) {
547
+ exit_quizzes(_node, _route) {
589
548
  //
590
549
  }
591
550
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue
592
- between_quizzesValue(_node, _left, right, _parent, _route) {
551
+ between_quizzesValue(_node, _left, right, _route) {
593
552
  if (right.key === NodeType_1.NodeType.choices || right.key === NodeType_1.NodeType.responses) {
594
553
  this.writeNL();
595
554
  }
596
555
  }
597
556
  // bitmarkAst -> bits -> bitsValue -> cardNode -> heading
598
- enter_heading(_node, _parent, _route) {
557
+ enter_heading(_node, _route) {
599
558
  //
600
559
  }
601
- between_heading(_node, _left, _right, _parent, _route) {
560
+ between_heading(_node, _left, _right, _route) {
602
561
  this.writeNL();
603
562
  this.writeCardSetSideDivider();
604
563
  this.writeNL();
605
564
  }
606
- exit_heading(_node, _parent, _route) {
565
+ exit_heading(_node, _route) {
607
566
  //
608
567
  }
609
568
  // bitmarkAst -> bits -> bitsValue -> cardNode -> heading -> forValues
610
- enter_forValues(_node, _parent, _route) {
569
+ enter_forValues(_node, _route) {
611
570
  //
612
571
  }
613
- between_forValues(_node, _left, _right, _parent, _route) {
572
+ between_forValues(_node, _left, _right, _route) {
614
573
  this.writeNL();
615
574
  this.writeCardSetSideDivider();
616
575
  this.writeNL();
617
576
  }
618
- exit_forValues(_node, _parent, _route) {
577
+ exit_forValues(_node, _route) {
619
578
  //
620
579
  }
621
580
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
622
- enter_pairs(_node, _parent, _route) {
581
+ enter_pairs(_node, _route) {
623
582
  //
624
583
  }
625
- between_pairs(_node, _left, _right, _parent, _route) {
584
+ between_pairs(_node, _left, _right, _route) {
626
585
  this.writeNL();
627
586
  this.writeCardSetCardDivider();
628
587
  this.writeNL();
629
588
  }
630
- exit_pairs(_node, _parent, _route) {
589
+ exit_pairs(_node, _route) {
631
590
  //
632
591
  }
633
592
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue
634
- between_pairsValue(_node, _left, _right, _parent, _route) {
593
+ between_pairsValue(_node, _left, _right, _route) {
635
594
  //
636
595
  }
637
596
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue -> keyAudio
638
- enter_keyAudio(node, _parent, _route) {
597
+ enter_keyAudio(node, _route) {
639
598
  const resource = node.value;
640
599
  // This is a resource, so handle it with the common code
641
600
  this.writeResource(resource);
642
601
  }
643
602
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue -> keyImage
644
- enter_keyImage(node, _parent, _route) {
603
+ enter_keyImage(node, _route) {
645
604
  const resource = node.value;
646
605
  // This is a resource, so handle it with the common code
647
606
  this.writeResource(resource);
648
607
  }
649
608
  // bitmarkAst -> bits -> bitsValue -> cardNode -> matrix
650
- enter_matrix(_node, _parent, _route) {
609
+ enter_matrix(_node, _route) {
651
610
  //
652
611
  }
653
- between_matrix(_node, _left, _right, _parent, _route) {
612
+ between_matrix(_node, _left, _right, _route) {
654
613
  this.writeNL();
655
614
  this.writeCardSetCardDivider();
656
615
  this.writeNL();
657
616
  }
658
- exit_matrix(_node, _parent, _route) {
617
+ exit_matrix(_node, _route) {
659
618
  //
660
619
  }
661
620
  // bitmarkAst -> bits -> bitsValue -> cardNode -> matrix -> matrixValue
662
- between_matrixValue(_node, _left, _right, _parent, _route) {
621
+ between_matrixValue(_node, _left, _right, _route) {
663
622
  //
664
623
  }
665
624
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue -> values
666
625
  // bitmarkAst -> bits -> bitsValue -> cardNode -> matrix -> matrixValue -> cells -> cellsValue -> values
667
- enter_values(_node, _parent, _route) {
626
+ enter_values(_node, _route) {
668
627
  this.writeNL();
669
628
  this.writeCardSetSideDivider();
670
629
  this.writeNL();
671
630
  }
672
- between_values(_node, _left, _right, _parent, _route) {
631
+ between_values(_node, _left, _right, _route) {
673
632
  this.writeNL();
674
633
  this.writeCardSetVariantDivider();
675
634
  this.writeNL();
676
635
  }
677
636
  // bitmarkAst -> bits -> bitsValue -> cardNode -> questions
678
- enter_questions(_node, _parent, _route) {
637
+ enter_questions(_node, _route) {
679
638
  //
680
639
  }
681
- between_questions(_node, _left, _right, _parent, _route) {
640
+ between_questions(_node, _left, _right, _route) {
682
641
  this.writeCardSetCardDivider();
683
642
  this.writeNL();
684
643
  }
685
- exit_questions(_node, _parent, _route) {
644
+ exit_questions(_node, _route) {
686
645
  //
687
646
  }
688
647
  // bitmarkAst -> bits -> bitsValue -> cardNode -> questions -> questionsValue
689
- between_questionsValue(_node, _left, right, _parent, _route) {
648
+ between_questionsValue(_node, _left, right, _route) {
690
649
  if (right.key === NodeType_1.NodeType.sampleSolution) {
691
650
  this.writeNL();
692
651
  }
693
652
  }
694
- exit_questionsValue(_node, _parent, _route) {
653
+ exit_questionsValue(_node, _route) {
695
654
  this.writeNL();
696
655
  }
697
656
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses
698
- enter_botResponses(_node, _parent, _route) {
657
+ enter_botResponses(_node, _route) {
699
658
  //
700
659
  }
701
- between_botResponses(_node, _left, _right, _parent, _route) {
660
+ between_botResponses(_node, _left, _right, _route) {
702
661
  this.writeCardSetCardDivider();
703
662
  this.writeNL();
704
663
  }
705
- exit_botResponses(_node, _parent, _route) {
664
+ exit_botResponses(_node, _route) {
706
665
  //
707
666
  }
708
667
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue
709
- between_botResponsesValue(_node, _left, _right, _parent, _route) {
668
+ between_botResponsesValue(_node, _left, _right, _route) {
710
669
  this.writeNL();
711
670
  }
712
- exit_botResponsesValue(_node, _parent, _route) {
671
+ exit_botResponsesValue(_node, _route) {
713
672
  this.writeNL();
714
673
  }
715
674
  // bitmarkAst -> bits -> bitsValue -> cardNode -> cardBits
716
- enter_cardBits(_node, _parent, _route) {
675
+ enter_cardBits(_node, _route) {
717
676
  //
718
677
  }
719
- between_cardBits(_node, _left, _right, _parent, _route) {
678
+ between_cardBits(_node, _left, _right, _route) {
720
679
  this.writeNL();
721
680
  this.writeCardSetCardDivider();
722
681
  this.writeNL();
723
682
  }
724
- exit_cardBits(_node, _parent, _route) {
683
+ exit_cardBits(_node, _route) {
725
684
  //
726
685
  }
727
686
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> response
728
- leaf_response(node, _parent, _route) {
687
+ leaf_response(node, _route) {
729
688
  this.writeOPB();
730
689
  this.writeString(node.value);
731
690
  this.writeCL();
732
691
  }
733
692
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> reaction
734
- leaf_reaction(node, _parent, _route) {
693
+ leaf_reaction(node, _route) {
735
694
  this.writeProperty('reaction', node.value, true);
736
695
  }
737
696
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> feedback
738
- leaf_feedback(node, _parent, _route) {
697
+ leaf_feedback(node, _route) {
739
698
  const feeback = node.value;
740
699
  if (feeback) {
741
700
  this.write(feeback);
742
701
  }
743
702
  }
744
703
  // bitmarkAst -> bits -> bitsValue -> resources
745
- between_resources(_node, _left, _right, _parent, _route) {
704
+ between_resources(_node, _left, _right, _route) {
746
705
  this.writeNL();
747
706
  }
748
707
  // bitmarkAst -> bits -> bitsValue -> resourcesValue
749
- enter_resourcesValue(node, _parent, _route) {
708
+ enter_resourcesValue(node, _route) {
750
709
  const resource = node.value;
751
710
  // This is a resource, so handle it with the common code
752
711
  this.writeResource(resource);
753
712
  }
754
713
  // bitmarkAst -> bits -> bitsValue -> posterImage
755
714
  // bitmarkAst -> bits -> bitsValue -> resource -> posterImage
756
- enter_posterImage(node, parent, _route) {
715
+ enter_posterImage(node, route) {
716
+ const parent = this.getParentNode(route);
757
717
  if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType_1.NodeType.bitsValue) {
758
718
  // Bit poster image
759
719
  const posterImage = node.value;
@@ -771,7 +731,7 @@ class BitmarkGenerator {
771
731
  }
772
732
  // bitmarkAst -> bits -> bitsValue -> resource -> thumbnails
773
733
  // [src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
774
- enter_thumbnails(node, _parent, _route) {
734
+ enter_thumbnails(node, _route) {
775
735
  const thumbnails = node.value;
776
736
  if (Array.isArray(thumbnails)) {
777
737
  const thumbnailKeys = ['src1x', 'src2x', 'src3x', 'src4x'];
@@ -791,7 +751,8 @@ class BitmarkGenerator {
791
751
  // bitmarkAst -> bits -> bitsValue -> bitType
792
752
  // bitmarkAst -> bits -> bitsValue -> textFormat
793
753
  // bitmarkAst -> bits -> title
794
- leaf_title(node, parent, _route) {
754
+ leaf_title(node, route) {
755
+ const parent = this.getParentNode(route);
795
756
  const value = node.value;
796
757
  const title = value;
797
758
  const bit = parent === null || parent === void 0 ? void 0 : parent.value;
@@ -805,7 +766,7 @@ class BitmarkGenerator {
805
766
  }
806
767
  }
807
768
  // bitmarkAst -> bits -> subtitle
808
- leaf_subtitle(node, _parent, _route) {
769
+ leaf_subtitle(node, _route) {
809
770
  const value = node.value;
810
771
  const subtitle = value;
811
772
  const level = 2;
@@ -818,7 +779,8 @@ class BitmarkGenerator {
818
779
  }
819
780
  }
820
781
  // bitmarkAst -> bits -> bitsValue -> book
821
- leaf_book(node, parent, _route) {
782
+ leaf_book(node, route) {
783
+ const parent = this.getParentNode(route);
822
784
  const bit = parent === null || parent === void 0 ? void 0 : parent.value;
823
785
  if (bit && node.value) {
824
786
  this.writeProperty('book', node.value);
@@ -835,7 +797,7 @@ class BitmarkGenerator {
835
797
  }
836
798
  }
837
799
  // bitmarkAst -> bits -> bitsValue -> anchor
838
- leaf_anchor(node, _parent, _route) {
800
+ leaf_anchor(node, _route) {
839
801
  if (node.value) {
840
802
  this.writeOPDANGLE();
841
803
  this.writeString(node.value);
@@ -843,7 +805,8 @@ class BitmarkGenerator {
843
805
  }
844
806
  }
845
807
  // bitmarkAst -> bits -> bitsValue -> reference
846
- leaf_reference(node, parent, _route) {
808
+ leaf_reference(node, route) {
809
+ const parent = this.getParentNode(route);
847
810
  const bit = parent === null || parent === void 0 ? void 0 : parent.value;
848
811
  if (bit && node.value) {
849
812
  // Only write reference if it is not chained to 'book'
@@ -857,7 +820,7 @@ class BitmarkGenerator {
857
820
  // * -> itemLead --> item
858
821
  // * -> itemLead --> lead
859
822
  // * -> hint
860
- leaf_hint(node, _parent, _route) {
823
+ leaf_hint(node, _route) {
861
824
  const value = node.value;
862
825
  const text = value;
863
826
  if (text) {
@@ -867,7 +830,7 @@ class BitmarkGenerator {
867
830
  }
868
831
  }
869
832
  // bitmarkAst -> bits -> bitsValue -> * -> instruction
870
- leaf_instruction(node, _parent, _route) {
833
+ leaf_instruction(node, _route) {
871
834
  const value = node.value;
872
835
  const text = value;
873
836
  if (text) {
@@ -877,9 +840,10 @@ class BitmarkGenerator {
877
840
  }
878
841
  }
879
842
  // bitmarkAst -> bits -> bitsValue -> * -> example
880
- leaf_example(node, parent, _route) {
843
+ leaf_example(node, route) {
881
844
  var _a, _b;
882
845
  const value = node.value;
846
+ const parent = this.getParentNode(route);
883
847
  const isExample = (_a = parent === null || parent === void 0 ? void 0 : parent.value.isExample) !== null && _a !== void 0 ? _a : false;
884
848
  const isDefaultExample = (_b = parent === null || parent === void 0 ? void 0 : parent.value.isDefaultExample) !== null && _b !== void 0 ? _b : false;
885
849
  if (!isExample)
@@ -907,7 +871,7 @@ class BitmarkGenerator {
907
871
  }
908
872
  }
909
873
  // bitmarkAst -> bits -> body -> bodyValue -> bodyText
910
- leaf_bodyText(node, _parent, _route) {
874
+ leaf_bodyText(node, _route) {
911
875
  const value = node.value;
912
876
  const text = value;
913
877
  if (text) {
@@ -915,7 +879,7 @@ class BitmarkGenerator {
915
879
  }
916
880
  }
917
881
  // bitmarkAst -> bits -> footer -> footerText
918
- leaf_footerText(node, _parent, _route) {
882
+ leaf_footerText(node, _route) {
919
883
  const value = node.value;
920
884
  const text = value;
921
885
  if (text) {
@@ -923,14 +887,14 @@ class BitmarkGenerator {
923
887
  }
924
888
  }
925
889
  // bitmarkAst -> bits -> bitsValue -> elements -> elementsValue
926
- leaf_elementsValue(node, _parent, _route) {
890
+ leaf_elementsValue(node, _route) {
927
891
  if (node.value) {
928
892
  this.writeString(node.value);
929
893
  }
930
894
  }
931
895
  // bitmarkAst -> bits -> bitsValue -> body -> bodyValue -> gap -> solutions -> solution
932
896
  // ? -> solutions -> solution
933
- leaf_solutionsValue(node, _parent, _route) {
897
+ leaf_solutionsValue(node, _route) {
934
898
  if (node.value) {
935
899
  this.writeOPU();
936
900
  this.writeString(node.value);
@@ -939,7 +903,7 @@ class BitmarkGenerator {
939
903
  }
940
904
  // bitmarkAst -> bits -> bitsValue-> body -> bodyValue -> select -> options -> prefix
941
905
  // bitmarkAst -> bits -> bitsValue-> body -> bodyValue -> highlight -> options -> prefix
942
- leaf_prefix(node, _parent, _route) {
906
+ leaf_prefix(node, _route) {
943
907
  if (node.value) {
944
908
  this.writeOPPRE();
945
909
  this.writeString(node.value);
@@ -948,7 +912,7 @@ class BitmarkGenerator {
948
912
  }
949
913
  // bitmarkAst -> bits -> bitsValue-> body -> bodyValue -> select -> options -> postfix
950
914
  // bitmarkAst -> bits -> bitsValue-> body -> bodyValue -> highlight -> options -> postfix
951
- leaf_postfix(node, _parent, _route) {
915
+ leaf_postfix(node, _route) {
952
916
  if (node.value) {
953
917
  this.writeOPPOST();
954
918
  this.writeString(node.value);
@@ -956,40 +920,41 @@ class BitmarkGenerator {
956
920
  }
957
921
  }
958
922
  // bitmarkAst -> bits -> bitsValue -> * -> isCaseSensitive
959
- leaf_isCaseSensitive(node, _parent, _route) {
923
+ leaf_isCaseSensitive(node, _route) {
960
924
  this.writeProperty('isCaseSensitive', node.value, true, false, true);
961
925
  }
962
926
  // bitmarkAst -> bits -> bitsValue -> * -> isCorrect
963
927
  // bitmarkAst -> bits -> bitsValue -> heading -> forKeys
964
- leaf_forKeys(node, _parent, _route) {
928
+ leaf_forKeys(node, _route) {
965
929
  this.writeOPHASH();
966
930
  this.writeString(node.value);
967
931
  this.writeCL();
968
932
  }
969
933
  // bitmarkAst -> bits -> bitsValue -> heading -> forValuesValue
970
- leaf_forValuesValue(node, _parent, _route) {
934
+ leaf_forValuesValue(node, _route) {
971
935
  this.writeOPHASH();
972
936
  this.writeString(node.value);
973
937
  this.writeCL();
974
938
  }
975
939
  // bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> key
976
940
  // bitmarkAst -> bits -> bitsValue -> matrix -> matrixValue -> key
977
- leaf_key(node, _parent, _route) {
941
+ leaf_key(node, _route) {
978
942
  if (node.value) {
979
943
  this.writeString(node.value);
980
944
  }
981
945
  }
982
946
  // bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> values -> valuesValue
983
947
  // bitmarkAst -> bits -> bitsValue -> matrix -> matrixValue -> cells -> cellsValue -> values -> valuesValue
984
- leaf_valuesValue(node, _parent, _route) {
948
+ leaf_valuesValue(node, _route) {
985
949
  if (node.value) {
986
950
  this.writeString(node.value);
987
951
  }
988
952
  }
989
953
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> question
990
954
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> question
991
- leaf_question(node, parent, _route) {
955
+ leaf_question(node, route) {
992
956
  // Ignore responses that are not at the questionsValue level as they are handled elsewhere
957
+ const parent = this.getParentNode(route);
993
958
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.questionsValue && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.flashcardsValue)
994
959
  return;
995
960
  if (node.value) {
@@ -1002,29 +967,29 @@ class BitmarkGenerator {
1002
967
  // bitmarkAst -> bits -> bitsValue -> resource -> posterImage -> ...
1003
968
  // bitmarkAst -> bits -> bitsValue -> resource -> thumbnails -> thumbnailsValue -> ...
1004
969
  // [src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
1005
- leaf_src1x(node, _parent, _route) {
970
+ leaf_src1x(node, _route) {
1006
971
  this.writeProperty('src1x', node.value);
1007
972
  }
1008
- leaf_src2x(node, _parent, _route) {
973
+ leaf_src2x(node, _route) {
1009
974
  this.writeProperty('src2x', node.value);
1010
975
  }
1011
- leaf_src3x(node, _parent, _route) {
976
+ leaf_src3x(node, _route) {
1012
977
  this.writeProperty('src3x', node.value);
1013
978
  }
1014
- leaf_src4x(node, _parent, _route) {
979
+ leaf_src4x(node, _route) {
1015
980
  this.writeProperty('src4x', node.value);
1016
981
  }
1017
- leaf_width(node, _parent, _route) {
982
+ leaf_width(node, _route) {
1018
983
  this.writeProperty('width', node.value);
1019
984
  }
1020
- leaf_height(node, _parent, _route) {
985
+ leaf_height(node, _route) {
1021
986
  this.writeProperty('height', node.value);
1022
987
  }
1023
- leaf_alt(node, _parent, _route) {
988
+ leaf_alt(node, _route) {
1024
989
  this.writeProperty('alt', node.value);
1025
990
  }
1026
- leaf_zoomDisabled(node, _parent, _route) {
1027
- const bitType = this.getBitType(_route);
991
+ leaf_zoomDisabled(node, route) {
992
+ const bitType = this.getBitType(route);
1028
993
  if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.imageSeparator, BitType_1.BitType.pageBanner])) {
1029
994
  this.writeProperty('zoomDisabled', node.value, undefined, false, true);
1030
995
  }
@@ -1032,20 +997,20 @@ class BitmarkGenerator {
1032
997
  this.writeProperty('zoomDisabled', node.value, undefined, true, false);
1033
998
  }
1034
999
  }
1035
- leaf_license(node, _parent, _route) {
1000
+ leaf_license(node, _route) {
1036
1001
  this.writeProperty('license', node.value);
1037
1002
  }
1038
- leaf_copyright(node, _parent, _route) {
1003
+ leaf_copyright(node, _route) {
1039
1004
  this.writeProperty('copyright', node.value);
1040
1005
  }
1041
- leaf_provider(_node, _parent, _route) {
1006
+ leaf_provider(_node, _route) {
1042
1007
  // provider is included in the url (it is the domain) and should not be written as a property
1043
1008
  // this.writeProperty('provider', node.value);
1044
1009
  }
1045
- leaf_showInIndex(node, _parent, _route) {
1010
+ leaf_showInIndex(node, _route) {
1046
1011
  this.writeProperty('showInIndex', node.value);
1047
1012
  }
1048
- leaf_caption(node, _parent, _route) {
1013
+ leaf_caption(node, _route) {
1049
1014
  const value = node.value;
1050
1015
  this.writeProperty('caption', value);
1051
1016
  }
@@ -1053,22 +1018,23 @@ class BitmarkGenerator {
1053
1018
  // bitmarkAst -> bits -> bitsValue -> resource -> posterImage -> ...
1054
1019
  // bitmarkAst -> bits -> bitsValue -> resource -> thumbnails -> thumbnailsValue -> ...
1055
1020
  // [duration,mute,autoplay,allowSubtitles,showSubtitles]
1056
- leaf_duration(node, parent, _route) {
1021
+ leaf_duration(node, route) {
1057
1022
  // Ignore duration that IS at the bit level as there is a key clash with resource...duration / bit.duration
1023
+ const parent = this.getParentNode(route);
1058
1024
  if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType_1.NodeType.bitsValue)
1059
1025
  return;
1060
1026
  this.writeProperty('duration', node.value);
1061
1027
  }
1062
- leaf_mute(node, _parent, _route) {
1028
+ leaf_mute(node, _route) {
1063
1029
  this.writeProperty('mute', node.value);
1064
1030
  }
1065
- leaf_autoplay(node, _parent, _route) {
1031
+ leaf_autoplay(node, _route) {
1066
1032
  this.writeProperty('autoplay', node.value);
1067
1033
  }
1068
- leaf_allowSubtitles(node, _parent, _route) {
1034
+ leaf_allowSubtitles(node, _route) {
1069
1035
  this.writeProperty('allowSubtitles', node.value);
1070
1036
  }
1071
- leaf_showSubtitles(node, _parent, _route) {
1037
+ leaf_showSubtitles(node, _route) {
1072
1038
  this.writeProperty('showSubtitles', node.value);
1073
1039
  }
1074
1040
  //
@@ -1077,7 +1043,7 @@ class BitmarkGenerator {
1077
1043
  /**
1078
1044
  * Generate the handlers for properties, as they are mostly the same, but not quite
1079
1045
  */
1080
- // protected enter_labelTrue(node: NodeInfo, parent: NodeInfo | undefined, _route: NodeInfo[],
1046
+ // protected enter_labelTrue(node: NodeInfo, _route: NodeInfo[],
1081
1047
  // ): void {
1082
1048
  // const bit = parent?.value as Bit;
1083
1049
  // if (bit) {
@@ -1109,12 +1075,13 @@ class BitmarkGenerator {
1109
1075
  continue;
1110
1076
  const funcName = `enter_${astKey}`;
1111
1077
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1112
- this[funcName] = (node, parent, _route) => {
1078
+ this[funcName] = (node, route) => {
1113
1079
  const value = node.value;
1114
1080
  if (value == null)
1115
1081
  return;
1116
1082
  // if (propertyConfig.tag === 'progress') debugger;
1117
1083
  // Ignore any property that is not at the bit level as that will be handled by a different handler
1084
+ const parent = this.getParentNode(route);
1118
1085
  if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
1119
1086
  return;
1120
1087
  // Write the property
@@ -1333,6 +1300,9 @@ class BitmarkGenerator {
1333
1300
  }
1334
1301
  this.writeString(tag);
1335
1302
  }
1303
+ //
1304
+ // Helper functions
1305
+ //
1336
1306
  isWriteTextFormat(bitsValue, textFormatDefault) {
1337
1307
  const isDefault = TextFormat_1.TextFormat.fromValue(bitsValue) === textFormatDefault;
1338
1308
  const writeFormat = !isDefault || this.options.explicitTextFormat;
@@ -1354,12 +1324,6 @@ class BitmarkGenerator {
1354
1324
  }
1355
1325
  return undefined;
1356
1326
  }
1357
- getParentNode(route, nodesBack = 1) {
1358
- if (route.length > nodesBack + 1) {
1359
- return route[route.length - nodesBack - 1];
1360
- }
1361
- return undefined;
1362
- }
1363
1327
  //
1364
1328
  // Writer interface
1365
1329
  //