@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
@@ -400,12 +400,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
400
400
  // Create this list item
401
401
  this.listItem = Object.assign(Object.assign({}, this.toItemLeadHintInstruction(node.value)), { body: this.bodyDefault });
402
402
  // Delete unwanted properties
403
- const nv = node.value;
404
- const li = this.listItem;
405
- if (nv.pageNumber == null)
406
- delete li.pageNumber;
407
- if (nv.marginNumber == null)
408
- delete li.marginNumber;
403
+ // const nv = node.value;
404
+ // const li: Partial<ListItemJson> = this.listItem;
409
405
  listItems.push(this.listItem);
410
406
  }
411
407
  exit_cardBitsValue(_node, _route) {
@@ -555,7 +551,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
555
551
  }
556
552
  // bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue
557
553
  enter_flashcards(node, route) {
558
- var _a, _b, _c, _d, _e, _f;
554
+ var _a, _b, _c, _d;
559
555
  const flashcards = node.value;
560
556
  // Ignore responses that are not at the correct level as they are potentially handled elsewhere
561
557
  const parent = this.getParentNode(route);
@@ -572,10 +568,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
572
568
  // Delete unwanted properties
573
569
  if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
574
570
  delete flashcardJson.lead;
575
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
576
- delete flashcardJson.pageNumber;
577
- if (((_f = c.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
578
- delete flashcardJson.marginNumber;
579
571
  flashcardsJson.push(flashcardJson);
580
572
  }
581
573
  }
@@ -598,7 +590,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
598
590
  }
599
591
  // bitmarkAst -> bits -> bitsValue -> cardNode -> statements -> statementsValue
600
592
  enter_statements(node, route) {
601
- var _a, _b, _c, _d, _e;
593
+ var _a, _b, _c;
602
594
  const statements = node.value;
603
595
  // Ignore statements that are not at the card node level as they are handled elsewhere
604
596
  const parent = this.getParentNode(route);
@@ -617,10 +609,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
617
609
  delete statementJson.item;
618
610
  if (((_c = s.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
619
611
  delete statementJson.lead;
620
- if (((_d = s.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
621
- delete statementJson.pageNumber;
622
- if (((_e = s.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
623
- delete statementJson.marginNumber;
624
612
  if ((s === null || s === void 0 ? void 0 : s.hint) == null)
625
613
  delete statementJson.hint;
626
614
  if ((s === null || s === void 0 ? void 0 : s.instruction) == null)
@@ -635,7 +623,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
635
623
  // bitmarkAst -> bits -> bitsValue -> choices
636
624
  // X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices
637
625
  enter_choices(node, route) {
638
- var _a, _b, _c, _d, _e;
626
+ var _a, _b, _c;
639
627
  const choices = node.value;
640
628
  // Ignore choices that are not at the bit level as they are handled elsewhere as quizzes
641
629
  const parent = this.getParentNode(route);
@@ -652,10 +640,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
652
640
  // Delete unwanted properties
653
641
  if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
654
642
  delete choiceJson.lead;
655
- if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
656
- delete choiceJson.pageNumber;
657
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
658
- delete choiceJson.marginNumber;
659
643
  choicesJson.push(choiceJson);
660
644
  }
661
645
  }
@@ -666,7 +650,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
666
650
  // bitmarkAst -> bits -> bitsValue -> responses
667
651
  // X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses
668
652
  enter_responses(node, route) {
669
- var _a, _b, _c, _d, _e;
653
+ var _a, _b, _c;
670
654
  const responses = node.value;
671
655
  // Ignore responses that are not at the correct level as they are handled elsewhere as quizzes
672
656
  const parent = this.getParentNode(route);
@@ -683,10 +667,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
683
667
  // Delete unwanted properties
684
668
  if (((_c = r.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
685
669
  delete responseJson.lead;
686
- if (((_d = r.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
687
- delete responseJson.pageNumber;
688
- if (((_e = r.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
689
- delete responseJson.marginNumber;
690
670
  responsesJson.push(responseJson);
691
671
  }
692
672
  }
@@ -696,7 +676,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
696
676
  }
697
677
  // bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes
698
678
  enter_quizzes(node, _route) {
699
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
679
+ var _a, _b, _c, _d, _e, _f, _g, _h;
700
680
  const quizzes = node.value;
701
681
  const quizzesJson = [];
702
682
  if (quizzes) {
@@ -713,10 +693,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
713
693
  // Delete unwanted properties
714
694
  if (((_c = q.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
715
695
  delete choiceJson.lead;
716
- if (((_d = q.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
717
- delete choiceJson.pageNumber;
718
- if (((_e = q.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
719
- delete choiceJson.marginNumber;
720
696
  choicesJson.push(choiceJson);
721
697
  }
722
698
  }
@@ -725,29 +701,21 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
725
701
  if (q.responses) {
726
702
  for (const r of q.responses) {
727
703
  // Create the choice
728
- const responseJson = Object.assign(Object.assign({ response: (_f = Breakscape_1.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, {
704
+ const responseJson = Object.assign(Object.assign({ response: (_d = Breakscape_1.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, {
729
705
  defaultExample: !!r.isCorrect,
730
706
  isBoolean: true,
731
707
  }));
732
708
  // Delete unwanted properties
733
- if (((_h = q.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
709
+ if (((_f = q.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
734
710
  delete responseJson.lead;
735
- if (((_j = q.itemLead) === null || _j === void 0 ? void 0 : _j.pageNumber) == null)
736
- delete responseJson.pageNumber;
737
- if (((_k = q.itemLead) === null || _k === void 0 ? void 0 : _k.marginNumber) == null)
738
- delete responseJson.marginNumber;
739
711
  responsesJson.push(responseJson);
740
712
  }
741
713
  }
742
714
  // Create the quiz
743
- 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 });
715
+ 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 });
744
716
  // Delete unwanted properties
745
- if (((_m = q.itemLead) === null || _m === void 0 ? void 0 : _m.lead) == null)
717
+ if (((_h = q.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
746
718
  delete quizJson.lead;
747
- if (((_o = q.itemLead) === null || _o === void 0 ? void 0 : _o.pageNumber) == null)
748
- delete quizJson.pageNumber;
749
- if (((_p = q.itemLead) === null || _p === void 0 ? void 0 : _p.marginNumber) == null)
750
- delete quizJson.marginNumber;
751
719
  quizzesJson.push(quizJson);
752
720
  }
753
721
  }
@@ -788,7 +756,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
788
756
  }
789
757
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
790
758
  enter_pairs(node, route) {
791
- var _a, _b, _c, _d, _e, _f;
759
+ var _a, _b, _c, _d;
792
760
  const pairs = node.value;
793
761
  const pairsJson = [];
794
762
  const bitType = this.getBitType(route);
@@ -804,10 +772,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
804
772
  // Delete unwanted properties
805
773
  if (((_d = p.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
806
774
  delete pairJson.lead;
807
- if (((_e = p.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
808
- delete pairJson.pageNumber;
809
- if (((_f = p.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
810
- delete pairJson.marginNumber;
811
775
  if (pairJson.key) {
812
776
  delete pairJson.keyAudio;
813
777
  delete pairJson.keyImage;
@@ -829,7 +793,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
829
793
  }
830
794
  // bitmarkAst -> bits -> bitsValue -> cardNode -> matrix
831
795
  enter_matrix(node, _route) {
832
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
796
+ var _a, _b, _c, _d, _e, _f;
833
797
  const matrix = node.value;
834
798
  const matrixJsonArray = [];
835
799
  if (matrix) {
@@ -848,26 +812,18 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
848
812
  // Delete unwanted properties
849
813
  if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
850
814
  delete matrixCellJson.lead;
851
- if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.pageNumber) == null)
852
- delete matrixCellJson.pageNumber;
853
- if (((_e = c.itemLead) === null || _e === void 0 ? void 0 : _e.marginNumber) == null)
854
- delete matrixCellJson.marginNumber;
855
815
  if (c.hint == null)
856
816
  delete matrixCellJson.hint;
857
817
  matrixCellsJson.push(matrixCellJson);
858
818
  }
859
819
  }
860
820
  // Create the matrix
861
- const matrixJson = Object.assign(Object.assign({ key: (_f = Breakscape_1.Breakscape.unbreakscape(m.key)) !== null && _f !== void 0 ? _f : '', cells: matrixCellsJson !== null && matrixCellsJson !== void 0 ? matrixCellsJson : [] }, this.toItemLeadHintInstruction(m)), {
821
+ const matrixJson = Object.assign(Object.assign({ key: (_d = Breakscape_1.Breakscape.unbreakscape(m.key)) !== null && _d !== void 0 ? _d : '', cells: matrixCellsJson !== null && matrixCellsJson !== void 0 ? matrixCellsJson : [] }, this.toItemLeadHintInstruction(m)), {
862
822
  // ...this.toExample(m.example, m.isExample),
863
- isExample: (_g = m.isExample) !== null && _g !== void 0 ? _g : false });
823
+ isExample: (_e = m.isExample) !== null && _e !== void 0 ? _e : false });
864
824
  // Delete unwanted properties
865
- if (((_h = m.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
825
+ if (((_f = m.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
866
826
  delete matrixJson.lead;
867
- if (((_j = m.itemLead) === null || _j === void 0 ? void 0 : _j.pageNumber) == null)
868
- delete matrixJson.pageNumber;
869
- if (((_k = m.itemLead) === null || _k === void 0 ? void 0 : _k.marginNumber) == null)
870
- delete matrixJson.marginNumber;
871
827
  if (m.instruction == null)
872
828
  delete matrixJson.instruction;
873
829
  matrixJsonArray.push(matrixJson);
@@ -890,7 +846,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
890
846
  }
891
847
  // bitmarkAst -> bits -> bitsValue -> cardNode -> questions
892
848
  enter_questions(node, _route) {
893
- var _a, _b, _c, _d, _e, _f;
849
+ var _a, _b, _c, _d;
894
850
  const questions = node.value;
895
851
  const questionsJson = [];
896
852
  if (questions) {
@@ -903,10 +859,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
903
859
  // Delete unwanted properties
904
860
  if (((_d = q.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
905
861
  delete questionJson.lead;
906
- if (((_e = q.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
907
- delete questionJson.pageNumber;
908
- if (((_f = q.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
909
- delete questionJson.marginNumber;
910
862
  questionsJson.push(questionJson);
911
863
  }
912
864
  }
@@ -916,7 +868,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
916
868
  }
917
869
  // bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses
918
870
  enter_botResponses(node, route) {
919
- var _a, _b, _c, _d, _e, _f;
871
+ var _a, _b, _c, _d;
920
872
  const botResponses = node.value;
921
873
  // Ignore responses that are not at the cardNode level as they are handled elsewhere
922
874
  const parent = this.getParentNode(route);
@@ -930,10 +882,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
930
882
  // Delete unwanted properties
931
883
  if (((_d = r.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
932
884
  delete responseJson.lead;
933
- if (((_e = r.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) == null)
934
- delete responseJson.pageNumber;
935
- if (((_f = r.itemLead) === null || _f === void 0 ? void 0 : _f.marginNumber) == null)
936
- delete responseJson.marginNumber;
937
885
  if (r.hint == null)
938
886
  delete responseJson.hint;
939
887
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1255,8 +1203,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1255
1203
  })), { solutions: Breakscape_1.Breakscape.unbreakscape(data.solutions) });
1256
1204
  // Remove unwanted properties
1257
1205
  // if (!data.itemLead?.lead) delete gapJson.lead;
1258
- // if (!data.itemLead?.pageNumber) delete gapJson.pageNumber;
1259
- // if (!data.itemLead?.marginNumber) delete gapJson.marginNumber;
1260
1206
  return gapJson;
1261
1207
  }
1262
1208
  createMarkJson(mark) {
@@ -1268,8 +1214,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1268
1214
  }));
1269
1215
  // Remove unwanted properties
1270
1216
  // if (!data.itemLead?.lead) delete markJson.lead;
1271
- // if (!data.itemLead?.pageNumber) delete markJson.pageNumber;
1272
- // if (!data.itemLead?.marginNumber) delete markJson.marginNumber;
1273
1217
  return markJson;
1274
1218
  }
1275
1219
  createSelectJson(select) {
@@ -1285,8 +1229,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1285
1229
  // Remove unwanted properties
1286
1230
  // if (!option.itemLead?.item) delete optionJson.item;
1287
1231
  // if (!option.itemLead?.lead) delete optionJson.lead;
1288
- // if (!option.itemLead?.pageNumber) delete optionJson.pageNumber;
1289
- // if (!option.itemLead?.marginNumber) delete optionJson.marginNumber;
1290
1232
  // if (!option.instruction) delete optionJson.instruction;
1291
1233
  options.push(optionJson);
1292
1234
  }
@@ -1294,8 +1236,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1294
1236
  const selectJson = Object.assign(Object.assign({ type: 'select', prefix: (_b = Breakscape_1.Breakscape.unbreakscape(data.prefix)) !== null && _b !== void 0 ? _b : '', postfix: (_c = Breakscape_1.Breakscape.unbreakscape(data.postfix)) !== null && _c !== void 0 ? _c : '' }, this.toItemLeadHintInstruction(data)), { isExample: (_d = data.isExample) !== null && _d !== void 0 ? _d : false, options });
1295
1237
  // Remove unwanted properties
1296
1238
  // if (!data.itemLead?.lead) delete selectJson.lead;
1297
- // if (!data.itemLead?.pageNumber) delete selectJson.pageNumber;
1298
- // if (!data.itemLead?.marginNumber) delete selectJson.marginNumber;
1299
1239
  return selectJson;
1300
1240
  }
1301
1241
  createHighlightJson(highlight) {
@@ -1311,8 +1251,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1311
1251
  // Remove unwanted properties
1312
1252
  // if (!text.itemLead?.item) delete textJson.item;
1313
1253
  // if (!text.itemLead?.lead) delete textJson.lead;
1314
- // if (!text.itemLead?.pageNumber) delete textJson.pageNumber;
1315
- // if (!text.itemLead?.marginNumber) delete textJson.marginNumber;
1316
1254
  // if (!text.hint) delete textJson.hint;
1317
1255
  texts.push(textJson);
1318
1256
  }
@@ -1814,7 +1752,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1814
1752
  return resourceJson;
1815
1753
  }
1816
1754
  addGenericResourceProperties(_bitType, resource, resourceJson, noDefaults) {
1817
- var _a, _b, _c, _d, _e, _f, _g, _h;
1755
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1818
1756
  if (noDefaults) {
1819
1757
  if (resource.license != null)
1820
1758
  resourceJson.license = (_a = Breakscape_1.Breakscape.unbreakscape(resource.license)) !== null && _a !== void 0 ? _a : '';
@@ -1824,28 +1762,31 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
1824
1762
  resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
1825
1763
  if (resource.showInIndex != null)
1826
1764
  resourceJson.showInIndex = (_c = resource.showInIndex) !== null && _c !== void 0 ? _c : false;
1827
- if (resource.caption != null)
1765
+ if (resource.caption != null) {
1828
1766
  resourceJson.caption = this.convertBreakscapedStringToJsonText((_d = resource.caption) !== null && _d !== void 0 ? _d : '', TextFormat_1.TextFormat.bitmarkMinusMinus);
1767
+ }
1768
+ if (resource.search != null)
1769
+ resourceJson.search = (_e = Breakscape_1.Breakscape.unbreakscape(resource.search)) !== null && _e !== void 0 ? _e : '';
1829
1770
  }
1830
1771
  else {
1831
- resourceJson.license = (_e = Breakscape_1.Breakscape.unbreakscape(resource.license)) !== null && _e !== void 0 ? _e : '';
1832
- resourceJson.copyright = (_f = Breakscape_1.Breakscape.unbreakscape(resource.copyright)) !== null && _f !== void 0 ? _f : '';
1772
+ resourceJson.license = (_f = Breakscape_1.Breakscape.unbreakscape(resource.license)) !== null && _f !== void 0 ? _f : '';
1773
+ resourceJson.copyright = (_g = Breakscape_1.Breakscape.unbreakscape(resource.copyright)) !== null && _g !== void 0 ? _g : '';
1833
1774
  if (resource.provider != null)
1834
1775
  resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
1835
- resourceJson.showInIndex = (_g = resource.showInIndex) !== null && _g !== void 0 ? _g : false;
1836
- resourceJson.caption = this.convertBreakscapedStringToJsonText((_h = resource.caption) !== null && _h !== void 0 ? _h : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus);
1776
+ resourceJson.showInIndex = (_h = resource.showInIndex) !== null && _h !== void 0 ? _h : false;
1777
+ resourceJson.caption = this.convertBreakscapedStringToJsonText((_j = resource.caption) !== null && _j !== void 0 ? _j : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus);
1778
+ if (resource.search != null)
1779
+ resourceJson.search = (_k = Breakscape_1.Breakscape.unbreakscape(resource.search)) !== null && _k !== void 0 ? _k : '';
1837
1780
  }
1838
1781
  return resourceJson;
1839
1782
  }
1840
1783
  toItemLeadHintInstruction(item) {
1841
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1784
+ var _a, _b, _c, _d, _e, _f;
1842
1785
  return {
1843
1786
  item: this.convertBreakscapedStringToJsonText((_b = (_a = item.itemLead) === null || _a === void 0 ? void 0 : _a.item) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1844
1787
  lead: this.convertBreakscapedStringToJsonText((_d = (_c = item.itemLead) === null || _c === void 0 ? void 0 : _c.lead) !== null && _d !== void 0 ? _d : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1845
- pageNumber: this.convertBreakscapedStringToJsonText((_f = (_e = item.itemLead) === null || _e === void 0 ? void 0 : _e.pageNumber) !== null && _f !== void 0 ? _f : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1846
- marginNumber: this.convertBreakscapedStringToJsonText((_h = (_g = item.itemLead) === null || _g === void 0 ? void 0 : _g.marginNumber) !== null && _h !== void 0 ? _h : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1847
- hint: this.convertBreakscapedStringToJsonText((_j = item.hint) !== null && _j !== void 0 ? _j : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1848
- instruction: this.convertBreakscapedStringToJsonText((_k = item.instruction) !== null && _k !== void 0 ? _k : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1788
+ hint: this.convertBreakscapedStringToJsonText((_e = item.hint) !== null && _e !== void 0 ? _e : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1789
+ instruction: this.convertBreakscapedStringToJsonText((_f = item.instruction) !== null && _f !== void 0 ? _f : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
1849
1790
  };
1850
1791
  }
1851
1792
  toExample(node, options) {
@@ -2094,7 +2035,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
2094
2035
  jupyterId: undefined,
2095
2036
  jupyterExecutionCount: undefined,
2096
2037
  isPublic: undefined,
2097
- AIGenerated: undefined,
2038
+ aiGenerated: undefined,
2098
2039
  analyticsTag: undefined,
2099
2040
  feedbackEngine: undefined,
2100
2041
  disableFeedback: undefined,
@@ -2284,284 +2225,209 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
2284
2225
  // The properties used are a bit random sometimes?
2285
2226
  // It would be better if this functionality was generated from the bit config
2286
2227
  if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType._error, BitType_1.BitType._comment])) {
2287
- //
2228
+ // Special caes for _error and _comment bits
2288
2229
  delete bitJson.format;
2289
2230
  //
2290
2231
  }
2291
- else if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.article, BitType_1.BitType.sampleSolution, BitType_1.BitType.page])) {
2292
- //
2293
- if (bitJson.body == null)
2294
- bitJson.body = this.bodyDefault;
2295
- //
2296
- }
2297
- else if (Config_1.Config.isOfBitType(bitType, [
2298
- BitType_1.BitType.multipleChoice1,
2299
- BitType_1.BitType.multipleResponse1,
2300
- BitType_1.BitType.multipleChoiceText,
2301
- BitType_1.BitType.highlightText,
2302
- BitType_1.BitType.clozeAndMultipleChoiceText,
2303
- BitType_1.BitType.sequence,
2304
- BitType_1.BitType.mark,
2305
- BitType_1.BitType.flashcard,
2306
- ])) {
2307
- // Default, but with no 'example' at the bit level.
2308
- if (bitJson.item == null)
2309
- bitJson.item = this.textDefault;
2310
- if (bitJson.hint == null)
2311
- bitJson.hint = this.textDefault;
2312
- if (bitJson.instruction == null)
2313
- bitJson.instruction = this.textDefault;
2314
- if (bitJson.isExample == null)
2315
- bitJson.isExample = false;
2316
- if (bitJson.body == null)
2317
- bitJson.body = this.bodyDefault;
2318
- //
2319
- }
2320
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.cloze)) {
2321
- // Default, but with no 'example' at the bit level.
2322
- if (bitJson.item == null)
2323
- bitJson.item = this.textDefault;
2324
- if (bitJson.hint == null)
2325
- bitJson.hint = this.textDefault;
2326
- if (bitJson.instruction == null)
2327
- bitJson.instruction = this.textDefault;
2328
- if (bitJson.isExample == null)
2329
- bitJson.isExample = false;
2330
- if (bitJson.body == null)
2331
- bitJson.body = this.bodyDefault;
2332
- if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.clozeSolutionGrouped)) {
2333
- // Solution grouped
2334
- if (bitJson.quizCountItems == null)
2335
- bitJson.quizCountItems = true;
2336
- if (bitJson.quizStrikethroughSolutions == null)
2337
- bitJson.quizStrikethroughSolutions = true;
2338
- }
2339
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.clozeInstructionGrouped)) {
2340
- // Instruction grouped
2341
- if (bitJson.quizCountItems == null)
2342
- bitJson.quizCountItems = true;
2343
- if (bitJson.quizStrikethroughSolutions == null)
2344
- bitJson.quizStrikethroughSolutions = false;
2345
- }
2346
- //
2347
- }
2348
- else if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.multipleChoice, BitType_1.BitType.multipleResponse])) {
2349
- // Default with a card (and hence a footer possibility)
2350
- if (bitJson.item == null)
2351
- bitJson.item = this.textDefault;
2352
- if (bitJson.hint == null)
2353
- bitJson.hint = this.textDefault;
2354
- if (bitJson.instruction == null)
2355
- bitJson.instruction = this.textDefault;
2356
- if (bitJson.isExample == null)
2357
- bitJson.isExample = false;
2358
- if (bitJson.body == null)
2359
- bitJson.body = this.bodyDefault;
2360
- if (bitJson.footer == null)
2361
- bitJson.footer = this.textDefault;
2362
- //
2363
- }
2364
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.essay)) {
2365
- //
2366
- if (bitJson.item == null)
2367
- bitJson.item = this.textDefault;
2368
- if (bitJson.hint == null)
2369
- bitJson.hint = this.textDefault;
2370
- if (bitJson.instruction == null)
2371
- bitJson.instruction = this.textDefault;
2372
- if (bitJson.isExample == null)
2373
- bitJson.isExample = false;
2374
- if (bitJson.example == null)
2375
- bitJson.example = null;
2376
- if (bitJson.body == null)
2377
- bitJson.body = this.bodyDefault;
2378
- if (bitJson.partialAnswer == null)
2379
- bitJson.partialAnswer = '';
2380
- // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2381
- //
2382
- }
2383
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.trueFalse1)) {
2384
- //
2385
- if (bitJson.item == null)
2386
- bitJson.item = this.textDefault;
2387
- if (bitJson.lead == null)
2388
- bitJson.lead = this.textDefault;
2389
- if (bitJson.hint == null)
2390
- bitJson.hint = this.textDefault;
2391
- if (bitJson.instruction == null)
2392
- bitJson.instruction = this.textDefault;
2393
- if (bitJson.isExample == null)
2394
- bitJson.isExample = false;
2395
- if (bitJson.example == null)
2396
- bitJson.example = null;
2397
- if (bitJson.isCorrect == null)
2398
- bitJson.isCorrect = false;
2399
- if (bitJson.body == null)
2400
- bitJson.body = this.bodyDefault;
2401
- //
2402
- }
2403
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.trueFalse)) {
2404
- //
2405
- if (bitJson.item == null)
2406
- bitJson.item = this.textDefault;
2407
- if (bitJson.lead == null)
2408
- bitJson.lead = this.textDefault;
2409
- if (bitJson.hint == null)
2410
- bitJson.hint = this.textDefault;
2411
- if (bitJson.instruction == null)
2412
- bitJson.instruction = this.textDefault;
2413
- if (bitJson.isExample == null)
2414
- bitJson.isExample = false;
2415
- if (bitJson.labelFalse == null)
2416
- bitJson.labelFalse = '';
2417
- if (bitJson.labelTrue == null)
2418
- bitJson.labelTrue = '';
2419
- if (bitJson.body == null)
2420
- bitJson.body = this.bodyDefault;
2421
- //
2422
- }
2423
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.chapter)) {
2424
- //
2425
- if (bitJson.item == null)
2426
- bitJson.item = this.textDefault;
2427
- if (bitJson.hint == null)
2428
- bitJson.hint = this.textDefault;
2429
- if (bitJson.isExample == null)
2430
- bitJson.isExample = false;
2431
- if (bitJson.example == null)
2432
- bitJson.example = null;
2433
- if (bitJson.toc == null)
2434
- bitJson.toc = true; // Always set on chapter bits?
2435
- if (bitJson.progress == null)
2436
- bitJson.progress = true; // Always set on chapter bits
2437
- if (bitJson.level == null)
2438
- bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2439
- if (bitJson.body == null)
2440
- bitJson.body = this.bodyDefault;
2441
- //
2442
- }
2443
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.interview)) {
2444
- //
2445
- if (bitJson.item == null)
2446
- bitJson.item = this.textDefault;
2447
- if (bitJson.hint == null)
2448
- bitJson.hint = this.textDefault;
2449
- if (bitJson.instruction == null)
2450
- bitJson.instruction = this.textDefault;
2451
- if (bitJson.isExample == null)
2452
- bitJson.isExample = false;
2453
- if (bitJson.body == null)
2454
- bitJson.body = this.bodyDefault;
2455
- if (bitJson.footer == null)
2456
- bitJson.footer = this.textDefault;
2457
- if (bitJson.questions == null)
2458
- bitJson.questions = [];
2459
- //
2460
- }
2461
- else if (bitType === BitType_1.BitType.matchMatrix) {
2462
- //
2463
- if (bitJson.item == null)
2464
- bitJson.item = this.textDefault;
2465
- if (bitJson.body == null)
2466
- bitJson.body = this.bodyDefault;
2467
- //
2468
- }
2469
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.match)) {
2470
- //
2471
- if (bitJson.item == null)
2472
- bitJson.item = this.textDefault;
2473
- if (bitJson.heading == null)
2474
- bitJson.heading = {};
2475
- if (bitJson.body == null)
2476
- bitJson.body = this.bodyDefault;
2477
- //
2478
- }
2479
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.learningPathBook)) {
2480
- //
2481
- if (bitJson.item == null)
2482
- bitJson.item = this.textDefault;
2483
- if (bitJson.hint == null)
2484
- bitJson.hint = this.textDefault;
2485
- if (bitJson.isExample == null)
2486
- bitJson.isExample = false;
2487
- if (bitJson.example == null)
2488
- bitJson.example = null;
2489
- if (bitJson.isTracked == null)
2490
- bitJson.isTracked = true;
2491
- if (bitJson.isInfoOnly == null)
2492
- bitJson.isInfoOnly = false;
2493
- if (bitJson.body == null)
2494
- bitJson.body = this.bodyDefault;
2495
- //
2496
- }
2497
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.table)) {
2498
- //
2499
- // if (bitJson.content2Buy == null) bitJson.content2Buy = '';
2500
- if (bitJson.tableFixedHeader == null)
2501
- bitJson.tableFixedHeader = false;
2502
- if (bitJson.tableSearch == null)
2503
- bitJson.tableSearch = false;
2504
- if (bitJson.tableSort == null)
2505
- bitJson.tableSort = false;
2506
- if (bitJson.tablePagination == null)
2507
- bitJson.tablePagination = false;
2508
- if (bitJson.tablePaginationLimit == null)
2509
- bitJson.tablePaginationLimit = 0;
2510
- if (bitJson.tableHeight == null)
2511
- bitJson.tableHeight = 0;
2512
- if (bitJson.tableWhitespaceNoWrap == null)
2513
- bitJson.tableWhitespaceNoWrap = true;
2514
- if (bitJson.tableAutoWidth == null)
2515
- bitJson.tableAutoWidth = true;
2516
- if (bitJson.tableResizableColumns == null)
2517
- bitJson.tableResizableColumns = false;
2518
- if (bitJson.body == null)
2519
- bitJson.body = this.bodyDefault;
2520
- //
2521
- }
2522
- else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageBanner) ||
2523
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageBuyButton) ||
2524
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageBuyButtonPromotion) ||
2525
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageFooter) ||
2526
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageOpenBook) ||
2527
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pagePerson) ||
2528
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageProduct) ||
2529
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageProductList) ||
2530
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageProductVideo) ||
2531
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageProductVideoList) ||
2532
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageSectionFolder) ||
2533
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageSubscribe) ||
2534
- Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageSubpage)) {
2535
- //
2536
- if (bitJson.slug == null)
2537
- bitJson.slug = '';
2538
- if (bitJson.item == null)
2539
- bitJson.item = this.textDefault;
2540
- if (bitJson.hint == null)
2541
- bitJson.hint = this.textDefault;
2542
- if (bitJson.isExample == null)
2543
- bitJson.isExample = false;
2544
- if (bitJson.example == null)
2545
- bitJson.example = null;
2546
- if (bitJson.body == null)
2547
- bitJson.body = this.bodyDefault;
2548
- if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageBuyButton)) {
2549
- if (bitJson.content2Buy == null)
2550
- bitJson.content2Buy = '';
2551
- }
2552
- }
2553
2232
  else {
2233
+ let isTopLevelExample = false;
2234
+ let isTopLevelExampleValue = false;
2554
2235
  // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2555
- if (bitJson.item == null)
2556
- bitJson.item = this.textDefault;
2557
- if (bitJson.hint == null)
2558
- bitJson.hint = this.textDefault;
2559
- if (bitJson.isExample == null)
2560
- bitJson.isExample = false;
2561
- if (bitJson.example == null)
2562
- bitJson.example = null;
2236
+ if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.page])) {
2237
+ // Bits without item, lead, etc
2238
+ }
2239
+ else {
2240
+ // Majority of bits
2241
+ if (bitJson.item == null)
2242
+ bitJson.item = this.textDefault;
2243
+ if (bitJson.lead == null)
2244
+ bitJson.lead = this.textDefault;
2245
+ if (bitJson.hint == null)
2246
+ bitJson.hint = this.textDefault;
2247
+ if (bitJson.instruction == null)
2248
+ bitJson.instruction = this.textDefault;
2249
+ if (bitJson.pageNumber == null)
2250
+ bitJson.pageNumber = this.textDefault;
2251
+ if (bitJson.marginNumber == null)
2252
+ bitJson.marginNumber = this.textDefault;
2253
+ }
2563
2254
  if (bitJson.body == null)
2564
2255
  bitJson.body = this.bodyDefault;
2256
+ if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.article])) {
2257
+ //
2258
+ }
2259
+ if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.example])) {
2260
+ // With 'example' value at the bit level.
2261
+ isTopLevelExample = true;
2262
+ isTopLevelExampleValue = true;
2263
+ }
2264
+ if (Config_1.Config.isOfBitType(bitType, [
2265
+ BitType_1.BitType.multipleChoice1,
2266
+ BitType_1.BitType.multipleResponse1,
2267
+ BitType_1.BitType.multipleChoiceText,
2268
+ BitType_1.BitType.highlightText,
2269
+ BitType_1.BitType.gapText,
2270
+ BitType_1.BitType.gapTextInstructionGrouped,
2271
+ BitType_1.BitType.clozeAndMultipleChoiceText,
2272
+ BitType_1.BitType.sequence,
2273
+ BitType_1.BitType.mark,
2274
+ BitType_1.BitType.flashcard,
2275
+ ])) {
2276
+ // With no 'example' value at the bit level.
2277
+ isTopLevelExample = true;
2278
+ if (bitJson.body == null)
2279
+ bitJson.body = this.bodyDefault;
2280
+ }
2281
+ if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.sequence])) {
2282
+ // With 'example' value at the bit level.
2283
+ isTopLevelExample = true;
2284
+ isTopLevelExampleValue = true;
2285
+ if (bitJson.body == null)
2286
+ bitJson.body = this.bodyDefault;
2287
+ }
2288
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.cloze)) {
2289
+ // With no 'example' value at the bit level.
2290
+ isTopLevelExample = true;
2291
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.clozeSolutionGrouped)) {
2292
+ // Solution grouped
2293
+ if (bitJson.quizCountItems == null)
2294
+ bitJson.quizCountItems = true;
2295
+ if (bitJson.quizStrikethroughSolutions == null)
2296
+ bitJson.quizStrikethroughSolutions = true;
2297
+ }
2298
+ else if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.clozeInstructionGrouped)) {
2299
+ // Instruction grouped
2300
+ if (bitJson.quizCountItems == null)
2301
+ bitJson.quizCountItems = true;
2302
+ if (bitJson.quizStrikethroughSolutions == null)
2303
+ bitJson.quizStrikethroughSolutions = false;
2304
+ }
2305
+ }
2306
+ if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.multipleChoice, BitType_1.BitType.multipleResponse])) {
2307
+ // Default with a card (and hence a footer possibility)
2308
+ isTopLevelExample = true;
2309
+ if (bitJson.body == null)
2310
+ bitJson.body = this.bodyDefault;
2311
+ if (bitJson.footer == null)
2312
+ bitJson.footer = this.textDefault;
2313
+ }
2314
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.essay)) {
2315
+ // With 'example' value at the bit level.
2316
+ isTopLevelExample = true;
2317
+ isTopLevelExampleValue = true;
2318
+ if (bitJson.body == null)
2319
+ bitJson.body = this.bodyDefault;
2320
+ if (bitJson.partialAnswer == null)
2321
+ bitJson.partialAnswer = '';
2322
+ // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2323
+ }
2324
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.trueFalse1)) {
2325
+ // With 'example' value at the bit level.
2326
+ isTopLevelExample = true;
2327
+ isTopLevelExampleValue = true;
2328
+ if (bitJson.isCorrect == null)
2329
+ bitJson.isCorrect = false;
2330
+ if (bitJson.body == null)
2331
+ bitJson.body = this.bodyDefault;
2332
+ }
2333
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.trueFalse)) {
2334
+ // With no 'example' value at the bit level.
2335
+ isTopLevelExample = true;
2336
+ if (bitJson.labelFalse == null)
2337
+ bitJson.labelFalse = '';
2338
+ if (bitJson.labelTrue == null)
2339
+ bitJson.labelTrue = '';
2340
+ if (bitJson.body == null)
2341
+ bitJson.body = this.bodyDefault;
2342
+ }
2343
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.chapter)) {
2344
+ //
2345
+ if (bitJson.toc == null)
2346
+ bitJson.toc = true; // Always set on chapter bits?
2347
+ if (bitJson.progress == null)
2348
+ bitJson.progress = true; // Always set on chapter bits
2349
+ if (bitJson.level == null)
2350
+ bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2351
+ if (bitJson.body == null)
2352
+ bitJson.body = this.bodyDefault;
2353
+ //
2354
+ }
2355
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.interview)) {
2356
+ // With no 'example' value at the bit level.
2357
+ isTopLevelExample = true;
2358
+ if (bitJson.body == null)
2359
+ bitJson.body = this.bodyDefault;
2360
+ if (bitJson.footer == null)
2361
+ bitJson.footer = this.textDefault;
2362
+ if (bitJson.questions == null)
2363
+ bitJson.questions = [];
2364
+ }
2365
+ if (bitType === BitType_1.BitType.matchMatrix) {
2366
+ // With no 'example' value at the bit level.
2367
+ isTopLevelExample = true;
2368
+ }
2369
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.match)) {
2370
+ // With no 'example' value at the bit level.
2371
+ isTopLevelExample = true;
2372
+ if (bitJson.heading == null)
2373
+ bitJson.heading = {};
2374
+ }
2375
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.learningPathBook)) {
2376
+ //
2377
+ if (bitJson.isTracked == null)
2378
+ bitJson.isTracked = true;
2379
+ if (bitJson.isInfoOnly == null)
2380
+ bitJson.isInfoOnly = false;
2381
+ //
2382
+ }
2383
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.table)) {
2384
+ //
2385
+ // if (bitJson.content2Buy == null) bitJson.content2Buy = '';
2386
+ if (bitJson.tableFixedHeader == null)
2387
+ bitJson.tableFixedHeader = false;
2388
+ if (bitJson.tableSearch == null)
2389
+ bitJson.tableSearch = false;
2390
+ if (bitJson.tableSort == null)
2391
+ bitJson.tableSort = false;
2392
+ if (bitJson.tablePagination == null)
2393
+ bitJson.tablePagination = false;
2394
+ if (bitJson.tablePaginationLimit == null)
2395
+ bitJson.tablePaginationLimit = 0;
2396
+ if (bitJson.tableHeight == null)
2397
+ bitJson.tableHeight = 0;
2398
+ if (bitJson.tableWhitespaceNoWrap == null)
2399
+ bitJson.tableWhitespaceNoWrap = true;
2400
+ if (bitJson.tableAutoWidth == null)
2401
+ bitJson.tableAutoWidth = true;
2402
+ if (bitJson.tableResizableColumns == null)
2403
+ bitJson.tableResizableColumns = false;
2404
+ //
2405
+ }
2406
+ if (Config_1.Config.isOfBitType(bitType, [
2407
+ BitType_1.BitType.pageBanner,
2408
+ BitType_1.BitType.pageBuyButton,
2409
+ BitType_1.BitType.pageBuyButtonPromotion,
2410
+ BitType_1.BitType.pageFooter,
2411
+ BitType_1.BitType.pageOpenBook,
2412
+ BitType_1.BitType.pagePerson,
2413
+ BitType_1.BitType.pageProduct,
2414
+ BitType_1.BitType.pageProductList,
2415
+ BitType_1.BitType.pageProductVideo,
2416
+ BitType_1.BitType.pageProductVideoList,
2417
+ BitType_1.BitType.pageSectionFolder,
2418
+ BitType_1.BitType.pageSubscribe,
2419
+ BitType_1.BitType.pageSubpage,
2420
+ ])) {
2421
+ //
2422
+ if (bitJson.slug == null)
2423
+ bitJson.slug = '';
2424
+ if (bitJson.body == null)
2425
+ bitJson.body = this.bodyDefault;
2426
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.pageBuyButton)) {
2427
+ if (bitJson.content2Buy == null)
2428
+ bitJson.content2Buy = '';
2429
+ }
2430
+ }
2565
2431
  // Special case for 'book' bits
2566
2432
  if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.book)) {
2567
2433
  if (bitJson.hasMarkAsDone == null)
@@ -2573,8 +2439,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
2573
2439
  }
2574
2440
  // Special case for 'ai' bits
2575
2441
  if (bitType === BitType_1.BitType.articleAi || bitType === BitType_1.BitType.noteAi || bitType === BitType_1.BitType.summaryAi) {
2576
- if (bitJson.AIGenerated == null)
2577
- bitJson.AIGenerated = true;
2442
+ if (bitJson.aiGenerated == null)
2443
+ bitJson.aiGenerated = true;
2578
2444
  }
2579
2445
  // Special case for 'review-...' bits
2580
2446
  if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.reviewNote)) {
@@ -2639,6 +2505,24 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
2639
2505
  if (bitJson.allowedBit == null)
2640
2506
  bitJson.allowedBit = [];
2641
2507
  }
2508
+ // Remove top level example if it is not required
2509
+ if (isTopLevelExample) {
2510
+ if (bitJson.isExample == null)
2511
+ bitJson.isExample = false;
2512
+ }
2513
+ else {
2514
+ // Remove example
2515
+ delete bitJson.isExample;
2516
+ delete bitJson.example;
2517
+ }
2518
+ if (isTopLevelExampleValue) {
2519
+ if (bitJson.example == null)
2520
+ bitJson.example = null;
2521
+ }
2522
+ else {
2523
+ // Remove example value
2524
+ delete bitJson.example;
2525
+ }
2642
2526
  }
2643
2527
  // Remove unwanted properties
2644
2528
  // Properties
@@ -2658,8 +2542,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
2658
2542
  delete bitJson.jupyterExecutionCount;
2659
2543
  if (bitJson.isPublic == null)
2660
2544
  delete bitJson.isPublic;
2661
- if (bitJson.AIGenerated == null)
2662
- delete bitJson.AIGenerated;
2545
+ if (bitJson.aiGenerated == null)
2546
+ delete bitJson.aiGenerated;
2663
2547
  if (bitJson.analyticsTag == null)
2664
2548
  delete bitJson.analyticsTag;
2665
2549
  if (bitJson.feedbackEngine == null)