@gmb/bitmark-parser-generator 1.16.0 → 1.17.0

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 (95) 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/Builder.js +1 -1
  4. package/dist/cjs/ast/ResourceBuilder.js +34 -17
  5. package/dist/cjs/ast/ResourceBuilder.js.map +1 -1
  6. package/dist/cjs/config/raw/bits.js +87 -82
  7. package/dist/cjs/config/raw/bits.js.map +1 -1
  8. package/dist/cjs/config/raw/groups.js +4 -0
  9. package/dist/cjs/config/raw/groups.js.map +1 -1
  10. package/dist/cjs/config/raw/properties.js +1 -2
  11. package/dist/cjs/config/raw/properties.js.map +1 -1
  12. package/dist/cjs/generated/build-info.js +1 -1
  13. package/dist/cjs/generated/parser/text/text-peggy-parser.js +1588 -855
  14. package/dist/cjs/generated/parser/text/text-peggy-parser.js.map +1 -1
  15. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +4 -0
  16. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  17. package/dist/cjs/generator/json/JsonGenerator.js +251 -367
  18. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  19. package/dist/cjs/generator/text/TextGenerator.js +98 -19
  20. package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
  21. package/dist/cjs/model/enum/BitType.js +5 -1
  22. package/dist/cjs/model/enum/BitType.js.map +1 -1
  23. package/dist/cjs/model/enum/PropertyAstKey.js +0 -1
  24. package/dist/cjs/model/enum/PropertyAstKey.js.map +1 -1
  25. package/dist/cjs/model/enum/PropertyTag.js +1 -1
  26. package/dist/cjs/model/enum/PropertyTag.js.map +1 -1
  27. package/dist/cjs/model/enum/TextMarkType.js +4 -1
  28. package/dist/cjs/model/enum/TextMarkType.js.map +1 -1
  29. package/dist/cjs/model/enum/TextNodeType.js +4 -0
  30. package/dist/cjs/model/enum/TextNodeType.js.map +1 -1
  31. package/dist/cjs/parser/json/JsonParser.js +50 -38
  32. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  33. package/dist/esm/ast/Builder.js +1 -1
  34. package/dist/esm/ast/ResourceBuilder.js +34 -17
  35. package/dist/esm/ast/ResourceBuilder.js.map +1 -1
  36. package/dist/esm/config/raw/bits.js +87 -82
  37. package/dist/esm/config/raw/bits.js.map +1 -1
  38. package/dist/esm/config/raw/groups.js +4 -0
  39. package/dist/esm/config/raw/groups.js.map +1 -1
  40. package/dist/esm/config/raw/properties.js +1 -2
  41. package/dist/esm/config/raw/properties.js.map +1 -1
  42. package/dist/esm/generated/build-info.js +1 -1
  43. package/dist/esm/generated/parser/text/text-peggy-parser.js +1588 -855
  44. package/dist/esm/generated/parser/text/text-peggy-parser.js.map +1 -1
  45. package/dist/esm/generator/bitmark/BitmarkGenerator.js +4 -0
  46. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  47. package/dist/esm/generator/json/JsonGenerator.js +251 -367
  48. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  49. package/dist/esm/generator/text/TextGenerator.js +98 -19
  50. package/dist/esm/generator/text/TextGenerator.js.map +1 -1
  51. package/dist/esm/model/enum/BitType.js +5 -1
  52. package/dist/esm/model/enum/BitType.js.map +1 -1
  53. package/dist/esm/model/enum/PropertyAstKey.js +0 -1
  54. package/dist/esm/model/enum/PropertyAstKey.js.map +1 -1
  55. package/dist/esm/model/enum/PropertyTag.js +1 -1
  56. package/dist/esm/model/enum/PropertyTag.js.map +1 -1
  57. package/dist/esm/model/enum/TextMarkType.js +4 -1
  58. package/dist/esm/model/enum/TextMarkType.js.map +1 -1
  59. package/dist/esm/model/enum/TextNodeType.js +4 -0
  60. package/dist/esm/model/enum/TextNodeType.js.map +1 -1
  61. package/dist/esm/parser/json/JsonParser.js +50 -38
  62. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  63. package/dist/types/ast/ResourceBuilder.d.ts +18 -0
  64. package/dist/types/ast/ResourceBuilder.d.ts.map +1 -1
  65. package/dist/types/config/raw/bits.d.ts.map +1 -1
  66. package/dist/types/config/raw/groups.d.ts.map +1 -1
  67. package/dist/types/config/raw/properties.d.ts.map +1 -1
  68. package/dist/types/generated/parser/text/text-peggy-parser.d.ts.map +1 -1
  69. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +1 -0
  70. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  71. package/dist/types/generator/json/JsonGenerator.d.ts +0 -2
  72. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  73. package/dist/types/generator/text/TextGenerator.d.ts +12 -3
  74. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  75. package/dist/types/model/ast/Nodes.d.ts +1 -0
  76. package/dist/types/model/ast/Nodes.d.ts.map +1 -1
  77. package/dist/types/model/ast/TextNodes.d.ts +21 -0
  78. package/dist/types/model/ast/TextNodes.d.ts.map +1 -1
  79. package/dist/types/model/enum/BitType.d.ts +10 -2
  80. package/dist/types/model/enum/BitType.d.ts.map +1 -1
  81. package/dist/types/model/enum/PropertyAstKey.d.ts +0 -2
  82. package/dist/types/model/enum/PropertyAstKey.d.ts.map +1 -1
  83. package/dist/types/model/enum/PropertyTag.d.ts +0 -2
  84. package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
  85. package/dist/types/model/enum/TextMarkType.d.ts +6 -2
  86. package/dist/types/model/enum/TextMarkType.d.ts.map +1 -1
  87. package/dist/types/model/enum/TextNodeType.d.ts +8 -0
  88. package/dist/types/model/enum/TextNodeType.d.ts.map +1 -1
  89. package/dist/types/model/json/BitJson.d.ts +1 -23
  90. package/dist/types/model/json/BitJson.d.ts.map +1 -1
  91. package/dist/types/model/json/ResourceJson.d.ts +1 -0
  92. package/dist/types/model/json/ResourceJson.d.ts.map +1 -1
  93. package/dist/types/parser/json/JsonParser.d.ts +1 -0
  94. package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
  95. package/package.json +1 -1
@@ -397,12 +397,8 @@ class JsonGenerator extends AstWalkerGenerator {
397
397
  // Create this list item
398
398
  this.listItem = Object.assign(Object.assign({}, this.toItemLeadHintInstruction(node.value)), { body: this.bodyDefault });
399
399
  // Delete unwanted properties
400
- const nv = node.value;
401
- const li = this.listItem;
402
- if (nv.pageNumber == null)
403
- delete li.pageNumber;
404
- if (nv.marginNumber == null)
405
- delete li.marginNumber;
400
+ // const nv = node.value;
401
+ // const li: Partial<ListItemJson> = this.listItem;
406
402
  listItems.push(this.listItem);
407
403
  }
408
404
  exit_cardBitsValue(_node, _route) {
@@ -552,7 +548,7 @@ class JsonGenerator extends AstWalkerGenerator {
552
548
  }
553
549
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue
554
550
  enter_flashcards(node, route) {
555
- var _a, _b, _c, _d, _e, _f;
551
+ var _a, _b, _c, _d;
556
552
  const flashcards = node.value;
557
553
  // Ignore responses that are not at the correct level as they are potentially handled elsewhere
558
554
  const parent = this.getParentNode(route);
@@ -569,10 +565,6 @@ class JsonGenerator extends AstWalkerGenerator {
569
565
  // Delete unwanted properties
570
566
  if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
571
567
  delete flashcardJson.lead;
572
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
573
- delete flashcardJson.pageNumber;
574
- if (((_f = c.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
575
- delete flashcardJson.marginNumber;
576
568
  flashcardsJson.push(flashcardJson);
577
569
  }
578
570
  }
@@ -595,7 +587,7 @@ class JsonGenerator extends AstWalkerGenerator {
595
587
  }
596
588
  // bitmarkAst -> bits -> bitsValue -> cardNode -> statements -> statementsValue
597
589
  enter_statements(node, route) {
598
- var _a, _b, _c, _d, _e;
590
+ var _a, _b, _c;
599
591
  const statements = node.value;
600
592
  // Ignore statements that are not at the card node level as they are handled elsewhere
601
593
  const parent = this.getParentNode(route);
@@ -614,10 +606,6 @@ class JsonGenerator extends AstWalkerGenerator {
614
606
  delete statementJson.item;
615
607
  if (((_c = s.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
616
608
  delete statementJson.lead;
617
- if (((_d = s.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
618
- delete statementJson.pageNumber;
619
- if (((_e = s.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
620
- delete statementJson.marginNumber;
621
609
  if ((s === null || s === void 0 ? void 0 : s.hint) == null)
622
610
  delete statementJson.hint;
623
611
  if ((s === null || s === void 0 ? void 0 : s.instruction) == null)
@@ -632,7 +620,7 @@ class JsonGenerator extends AstWalkerGenerator {
632
620
  // bitmarkAst -> bits -> bitsValue -> choices
633
621
  // X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices
634
622
  enter_choices(node, route) {
635
- var _a, _b, _c, _d, _e;
623
+ var _a, _b, _c;
636
624
  const choices = node.value;
637
625
  // Ignore choices that are not at the bit level as they are handled elsewhere as quizzes
638
626
  const parent = this.getParentNode(route);
@@ -649,10 +637,6 @@ class JsonGenerator extends AstWalkerGenerator {
649
637
  // Delete unwanted properties
650
638
  if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
651
639
  delete choiceJson.lead;
652
- if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
653
- delete choiceJson.pageNumber;
654
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
655
- delete choiceJson.marginNumber;
656
640
  choicesJson.push(choiceJson);
657
641
  }
658
642
  }
@@ -663,7 +647,7 @@ class JsonGenerator extends AstWalkerGenerator {
663
647
  // bitmarkAst -> bits -> bitsValue -> responses
664
648
  // X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses
665
649
  enter_responses(node, route) {
666
- var _a, _b, _c, _d, _e;
650
+ var _a, _b, _c;
667
651
  const responses = node.value;
668
652
  // Ignore responses that are not at the correct level as they are handled elsewhere as quizzes
669
653
  const parent = this.getParentNode(route);
@@ -680,10 +664,6 @@ class JsonGenerator extends AstWalkerGenerator {
680
664
  // Delete unwanted properties
681
665
  if (((_c = r.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
682
666
  delete responseJson.lead;
683
- if (((_d = r.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
684
- delete responseJson.pageNumber;
685
- if (((_e = r.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
686
- delete responseJson.marginNumber;
687
667
  responsesJson.push(responseJson);
688
668
  }
689
669
  }
@@ -693,7 +673,7 @@ class JsonGenerator extends AstWalkerGenerator {
693
673
  }
694
674
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes
695
675
  enter_quizzes(node, _route) {
696
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
676
+ var _a, _b, _c, _d, _e, _f, _g, _h;
697
677
  const quizzes = node.value;
698
678
  const quizzesJson = [];
699
679
  if (quizzes) {
@@ -710,10 +690,6 @@ class JsonGenerator extends AstWalkerGenerator {
710
690
  // Delete unwanted properties
711
691
  if (((_c = q.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
712
692
  delete choiceJson.lead;
713
- if (((_d = q.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
714
- delete choiceJson.pageNumber;
715
- if (((_e = q.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
716
- delete choiceJson.marginNumber;
717
693
  choicesJson.push(choiceJson);
718
694
  }
719
695
  }
@@ -722,29 +698,21 @@ class JsonGenerator extends AstWalkerGenerator {
722
698
  if (q.responses) {
723
699
  for (const r of q.responses) {
724
700
  // Create the choice
725
- const responseJson = Object.assign(Object.assign({ response: (_f = Breakscape.unbreakscape(r.text)) !== null && _f !== void 0 ? _f : '', isCorrect: (_g = r.isCorrect) !== null && _g !== void 0 ? _g : false }, this.toItemLeadHintInstruction(r)), this.toExample(r, {
701
+ const responseJson = Object.assign(Object.assign({ response: (_d = Breakscape.unbreakscape(r.text)) !== null && _d !== void 0 ? _d : '', isCorrect: (_e = r.isCorrect) !== null && _e !== void 0 ? _e : false }, this.toItemLeadHintInstruction(r)), this.toExample(r, {
726
702
  defaultExample: !!r.isCorrect,
727
703
  isBoolean: true,
728
704
  }));
729
705
  // Delete unwanted properties
730
- if (((_h = q.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
706
+ if (((_f = q.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
731
707
  delete responseJson.lead;
732
- if (((_j = q.itemLead) === null || _j === void 0 ? void 0 : _j.pageNumber) == null)
733
- delete responseJson.pageNumber;
734
- if (((_k = q.itemLead) === null || _k === void 0 ? void 0 : _k.marginNumber) == null)
735
- delete responseJson.marginNumber;
736
708
  responsesJson.push(responseJson);
737
709
  }
738
710
  }
739
711
  // Create the quiz
740
- const quizJson = Object.assign(Object.assign({}, this.toItemLeadHintInstruction(q)), { isExample: (_l = q.isExample) !== null && _l !== void 0 ? _l : false, choices: q.choices ? choicesJson : undefined, responses: q.responses ? responsesJson : undefined });
712
+ const quizJson = Object.assign(Object.assign({}, this.toItemLeadHintInstruction(q)), { isExample: (_g = q.isExample) !== null && _g !== void 0 ? _g : false, choices: q.choices ? choicesJson : undefined, responses: q.responses ? responsesJson : undefined });
741
713
  // Delete unwanted properties
742
- if (((_m = q.itemLead) === null || _m === void 0 ? void 0 : _m.lead) == null)
714
+ if (((_h = q.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
743
715
  delete quizJson.lead;
744
- if (((_o = q.itemLead) === null || _o === void 0 ? void 0 : _o.pageNumber) == null)
745
- delete quizJson.pageNumber;
746
- if (((_p = q.itemLead) === null || _p === void 0 ? void 0 : _p.marginNumber) == null)
747
- delete quizJson.marginNumber;
748
716
  quizzesJson.push(quizJson);
749
717
  }
750
718
  }
@@ -785,7 +753,7 @@ class JsonGenerator extends AstWalkerGenerator {
785
753
  }
786
754
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
787
755
  enter_pairs(node, route) {
788
- var _a, _b, _c, _d, _e, _f;
756
+ var _a, _b, _c, _d;
789
757
  const pairs = node.value;
790
758
  const pairsJson = [];
791
759
  const bitType = this.getBitType(route);
@@ -801,10 +769,6 @@ class JsonGenerator extends AstWalkerGenerator {
801
769
  // Delete unwanted properties
802
770
  if (((_d = p.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
803
771
  delete pairJson.lead;
804
- if (((_e = p.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
805
- delete pairJson.pageNumber;
806
- if (((_f = p.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
807
- delete pairJson.marginNumber;
808
772
  if (pairJson.key) {
809
773
  delete pairJson.keyAudio;
810
774
  delete pairJson.keyImage;
@@ -826,7 +790,7 @@ class JsonGenerator extends AstWalkerGenerator {
826
790
  }
827
791
  // bitmarkAst -> bits -> bitsValue -> cardNode -> matrix
828
792
  enter_matrix(node, _route) {
829
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
793
+ var _a, _b, _c, _d, _e, _f;
830
794
  const matrix = node.value;
831
795
  const matrixJsonArray = [];
832
796
  if (matrix) {
@@ -845,26 +809,18 @@ class JsonGenerator extends AstWalkerGenerator {
845
809
  // Delete unwanted properties
846
810
  if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
847
811
  delete matrixCellJson.lead;
848
- if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
849
- delete matrixCellJson.pageNumber;
850
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
851
- delete matrixCellJson.marginNumber;
852
812
  if (c.hint == null)
853
813
  delete matrixCellJson.hint;
854
814
  matrixCellsJson.push(matrixCellJson);
855
815
  }
856
816
  }
857
817
  // Create the matrix
858
- const matrixJson = Object.assign(Object.assign({ key: (_f = Breakscape.unbreakscape(m.key)) !== null && _f !== void 0 ? _f : '', cells: matrixCellsJson !== null && matrixCellsJson !== void 0 ? matrixCellsJson : [] }, this.toItemLeadHintInstruction(m)), {
818
+ const matrixJson = Object.assign(Object.assign({ key: (_d = Breakscape.unbreakscape(m.key)) !== null && _d !== void 0 ? _d : '', cells: matrixCellsJson !== null && matrixCellsJson !== void 0 ? matrixCellsJson : [] }, this.toItemLeadHintInstruction(m)), {
859
819
  // ...this.toExample(m.example, m.isExample),
860
- isExample: (_g = m.isExample) !== null && _g !== void 0 ? _g : false });
820
+ isExample: (_e = m.isExample) !== null && _e !== void 0 ? _e : false });
861
821
  // Delete unwanted properties
862
- if (((_h = m.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
822
+ if (((_f = m.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
863
823
  delete matrixJson.lead;
864
- if (((_j = m.itemLead) === null || _j === void 0 ? void 0 : _j.pageNumber) == null)
865
- delete matrixJson.pageNumber;
866
- if (((_k = m.itemLead) === null || _k === void 0 ? void 0 : _k.marginNumber) == null)
867
- delete matrixJson.marginNumber;
868
824
  if (m.instruction == null)
869
825
  delete matrixJson.instruction;
870
826
  matrixJsonArray.push(matrixJson);
@@ -887,7 +843,7 @@ class JsonGenerator extends AstWalkerGenerator {
887
843
  }
888
844
  // bitmarkAst -> bits -> bitsValue -> cardNode -> questions
889
845
  enter_questions(node, _route) {
890
- var _a, _b, _c, _d, _e, _f;
846
+ var _a, _b, _c, _d;
891
847
  const questions = node.value;
892
848
  const questionsJson = [];
893
849
  if (questions) {
@@ -900,10 +856,6 @@ class JsonGenerator extends AstWalkerGenerator {
900
856
  // Delete unwanted properties
901
857
  if (((_d = q.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
902
858
  delete questionJson.lead;
903
- if (((_e = q.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
904
- delete questionJson.pageNumber;
905
- if (((_f = q.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
906
- delete questionJson.marginNumber;
907
859
  questionsJson.push(questionJson);
908
860
  }
909
861
  }
@@ -913,7 +865,7 @@ class JsonGenerator extends AstWalkerGenerator {
913
865
  }
914
866
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses
915
867
  enter_botResponses(node, route) {
916
- var _a, _b, _c, _d, _e, _f;
868
+ var _a, _b, _c, _d;
917
869
  const botResponses = node.value;
918
870
  // Ignore responses that are not at the cardNode level as they are handled elsewhere
919
871
  const parent = this.getParentNode(route);
@@ -927,10 +879,6 @@ class JsonGenerator extends AstWalkerGenerator {
927
879
  // Delete unwanted properties
928
880
  if (((_d = r.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
929
881
  delete responseJson.lead;
930
- if (((_e = r.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
931
- delete responseJson.pageNumber;
932
- if (((_f = r.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
933
- delete responseJson.marginNumber;
934
882
  if (r.hint == null)
935
883
  delete responseJson.hint;
936
884
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1252,8 +1200,6 @@ class JsonGenerator extends AstWalkerGenerator {
1252
1200
  })), { solutions: Breakscape.unbreakscape(data.solutions) });
1253
1201
  // Remove unwanted properties
1254
1202
  // if (!data.itemLead?.lead) delete gapJson.lead;
1255
- // if (!data.itemLead?.pageNumber) delete gapJson.pageNumber;
1256
- // if (!data.itemLead?.marginNumber) delete gapJson.marginNumber;
1257
1203
  return gapJson;
1258
1204
  }
1259
1205
  createMarkJson(mark) {
@@ -1265,8 +1211,6 @@ class JsonGenerator extends AstWalkerGenerator {
1265
1211
  }));
1266
1212
  // Remove unwanted properties
1267
1213
  // if (!data.itemLead?.lead) delete markJson.lead;
1268
- // if (!data.itemLead?.pageNumber) delete markJson.pageNumber;
1269
- // if (!data.itemLead?.marginNumber) delete markJson.marginNumber;
1270
1214
  return markJson;
1271
1215
  }
1272
1216
  createSelectJson(select) {
@@ -1282,8 +1226,6 @@ class JsonGenerator extends AstWalkerGenerator {
1282
1226
  // Remove unwanted properties
1283
1227
  // if (!option.itemLead?.item) delete optionJson.item;
1284
1228
  // if (!option.itemLead?.lead) delete optionJson.lead;
1285
- // if (!option.itemLead?.pageNumber) delete optionJson.pageNumber;
1286
- // if (!option.itemLead?.marginNumber) delete optionJson.marginNumber;
1287
1229
  // if (!option.instruction) delete optionJson.instruction;
1288
1230
  options.push(optionJson);
1289
1231
  }
@@ -1291,8 +1233,6 @@ class JsonGenerator extends AstWalkerGenerator {
1291
1233
  const selectJson = Object.assign(Object.assign({ type: 'select', prefix: (_b = Breakscape.unbreakscape(data.prefix)) !== null && _b !== void 0 ? _b : '', postfix: (_c = Breakscape.unbreakscape(data.postfix)) !== null && _c !== void 0 ? _c : '' }, this.toItemLeadHintInstruction(data)), { isExample: (_d = data.isExample) !== null && _d !== void 0 ? _d : false, options });
1292
1234
  // Remove unwanted properties
1293
1235
  // if (!data.itemLead?.lead) delete selectJson.lead;
1294
- // if (!data.itemLead?.pageNumber) delete selectJson.pageNumber;
1295
- // if (!data.itemLead?.marginNumber) delete selectJson.marginNumber;
1296
1236
  return selectJson;
1297
1237
  }
1298
1238
  createHighlightJson(highlight) {
@@ -1308,8 +1248,6 @@ class JsonGenerator extends AstWalkerGenerator {
1308
1248
  // Remove unwanted properties
1309
1249
  // if (!text.itemLead?.item) delete textJson.item;
1310
1250
  // if (!text.itemLead?.lead) delete textJson.lead;
1311
- // if (!text.itemLead?.pageNumber) delete textJson.pageNumber;
1312
- // if (!text.itemLead?.marginNumber) delete textJson.marginNumber;
1313
1251
  // if (!text.hint) delete textJson.hint;
1314
1252
  texts.push(textJson);
1315
1253
  }
@@ -1811,7 +1749,7 @@ class JsonGenerator extends AstWalkerGenerator {
1811
1749
  return resourceJson;
1812
1750
  }
1813
1751
  addGenericResourceProperties(_bitType, resource, resourceJson, noDefaults) {
1814
- var _a, _b, _c, _d, _e, _f, _g, _h;
1752
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1815
1753
  if (noDefaults) {
1816
1754
  if (resource.license != null)
1817
1755
  resourceJson.license = (_a = Breakscape.unbreakscape(resource.license)) !== null && _a !== void 0 ? _a : '';
@@ -1821,28 +1759,31 @@ class JsonGenerator extends AstWalkerGenerator {
1821
1759
  resourceJson.provider = Breakscape.unbreakscape(resource.provider);
1822
1760
  if (resource.showInIndex != null)
1823
1761
  resourceJson.showInIndex = (_c = resource.showInIndex) !== null && _c !== void 0 ? _c : false;
1824
- if (resource.caption != null)
1762
+ if (resource.caption != null) {
1825
1763
  resourceJson.caption = this.convertBreakscapedStringToJsonText((_d = resource.caption) !== null && _d !== void 0 ? _d : '', TextFormat.bitmarkMinusMinus);
1764
+ }
1765
+ if (resource.search != null)
1766
+ resourceJson.search = (_e = Breakscape.unbreakscape(resource.search)) !== null && _e !== void 0 ? _e : '';
1826
1767
  }
1827
1768
  else {
1828
- resourceJson.license = (_e = Breakscape.unbreakscape(resource.license)) !== null && _e !== void 0 ? _e : '';
1829
- resourceJson.copyright = (_f = Breakscape.unbreakscape(resource.copyright)) !== null && _f !== void 0 ? _f : '';
1769
+ resourceJson.license = (_f = Breakscape.unbreakscape(resource.license)) !== null && _f !== void 0 ? _f : '';
1770
+ resourceJson.copyright = (_g = Breakscape.unbreakscape(resource.copyright)) !== null && _g !== void 0 ? _g : '';
1830
1771
  if (resource.provider != null)
1831
1772
  resourceJson.provider = Breakscape.unbreakscape(resource.provider);
1832
- resourceJson.showInIndex = (_g = resource.showInIndex) !== null && _g !== void 0 ? _g : false;
1833
- resourceJson.caption = this.convertBreakscapedStringToJsonText((_h = resource.caption) !== null && _h !== void 0 ? _h : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus);
1773
+ resourceJson.showInIndex = (_h = resource.showInIndex) !== null && _h !== void 0 ? _h : false;
1774
+ resourceJson.caption = this.convertBreakscapedStringToJsonText((_j = resource.caption) !== null && _j !== void 0 ? _j : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus);
1775
+ if (resource.search != null)
1776
+ resourceJson.search = (_k = Breakscape.unbreakscape(resource.search)) !== null && _k !== void 0 ? _k : '';
1834
1777
  }
1835
1778
  return resourceJson;
1836
1779
  }
1837
1780
  toItemLeadHintInstruction(item) {
1838
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1781
+ var _a, _b, _c, _d, _e, _f;
1839
1782
  return {
1840
1783
  item: this.convertBreakscapedStringToJsonText((_b = (_a = item.itemLead) === null || _a === void 0 ? void 0 : _a.item) !== null && _b !== void 0 ? _b : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1841
1784
  lead: this.convertBreakscapedStringToJsonText((_d = (_c = item.itemLead) === null || _c === void 0 ? void 0 : _c.lead) !== null && _d !== void 0 ? _d : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1842
- pageNumber: this.convertBreakscapedStringToJsonText((_f = (_e = item.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) !== null && _f !== void 0 ? _f : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1843
- marginNumber: this.convertBreakscapedStringToJsonText((_h = (_g = item.itemLead) === null || _g === void 0 ? void 0 : _g.marginNumber) !== null && _h !== void 0 ? _h : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1844
- hint: this.convertBreakscapedStringToJsonText((_j = item.hint) !== null && _j !== void 0 ? _j : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1845
- instruction: this.convertBreakscapedStringToJsonText((_k = item.instruction) !== null && _k !== void 0 ? _k : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1785
+ hint: this.convertBreakscapedStringToJsonText((_e = item.hint) !== null && _e !== void 0 ? _e : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1786
+ instruction: this.convertBreakscapedStringToJsonText((_f = item.instruction) !== null && _f !== void 0 ? _f : Breakscape.EMPTY_STRING, TextFormat.bitmarkMinusMinus),
1846
1787
  };
1847
1788
  }
1848
1789
  toExample(node, options) {
@@ -2091,7 +2032,7 @@ class JsonGenerator extends AstWalkerGenerator {
2091
2032
  jupyterId: undefined,
2092
2033
  jupyterExecutionCount: undefined,
2093
2034
  isPublic: undefined,
2094
- AIGenerated: undefined,
2035
+ aiGenerated: undefined,
2095
2036
  analyticsTag: undefined,
2096
2037
  feedbackEngine: undefined,
2097
2038
  disableFeedback: undefined,
@@ -2281,284 +2222,209 @@ class JsonGenerator extends AstWalkerGenerator {
2281
2222
  // The properties used are a bit random sometimes?
2282
2223
  // It would be better if this functionality was generated from the bit config
2283
2224
  if (Config.isOfBitType(bitType, [BitType._error, BitType._comment])) {
2284
- //
2225
+ // Special caes for _error and _comment bits
2285
2226
  delete bitJson.format;
2286
2227
  //
2287
2228
  }
2288
- else if (Config.isOfBitType(bitType, [BitType.article, BitType.sampleSolution, BitType.page])) {
2289
- //
2290
- if (bitJson.body == null)
2291
- bitJson.body = this.bodyDefault;
2292
- //
2293
- }
2294
- else if (Config.isOfBitType(bitType, [
2295
- BitType.multipleChoice1,
2296
- BitType.multipleResponse1,
2297
- BitType.multipleChoiceText,
2298
- BitType.highlightText,
2299
- BitType.clozeAndMultipleChoiceText,
2300
- BitType.sequence,
2301
- BitType.mark,
2302
- BitType.flashcard,
2303
- ])) {
2304
- // Default, but with no 'example' at the bit level.
2305
- if (bitJson.item == null)
2306
- bitJson.item = this.textDefault;
2307
- if (bitJson.hint == null)
2308
- bitJson.hint = this.textDefault;
2309
- if (bitJson.instruction == null)
2310
- bitJson.instruction = this.textDefault;
2311
- if (bitJson.isExample == null)
2312
- bitJson.isExample = false;
2313
- if (bitJson.body == null)
2314
- bitJson.body = this.bodyDefault;
2315
- //
2316
- }
2317
- else if (Config.isOfBitType(bitType, BitType.cloze)) {
2318
- // Default, but with no 'example' at the bit level.
2319
- if (bitJson.item == null)
2320
- bitJson.item = this.textDefault;
2321
- if (bitJson.hint == null)
2322
- bitJson.hint = this.textDefault;
2323
- if (bitJson.instruction == null)
2324
- bitJson.instruction = this.textDefault;
2325
- if (bitJson.isExample == null)
2326
- bitJson.isExample = false;
2327
- if (bitJson.body == null)
2328
- bitJson.body = this.bodyDefault;
2329
- if (Config.isOfBitType(bitType, BitType.clozeSolutionGrouped)) {
2330
- // Solution grouped
2331
- if (bitJson.quizCountItems == null)
2332
- bitJson.quizCountItems = true;
2333
- if (bitJson.quizStrikethroughSolutions == null)
2334
- bitJson.quizStrikethroughSolutions = true;
2335
- }
2336
- else if (Config.isOfBitType(bitType, BitType.clozeInstructionGrouped)) {
2337
- // Instruction grouped
2338
- if (bitJson.quizCountItems == null)
2339
- bitJson.quizCountItems = true;
2340
- if (bitJson.quizStrikethroughSolutions == null)
2341
- bitJson.quizStrikethroughSolutions = false;
2342
- }
2343
- //
2344
- }
2345
- else if (Config.isOfBitType(bitType, [BitType.multipleChoice, BitType.multipleResponse])) {
2346
- // Default with a card (and hence a footer possibility)
2347
- if (bitJson.item == null)
2348
- bitJson.item = this.textDefault;
2349
- if (bitJson.hint == null)
2350
- bitJson.hint = this.textDefault;
2351
- if (bitJson.instruction == null)
2352
- bitJson.instruction = this.textDefault;
2353
- if (bitJson.isExample == null)
2354
- bitJson.isExample = false;
2355
- if (bitJson.body == null)
2356
- bitJson.body = this.bodyDefault;
2357
- if (bitJson.footer == null)
2358
- bitJson.footer = this.textDefault;
2359
- //
2360
- }
2361
- else if (Config.isOfBitType(bitType, BitType.essay)) {
2362
- //
2363
- if (bitJson.item == null)
2364
- bitJson.item = this.textDefault;
2365
- if (bitJson.hint == null)
2366
- bitJson.hint = this.textDefault;
2367
- if (bitJson.instruction == null)
2368
- bitJson.instruction = this.textDefault;
2369
- if (bitJson.isExample == null)
2370
- bitJson.isExample = false;
2371
- if (bitJson.example == null)
2372
- bitJson.example = null;
2373
- if (bitJson.body == null)
2374
- bitJson.body = this.bodyDefault;
2375
- if (bitJson.partialAnswer == null)
2376
- bitJson.partialAnswer = '';
2377
- // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2378
- //
2379
- }
2380
- else if (Config.isOfBitType(bitType, BitType.trueFalse1)) {
2381
- //
2382
- if (bitJson.item == null)
2383
- bitJson.item = this.textDefault;
2384
- if (bitJson.lead == null)
2385
- bitJson.lead = this.textDefault;
2386
- if (bitJson.hint == null)
2387
- bitJson.hint = this.textDefault;
2388
- if (bitJson.instruction == null)
2389
- bitJson.instruction = this.textDefault;
2390
- if (bitJson.isExample == null)
2391
- bitJson.isExample = false;
2392
- if (bitJson.example == null)
2393
- bitJson.example = null;
2394
- if (bitJson.isCorrect == null)
2395
- bitJson.isCorrect = false;
2396
- if (bitJson.body == null)
2397
- bitJson.body = this.bodyDefault;
2398
- //
2399
- }
2400
- else if (Config.isOfBitType(bitType, BitType.trueFalse)) {
2401
- //
2402
- if (bitJson.item == null)
2403
- bitJson.item = this.textDefault;
2404
- if (bitJson.lead == null)
2405
- bitJson.lead = this.textDefault;
2406
- if (bitJson.hint == null)
2407
- bitJson.hint = this.textDefault;
2408
- if (bitJson.instruction == null)
2409
- bitJson.instruction = this.textDefault;
2410
- if (bitJson.isExample == null)
2411
- bitJson.isExample = false;
2412
- if (bitJson.labelFalse == null)
2413
- bitJson.labelFalse = '';
2414
- if (bitJson.labelTrue == null)
2415
- bitJson.labelTrue = '';
2416
- if (bitJson.body == null)
2417
- bitJson.body = this.bodyDefault;
2418
- //
2419
- }
2420
- else if (Config.isOfBitType(bitType, BitType.chapter)) {
2421
- //
2422
- if (bitJson.item == null)
2423
- bitJson.item = this.textDefault;
2424
- if (bitJson.hint == null)
2425
- bitJson.hint = this.textDefault;
2426
- if (bitJson.isExample == null)
2427
- bitJson.isExample = false;
2428
- if (bitJson.example == null)
2429
- bitJson.example = null;
2430
- if (bitJson.toc == null)
2431
- bitJson.toc = true; // Always set on chapter bits?
2432
- if (bitJson.progress == null)
2433
- bitJson.progress = true; // Always set on chapter bits
2434
- if (bitJson.level == null)
2435
- bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2436
- if (bitJson.body == null)
2437
- bitJson.body = this.bodyDefault;
2438
- //
2439
- }
2440
- else if (Config.isOfBitType(bitType, BitType.interview)) {
2441
- //
2442
- if (bitJson.item == null)
2443
- bitJson.item = this.textDefault;
2444
- if (bitJson.hint == null)
2445
- bitJson.hint = this.textDefault;
2446
- if (bitJson.instruction == null)
2447
- bitJson.instruction = this.textDefault;
2448
- if (bitJson.isExample == null)
2449
- bitJson.isExample = false;
2450
- if (bitJson.body == null)
2451
- bitJson.body = this.bodyDefault;
2452
- if (bitJson.footer == null)
2453
- bitJson.footer = this.textDefault;
2454
- if (bitJson.questions == null)
2455
- bitJson.questions = [];
2456
- //
2457
- }
2458
- else if (bitType === BitType.matchMatrix) {
2459
- //
2460
- if (bitJson.item == null)
2461
- bitJson.item = this.textDefault;
2462
- if (bitJson.body == null)
2463
- bitJson.body = this.bodyDefault;
2464
- //
2465
- }
2466
- else if (Config.isOfBitType(bitType, BitType.match)) {
2467
- //
2468
- if (bitJson.item == null)
2469
- bitJson.item = this.textDefault;
2470
- if (bitJson.heading == null)
2471
- bitJson.heading = {};
2472
- if (bitJson.body == null)
2473
- bitJson.body = this.bodyDefault;
2474
- //
2475
- }
2476
- else if (Config.isOfBitType(bitType, BitType.learningPathBook)) {
2477
- //
2478
- if (bitJson.item == null)
2479
- bitJson.item = this.textDefault;
2480
- if (bitJson.hint == null)
2481
- bitJson.hint = this.textDefault;
2482
- if (bitJson.isExample == null)
2483
- bitJson.isExample = false;
2484
- if (bitJson.example == null)
2485
- bitJson.example = null;
2486
- if (bitJson.isTracked == null)
2487
- bitJson.isTracked = true;
2488
- if (bitJson.isInfoOnly == null)
2489
- bitJson.isInfoOnly = false;
2490
- if (bitJson.body == null)
2491
- bitJson.body = this.bodyDefault;
2492
- //
2493
- }
2494
- else if (Config.isOfBitType(bitType, BitType.table)) {
2495
- //
2496
- // if (bitJson.content2Buy == null) bitJson.content2Buy = '';
2497
- if (bitJson.tableFixedHeader == null)
2498
- bitJson.tableFixedHeader = false;
2499
- if (bitJson.tableSearch == null)
2500
- bitJson.tableSearch = false;
2501
- if (bitJson.tableSort == null)
2502
- bitJson.tableSort = false;
2503
- if (bitJson.tablePagination == null)
2504
- bitJson.tablePagination = false;
2505
- if (bitJson.tablePaginationLimit == null)
2506
- bitJson.tablePaginationLimit = 0;
2507
- if (bitJson.tableHeight == null)
2508
- bitJson.tableHeight = 0;
2509
- if (bitJson.tableWhitespaceNoWrap == null)
2510
- bitJson.tableWhitespaceNoWrap = true;
2511
- if (bitJson.tableAutoWidth == null)
2512
- bitJson.tableAutoWidth = true;
2513
- if (bitJson.tableResizableColumns == null)
2514
- bitJson.tableResizableColumns = false;
2515
- if (bitJson.body == null)
2516
- bitJson.body = this.bodyDefault;
2517
- //
2518
- }
2519
- else if (Config.isOfBitType(bitType, BitType.pageBanner) ||
2520
- Config.isOfBitType(bitType, BitType.pageBuyButton) ||
2521
- Config.isOfBitType(bitType, BitType.pageBuyButtonPromotion) ||
2522
- Config.isOfBitType(bitType, BitType.pageFooter) ||
2523
- Config.isOfBitType(bitType, BitType.pageOpenBook) ||
2524
- Config.isOfBitType(bitType, BitType.pagePerson) ||
2525
- Config.isOfBitType(bitType, BitType.pageProduct) ||
2526
- Config.isOfBitType(bitType, BitType.pageProductList) ||
2527
- Config.isOfBitType(bitType, BitType.pageProductVideo) ||
2528
- Config.isOfBitType(bitType, BitType.pageProductVideoList) ||
2529
- Config.isOfBitType(bitType, BitType.pageSectionFolder) ||
2530
- Config.isOfBitType(bitType, BitType.pageSubscribe) ||
2531
- Config.isOfBitType(bitType, BitType.pageSubpage)) {
2532
- //
2533
- if (bitJson.slug == null)
2534
- bitJson.slug = '';
2535
- if (bitJson.item == null)
2536
- bitJson.item = this.textDefault;
2537
- if (bitJson.hint == null)
2538
- bitJson.hint = this.textDefault;
2539
- if (bitJson.isExample == null)
2540
- bitJson.isExample = false;
2541
- if (bitJson.example == null)
2542
- bitJson.example = null;
2543
- if (bitJson.body == null)
2544
- bitJson.body = this.bodyDefault;
2545
- if (Config.isOfBitType(bitType, BitType.pageBuyButton)) {
2546
- if (bitJson.content2Buy == null)
2547
- bitJson.content2Buy = '';
2548
- }
2549
- }
2550
2229
  else {
2230
+ let isTopLevelExample = false;
2231
+ let isTopLevelExampleValue = false;
2551
2232
  // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2552
- if (bitJson.item == null)
2553
- bitJson.item = this.textDefault;
2554
- if (bitJson.hint == null)
2555
- bitJson.hint = this.textDefault;
2556
- if (bitJson.isExample == null)
2557
- bitJson.isExample = false;
2558
- if (bitJson.example == null)
2559
- bitJson.example = null;
2233
+ if (Config.isOfBitType(bitType, [BitType.page])) {
2234
+ // Bits without item, lead, etc
2235
+ }
2236
+ else {
2237
+ // Majority of bits
2238
+ if (bitJson.item == null)
2239
+ bitJson.item = this.textDefault;
2240
+ if (bitJson.lead == null)
2241
+ bitJson.lead = this.textDefault;
2242
+ if (bitJson.hint == null)
2243
+ bitJson.hint = this.textDefault;
2244
+ if (bitJson.instruction == null)
2245
+ bitJson.instruction = this.textDefault;
2246
+ if (bitJson.pageNumber == null)
2247
+ bitJson.pageNumber = this.textDefault;
2248
+ if (bitJson.marginNumber == null)
2249
+ bitJson.marginNumber = this.textDefault;
2250
+ }
2560
2251
  if (bitJson.body == null)
2561
2252
  bitJson.body = this.bodyDefault;
2253
+ if (Config.isOfBitType(bitType, [BitType.article])) {
2254
+ //
2255
+ }
2256
+ if (Config.isOfBitType(bitType, [BitType.example])) {
2257
+ // With 'example' value at the bit level.
2258
+ isTopLevelExample = true;
2259
+ isTopLevelExampleValue = true;
2260
+ }
2261
+ if (Config.isOfBitType(bitType, [
2262
+ BitType.multipleChoice1,
2263
+ BitType.multipleResponse1,
2264
+ BitType.multipleChoiceText,
2265
+ BitType.highlightText,
2266
+ BitType.gapText,
2267
+ BitType.gapTextInstructionGrouped,
2268
+ BitType.clozeAndMultipleChoiceText,
2269
+ BitType.sequence,
2270
+ BitType.mark,
2271
+ BitType.flashcard,
2272
+ ])) {
2273
+ // With no 'example' value at the bit level.
2274
+ isTopLevelExample = true;
2275
+ if (bitJson.body == null)
2276
+ bitJson.body = this.bodyDefault;
2277
+ }
2278
+ if (Config.isOfBitType(bitType, [BitType.sequence])) {
2279
+ // With 'example' value at the bit level.
2280
+ isTopLevelExample = true;
2281
+ isTopLevelExampleValue = true;
2282
+ if (bitJson.body == null)
2283
+ bitJson.body = this.bodyDefault;
2284
+ }
2285
+ if (Config.isOfBitType(bitType, BitType.cloze)) {
2286
+ // With no 'example' value at the bit level.
2287
+ isTopLevelExample = true;
2288
+ if (Config.isOfBitType(bitType, BitType.clozeSolutionGrouped)) {
2289
+ // Solution grouped
2290
+ if (bitJson.quizCountItems == null)
2291
+ bitJson.quizCountItems = true;
2292
+ if (bitJson.quizStrikethroughSolutions == null)
2293
+ bitJson.quizStrikethroughSolutions = true;
2294
+ }
2295
+ else if (Config.isOfBitType(bitType, BitType.clozeInstructionGrouped)) {
2296
+ // Instruction grouped
2297
+ if (bitJson.quizCountItems == null)
2298
+ bitJson.quizCountItems = true;
2299
+ if (bitJson.quizStrikethroughSolutions == null)
2300
+ bitJson.quizStrikethroughSolutions = false;
2301
+ }
2302
+ }
2303
+ if (Config.isOfBitType(bitType, [BitType.multipleChoice, BitType.multipleResponse])) {
2304
+ // Default with a card (and hence a footer possibility)
2305
+ isTopLevelExample = true;
2306
+ if (bitJson.body == null)
2307
+ bitJson.body = this.bodyDefault;
2308
+ if (bitJson.footer == null)
2309
+ bitJson.footer = this.textDefault;
2310
+ }
2311
+ if (Config.isOfBitType(bitType, BitType.essay)) {
2312
+ // With 'example' value at the bit level.
2313
+ isTopLevelExample = true;
2314
+ isTopLevelExampleValue = true;
2315
+ if (bitJson.body == null)
2316
+ bitJson.body = this.bodyDefault;
2317
+ if (bitJson.partialAnswer == null)
2318
+ bitJson.partialAnswer = '';
2319
+ // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2320
+ }
2321
+ if (Config.isOfBitType(bitType, BitType.trueFalse1)) {
2322
+ // With 'example' value at the bit level.
2323
+ isTopLevelExample = true;
2324
+ isTopLevelExampleValue = true;
2325
+ if (bitJson.isCorrect == null)
2326
+ bitJson.isCorrect = false;
2327
+ if (bitJson.body == null)
2328
+ bitJson.body = this.bodyDefault;
2329
+ }
2330
+ if (Config.isOfBitType(bitType, BitType.trueFalse)) {
2331
+ // With no 'example' value at the bit level.
2332
+ isTopLevelExample = true;
2333
+ if (bitJson.labelFalse == null)
2334
+ bitJson.labelFalse = '';
2335
+ if (bitJson.labelTrue == null)
2336
+ bitJson.labelTrue = '';
2337
+ if (bitJson.body == null)
2338
+ bitJson.body = this.bodyDefault;
2339
+ }
2340
+ if (Config.isOfBitType(bitType, BitType.chapter)) {
2341
+ //
2342
+ if (bitJson.toc == null)
2343
+ bitJson.toc = true; // Always set on chapter bits?
2344
+ if (bitJson.progress == null)
2345
+ bitJson.progress = true; // Always set on chapter bits
2346
+ if (bitJson.level == null)
2347
+ bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2348
+ if (bitJson.body == null)
2349
+ bitJson.body = this.bodyDefault;
2350
+ //
2351
+ }
2352
+ if (Config.isOfBitType(bitType, BitType.interview)) {
2353
+ // With no 'example' value at the bit level.
2354
+ isTopLevelExample = true;
2355
+ if (bitJson.body == null)
2356
+ bitJson.body = this.bodyDefault;
2357
+ if (bitJson.footer == null)
2358
+ bitJson.footer = this.textDefault;
2359
+ if (bitJson.questions == null)
2360
+ bitJson.questions = [];
2361
+ }
2362
+ if (bitType === BitType.matchMatrix) {
2363
+ // With no 'example' value at the bit level.
2364
+ isTopLevelExample = true;
2365
+ }
2366
+ if (Config.isOfBitType(bitType, BitType.match)) {
2367
+ // With no 'example' value at the bit level.
2368
+ isTopLevelExample = true;
2369
+ if (bitJson.heading == null)
2370
+ bitJson.heading = {};
2371
+ }
2372
+ if (Config.isOfBitType(bitType, BitType.learningPathBook)) {
2373
+ //
2374
+ if (bitJson.isTracked == null)
2375
+ bitJson.isTracked = true;
2376
+ if (bitJson.isInfoOnly == null)
2377
+ bitJson.isInfoOnly = false;
2378
+ //
2379
+ }
2380
+ if (Config.isOfBitType(bitType, BitType.table)) {
2381
+ //
2382
+ // if (bitJson.content2Buy == null) bitJson.content2Buy = '';
2383
+ if (bitJson.tableFixedHeader == null)
2384
+ bitJson.tableFixedHeader = false;
2385
+ if (bitJson.tableSearch == null)
2386
+ bitJson.tableSearch = false;
2387
+ if (bitJson.tableSort == null)
2388
+ bitJson.tableSort = false;
2389
+ if (bitJson.tablePagination == null)
2390
+ bitJson.tablePagination = false;
2391
+ if (bitJson.tablePaginationLimit == null)
2392
+ bitJson.tablePaginationLimit = 0;
2393
+ if (bitJson.tableHeight == null)
2394
+ bitJson.tableHeight = 0;
2395
+ if (bitJson.tableWhitespaceNoWrap == null)
2396
+ bitJson.tableWhitespaceNoWrap = true;
2397
+ if (bitJson.tableAutoWidth == null)
2398
+ bitJson.tableAutoWidth = true;
2399
+ if (bitJson.tableResizableColumns == null)
2400
+ bitJson.tableResizableColumns = false;
2401
+ //
2402
+ }
2403
+ if (Config.isOfBitType(bitType, [
2404
+ BitType.pageBanner,
2405
+ BitType.pageBuyButton,
2406
+ BitType.pageBuyButtonPromotion,
2407
+ BitType.pageFooter,
2408
+ BitType.pageOpenBook,
2409
+ BitType.pagePerson,
2410
+ BitType.pageProduct,
2411
+ BitType.pageProductList,
2412
+ BitType.pageProductVideo,
2413
+ BitType.pageProductVideoList,
2414
+ BitType.pageSectionFolder,
2415
+ BitType.pageSubscribe,
2416
+ BitType.pageSubpage,
2417
+ ])) {
2418
+ //
2419
+ if (bitJson.slug == null)
2420
+ bitJson.slug = '';
2421
+ if (bitJson.body == null)
2422
+ bitJson.body = this.bodyDefault;
2423
+ if (Config.isOfBitType(bitType, BitType.pageBuyButton)) {
2424
+ if (bitJson.content2Buy == null)
2425
+ bitJson.content2Buy = '';
2426
+ }
2427
+ }
2562
2428
  // Special case for 'book' bits
2563
2429
  if (Config.isOfBitType(bitType, BitType.book)) {
2564
2430
  if (bitJson.hasMarkAsDone == null)
@@ -2570,8 +2436,8 @@ class JsonGenerator extends AstWalkerGenerator {
2570
2436
  }
2571
2437
  // Special case for 'ai' bits
2572
2438
  if (bitType === BitType.articleAi || bitType === BitType.noteAi || bitType === BitType.summaryAi) {
2573
- if (bitJson.AIGenerated == null)
2574
- bitJson.AIGenerated = true;
2439
+ if (bitJson.aiGenerated == null)
2440
+ bitJson.aiGenerated = true;
2575
2441
  }
2576
2442
  // Special case for 'review-...' bits
2577
2443
  if (Config.isOfBitType(bitType, BitType.reviewNote)) {
@@ -2636,6 +2502,24 @@ class JsonGenerator extends AstWalkerGenerator {
2636
2502
  if (bitJson.allowedBit == null)
2637
2503
  bitJson.allowedBit = [];
2638
2504
  }
2505
+ // Remove top level example if it is not required
2506
+ if (isTopLevelExample) {
2507
+ if (bitJson.isExample == null)
2508
+ bitJson.isExample = false;
2509
+ }
2510
+ else {
2511
+ // Remove example
2512
+ delete bitJson.isExample;
2513
+ delete bitJson.example;
2514
+ }
2515
+ if (isTopLevelExampleValue) {
2516
+ if (bitJson.example == null)
2517
+ bitJson.example = null;
2518
+ }
2519
+ else {
2520
+ // Remove example value
2521
+ delete bitJson.example;
2522
+ }
2639
2523
  }
2640
2524
  // Remove unwanted properties
2641
2525
  // Properties
@@ -2655,8 +2539,8 @@ class JsonGenerator extends AstWalkerGenerator {
2655
2539
  delete bitJson.jupyterExecutionCount;
2656
2540
  if (bitJson.isPublic == null)
2657
2541
  delete bitJson.isPublic;
2658
- if (bitJson.AIGenerated == null)
2659
- delete bitJson.AIGenerated;
2542
+ if (bitJson.aiGenerated == null)
2543
+ delete bitJson.aiGenerated;
2660
2544
  if (bitJson.analyticsTag == null)
2661
2545
  delete bitJson.analyticsTag;
2662
2546
  if (bitJson.feedbackEngine == null)