@gmb/bitmark-parser-generator 5.9.1 → 5.10.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.
package/dist/index.cjs CHANGED
@@ -752,8 +752,10 @@ var TagFormat = {
752
752
  // If the value is treated as a number
753
753
  boolean: "boolean",
754
754
  // If the value is treated as a boolean
755
- invertedBoolean: "invertedBoolean"
755
+ invertedBoolean: "invertedBoolean",
756
756
  // If the value is treated as a boolean with the value inverted (e.g. isLongAnswer ==> isShortAnswer = false)
757
+ enumeration: "enumeration"
758
+ // If the value is treated as an enumeration (the value is a string that must be one of a predefined set of values)
757
759
  };
758
760
 
759
761
  // src/model/enum/TextFormat.ts
@@ -897,9 +899,12 @@ var PropertyTagConfig = class extends AbstractTagConfig {
897
899
  // If the property is treated as an array rather than a single value
898
900
  __publicField(this, "format");
899
901
  // How the property is formatted
902
+ __publicField(this, "values");
903
+ // If the format is an enumeration, the possible values of the property
900
904
  __publicField(this, "defaultValue");
901
905
  this.array = params.maxCount === Count.infinity || params.maxCount > 1;
902
906
  this.format = params.format;
907
+ this.values = params.values;
903
908
  this.defaultValue = params.defaultValue;
904
909
  }
905
910
  toString(options) {
@@ -911,6 +916,7 @@ var PropertyTagConfig = class extends AbstractTagConfig {
911
916
  if (this.minCount != null) s += `, min=${this.minCount}`;
912
917
  if (this.array != null) s += `, arr=${this.array}`;
913
918
  if (this.format != null) s += `, fmt=${this.format}`;
919
+ if (this.values != null) s += `, vals=[${this.values.join(",")}]`;
914
920
  if (this.defaultValue != null) s += `, def=${this.defaultValue}`;
915
921
  if (this.jsonKey != null) s += `, json=${this.jsonKey}`;
916
922
  }
@@ -1204,7 +1210,6 @@ var propertyKeys = {
1204
1210
  property_aiGenerated: "@aiGenerated",
1205
1211
  property_allowedBit: "@allowedBit",
1206
1212
  property_allowPrint: "@allowPrint",
1207
- property_allowPrintEnforceSpaceConfiguration: "@allowPrintEnforceSpaceConfiguration",
1208
1213
  property_allowSubtitles: "@allowSubtitles",
1209
1214
  property_alt: "@alt",
1210
1215
  property_altLangTag: "@altLangTag",
@@ -3485,14 +3490,9 @@ var GROUPS = {
3485
3490
  {
3486
3491
  key: ConfigKey.property_allowPrint,
3487
3492
  description: "If true, the book allows printing",
3488
- format: TagFormat.boolean,
3489
- defaultValue: "false"
3490
- },
3491
- {
3492
- key: ConfigKey.property_allowPrintEnforceSpaceConfiguration,
3493
- description: "If true, enforces space configuration for printing regardless of the allowPrint setting",
3494
- format: TagFormat.boolean,
3495
- defaultValue: "false"
3493
+ format: TagFormat.enumeration,
3494
+ values: ["enforceFalse", "enforceTrue", "useSpaceConfiguration"],
3495
+ defaultValue: "enforceFalse"
3496
3496
  },
3497
3497
  {
3498
3498
  key: ConfigKey.property_hasPrintRestriction,
@@ -4468,6 +4468,7 @@ var ConfigHydrator = class {
4468
4468
  chain: _chain,
4469
4469
  deprecated,
4470
4470
  format,
4471
+ values,
4471
4472
  defaultValue,
4472
4473
  jsonKey
4473
4474
  } = _tag;
@@ -4486,6 +4487,7 @@ var ConfigHydrator = class {
4486
4487
  chain,
4487
4488
  jsonKey,
4488
4489
  format,
4490
+ values,
4489
4491
  defaultValue,
4490
4492
  deprecated
4491
4493
  });
@@ -10461,7 +10463,7 @@ var instance2 = new Config();
10461
10463
  // src/generated/package_info.ts
10462
10464
  var PACKAGE_INFO = {
10463
10465
  "name": "@gmb/bitmark-parser-generator",
10464
- "version": "5.9.1",
10466
+ "version": "5.10.0",
10465
10467
  "author": "Get More Brain Ltd",
10466
10468
  "license": "ISC",
10467
10469
  "description": "A bitmark parser and generator using Peggy.js"
@@ -11082,6 +11084,8 @@ var NodeType = {
11082
11084
  indexValue: "indexValue",
11083
11085
  ingredients: "ingredients",
11084
11086
  ingredientsValue: "ingredientsValue",
11087
+ ingredient: "ingredient",
11088
+ ingredientValue: "ingredientValue",
11085
11089
  instruction: "instruction",
11086
11090
  instructionValue: "instructionValue",
11087
11091
  internalComment: "internalComment",
@@ -11394,6 +11398,7 @@ var NodeType = {
11394
11398
  srcAltValue: "srcAltValue",
11395
11399
  start: "start",
11396
11400
  statement: "statement",
11401
+ statementValue: "statementValue",
11397
11402
  statements: "statements",
11398
11403
  statementsValue: "statementsValue",
11399
11404
  statementText: "statementText",
@@ -25024,12 +25029,6 @@ var Builder = class extends BaseBuilder {
25024
25029
  data.allowPrint,
25025
25030
  options
25026
25031
  ),
25027
- allowPrintEnforceSpaceConfiguration: this.toAstProperty(
25028
- bitType,
25029
- ConfigKey.property_allowPrintEnforceSpaceConfiguration,
25030
- data.allowPrintEnforceSpaceConfiguration,
25031
- options
25032
- ),
25033
25032
  printParentChapterLevel: this.toAstProperty(
25034
25033
  bitType,
25035
25034
  ConfigKey.property_printParentChapterLevel,
@@ -27402,7 +27401,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27402
27401
  if (parent?.key !== NodeType.bitsValue) return true;
27403
27402
  for (const gt of groupTag) {
27404
27403
  const { name, tags: tags2 } = gt;
27405
- this.writeNL();
27406
27404
  this.writeProperty("groupTag", name, route, {
27407
27405
  format: TagFormat.plainText,
27408
27406
  writeEmpty: true
@@ -27411,7 +27409,8 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27411
27409
  for (const t of tags2) {
27412
27410
  this.writeProperty("tag", t, route, {
27413
27411
  format: TagFormat.plainText,
27414
- writeEmpty: true
27412
+ writeEmpty: true,
27413
+ forceChain: true
27415
27414
  });
27416
27415
  }
27417
27416
  }
@@ -27419,7 +27418,7 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27419
27418
  return false;
27420
27419
  }
27421
27420
  // bitmarkAst -> bits -> bitsValue -> labelTrue / labelFalse
27422
- enter_labelTrue(node, route) {
27421
+ leaf_labelTrue(node, route) {
27423
27422
  const value = node.value;
27424
27423
  const parent = this.getParentNode(route);
27425
27424
  if (parent?.key !== NodeType.bitsValue) return true;
@@ -27432,16 +27431,18 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27432
27431
  }
27433
27432
  if (haveTrue)
27434
27433
  this.writeProperty("labelTrue", value, route, {
27435
- format: TagFormat.plainText
27434
+ format: TagFormat.plainText,
27435
+ forceChain: true
27436
27436
  });
27437
27437
  if (haveFalse)
27438
27438
  this.writeProperty("labelFalse", bit.labelFalse, route, {
27439
- format: TagFormat.plainText
27439
+ format: TagFormat.plainText,
27440
+ forceChain: true
27440
27441
  });
27441
27442
  }
27442
27443
  return false;
27443
27444
  }
27444
- enter_labelFalse(_node, _route) {
27445
+ leaf_labelFalse(_node, _route) {
27445
27446
  return true;
27446
27447
  }
27447
27448
  // bitmarkAst -> bits -> bitsValue -> imageSource
@@ -27450,26 +27451,29 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27450
27451
  const parent = this.getParentNode(route);
27451
27452
  if (parent?.key !== NodeType.bitsValue) return true;
27452
27453
  const { url, mockupId, size, format, trim } = imageSource;
27453
- this.writeNL();
27454
27454
  this.writeProperty("imageSource", url, route, {
27455
27455
  format: TagFormat.plainText
27456
27456
  });
27457
27457
  if (url) {
27458
27458
  if (mockupId)
27459
27459
  this.writeProperty("mockupId", mockupId, route, {
27460
- format: TagFormat.plainText
27460
+ format: TagFormat.plainText,
27461
+ forceChain: true
27461
27462
  });
27462
27463
  if (size)
27463
27464
  this.writeProperty("size", size, route, {
27464
- format: TagFormat.plainText
27465
+ format: TagFormat.plainText,
27466
+ forceChain: true
27465
27467
  });
27466
27468
  if (format)
27467
27469
  this.writeProperty("format", format, route, {
27468
- format: TagFormat.plainText
27470
+ format: TagFormat.plainText,
27471
+ forceChain: true
27469
27472
  });
27470
27473
  if (instance5.isBoolean(trim))
27471
27474
  this.writeProperty("trim", trim, route, {
27472
- format: TagFormat.plainText
27475
+ format: TagFormat.plainText,
27476
+ forceChain: true
27473
27477
  });
27474
27478
  }
27475
27479
  return false;
@@ -27480,13 +27484,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27480
27484
  const parent = this.getParentNode(route);
27481
27485
  if (parent?.key !== NodeType.bitsValue) return true;
27482
27486
  const { technicalTerm, lang } = nodeValue;
27483
- this.writeNL();
27484
27487
  this.writeProperty("technicalTerm", technicalTerm, route, {
27485
27488
  format: TagFormat.plainText
27486
27489
  });
27487
27490
  if (lang != null) {
27488
27491
  this.writeProperty("lang", lang, route, {
27489
- format: TagFormat.plainText
27492
+ format: TagFormat.plainText,
27493
+ forceChain: true
27490
27494
  });
27491
27495
  }
27492
27496
  return false;
@@ -27497,28 +27501,31 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27497
27501
  const parent = this.getParentNode(route);
27498
27502
  if (parent?.key !== NodeType.bitsValue) return true;
27499
27503
  const { servings, unit, unitAbbr, decimalPlaces, disableCalculation, hint } = nodeValue;
27500
- this.writeNL();
27501
27504
  this.writeProperty("servings", servings, route, {
27502
27505
  format: TagFormat.plainText
27503
27506
  });
27504
27507
  if (unit != null) {
27505
27508
  this.writeProperty("unit", unit, route, {
27506
- format: TagFormat.plainText
27509
+ format: TagFormat.plainText,
27510
+ forceChain: true
27507
27511
  });
27508
27512
  }
27509
27513
  if (unitAbbr != null) {
27510
27514
  this.writeProperty("unitAbbr", unitAbbr, route, {
27511
- format: TagFormat.plainText
27515
+ format: TagFormat.plainText,
27516
+ forceChain: true
27512
27517
  });
27513
27518
  }
27514
27519
  if (decimalPlaces != null) {
27515
27520
  this.writeProperty("decimalPlaces", decimalPlaces, route, {
27516
- format: TagFormat.plainText
27521
+ format: TagFormat.plainText,
27522
+ forceChain: true
27517
27523
  });
27518
27524
  }
27519
27525
  if (disableCalculation != null) {
27520
27526
  this.writeProperty("disableCalculation", disableCalculation, route, {
27521
- format: TagFormat.plainText
27527
+ format: TagFormat.plainText,
27528
+ forceChain: true
27522
27529
  });
27523
27530
  }
27524
27531
  if (hint != null) {
@@ -27534,13 +27541,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27534
27541
  const parent = this.getParentNode(route);
27535
27542
  if (parent?.key !== NodeType.bitsValue) return true;
27536
27543
  const { name, title, avatarImage } = person;
27537
- this.writeNL();
27538
27544
  this.writeProperty("person", name, route, {
27539
27545
  format: TagFormat.plainText
27540
27546
  });
27541
27547
  if (title) {
27542
27548
  this.writeProperty("title", title, route, {
27543
- format: TagFormat.plainText
27549
+ format: TagFormat.plainText,
27550
+ forceChain: true
27544
27551
  });
27545
27552
  }
27546
27553
  if (avatarImage) {
@@ -27588,7 +27595,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27588
27595
  if (parent.key !== NodeType.term && parent.key !== NodeType.definition && parent.key !== NodeType.alternativeDefinitionsValue && parent.key !== NodeType.question && parent.key !== NodeType.answer && parent.key !== NodeType.alternativeAnswersValue) {
27589
27596
  return true;
27590
27597
  }
27591
- this.writeNL();
27592
27598
  this.writeResource(ResourceType.icon, resource.image.src);
27593
27599
  return true;
27594
27600
  }
@@ -27616,13 +27622,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27616
27622
  if (parent?.key !== NodeType.bitsValue) return true;
27617
27623
  const { level, label } = n;
27618
27624
  const levelKey = node.key === NodeType.ratingLevelStart ? "ratingLevelStart" : "ratingLevelEnd";
27619
- this.writeNL();
27620
27625
  this.writeProperty(levelKey, level, route, {
27621
27626
  format: TagFormat.plainText
27622
27627
  });
27623
27628
  if (label) {
27624
27629
  this.writeProperty("label", label, route, {
27625
- format: TagFormat.bitmarkText
27630
+ format: TagFormat.bitmarkText,
27631
+ forceChain: true
27626
27632
  });
27627
27633
  }
27628
27634
  return false;
@@ -27644,12 +27650,14 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27644
27650
  });
27645
27651
  if (color) {
27646
27652
  this.writeProperty("color", color, route, {
27647
- format: TagFormat.plainText
27653
+ format: TagFormat.plainText,
27654
+ forceChain: true
27648
27655
  });
27649
27656
  }
27650
27657
  if (emphasis) {
27651
27658
  this.writeProperty("emphasis", emphasis, route, {
27652
- format: TagFormat.plainText
27659
+ format: TagFormat.plainText,
27660
+ forceChain: true
27653
27661
  });
27654
27662
  }
27655
27663
  }
@@ -27658,7 +27666,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27658
27666
  // bitmarkAst -> bits -> bitsValue -> partialAnswer
27659
27667
  enter_partialAnswer(node, route) {
27660
27668
  if (node.value) {
27661
- this.writeNL();
27662
27669
  this.writeProperty("partialAnswer", node.value, route, {
27663
27670
  format: TagFormat.plainText
27664
27671
  });
@@ -27668,7 +27675,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27668
27675
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> partialAnswer
27669
27676
  leaf_partialAnswer(node, route) {
27670
27677
  if (node.value) {
27671
- this.writeNL();
27672
27678
  this.writeProperty("partialAnswer", node.value, route, {
27673
27679
  format: TagFormat.plainText
27674
27680
  });
@@ -27679,7 +27685,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27679
27685
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> sampleSolution
27680
27686
  enter_sampleSolution(node, route) {
27681
27687
  if (node.value) {
27682
- this.writeNL();
27683
27688
  this.writeProperty("sampleSolution", node.value, route, {
27684
27689
  format: TagFormat.plainText
27685
27690
  });
@@ -27688,7 +27693,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27688
27693
  }
27689
27694
  leaf_sampleSolution(node, route) {
27690
27695
  if (node.value) {
27691
- this.writeNL();
27692
27696
  this.writeProperty("sampleSolution", node.value, route, {
27693
27697
  format: TagFormat.plainText
27694
27698
  });
@@ -27698,7 +27702,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27698
27702
  // bitmarkAst -> bits -> bitsValue -> reasonableNumOfChars
27699
27703
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> reasonableNumOfChars
27700
27704
  leaf_reasonableNumOfChars(node, route) {
27701
- this.writeNL();
27702
27705
  this.writeProperty("reasonableNumOfChars", node.value, route, {
27703
27706
  format: TagFormat.plainText
27704
27707
  });
@@ -28705,7 +28708,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28705
28708
  // bitmarkAst -> bits -> bitsValue -> * -> lang
28706
28709
  leaf_lang(node, route) {
28707
28710
  if (!node.value) return;
28708
- this.writeNL();
28709
28711
  this.writeProperty("lang", node.value, route, {
28710
28712
  format: TagFormat.boolean
28711
28713
  });
@@ -28713,7 +28715,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28713
28715
  // bitmarkAst -> bits -> bitsValue -> * -> refAuthor
28714
28716
  enter_refAuthor(node, route) {
28715
28717
  if (!node.value) return;
28716
- this.writeNL();
28717
28718
  this.writeProperty("refAuthor", node.value, route, {
28718
28719
  format: TagFormat.plainText,
28719
28720
  array: true
@@ -28722,7 +28723,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28722
28723
  // bitmarkAst -> bits -> bitsValue -> * -> refBookTitle
28723
28724
  leaf_refBookTitle(node, route) {
28724
28725
  if (!node.value) return;
28725
- this.writeNL();
28726
28726
  this.writeProperty("refBookTitle", node.value, route, {
28727
28727
  format: TagFormat.plainText,
28728
28728
  array: true
@@ -28731,7 +28731,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28731
28731
  // bitmarkAst -> bits -> bitsValue -> * -> refPublisher
28732
28732
  enter_refPublisher(node, route) {
28733
28733
  if (!node.value) return;
28734
- this.writeNL();
28735
28734
  this.writeProperty("refPublisher", node.value, route, {
28736
28735
  format: TagFormat.plainText,
28737
28736
  array: true
@@ -28740,7 +28739,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28740
28739
  // bitmarkAst -> bits -> bitsValue -> * -> refPublicationYear
28741
28740
  leaf_refPublicationYear(node, route) {
28742
28741
  if (!node.value) return;
28743
- this.writeNL();
28744
28742
  this.writeProperty("refPublicationYear", node.value, route, {
28745
28743
  format: TagFormat.plainText
28746
28744
  });
@@ -28748,7 +28746,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28748
28746
  // bitmarkAst -> bits -> bitsValue -> * -> citationStyle
28749
28747
  leaf_citationStyle(node, route) {
28750
28748
  if (!node.value) return;
28751
- this.writeNL();
28752
28749
  this.writeProperty("citationStyle", node.value, route, {
28753
28750
  format: TagFormat.plainText
28754
28751
  });
@@ -29080,7 +29077,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
29080
29077
  const config = instance2.getBitConfig(bitType);
29081
29078
  const propertyConfig = instance2.getTagConfigForTag(config.tags, propertyConfigKey);
29082
29079
  if (!propertyConfig) return;
29083
- this.writeNL_IfNotChain(route);
29084
29080
  this.writeProperty(propertyConfig.tag, node.value, route, {
29085
29081
  format: propertyConfig.format ?? TagFormat.plainText,
29086
29082
  array: propertyConfig.array ?? false,
@@ -29464,7 +29460,7 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
29464
29460
  if (options.ignoreFalse && val === false) continue;
29465
29461
  if (options.ignoreTrue && val === true) continue;
29466
29462
  if (!options.writeEmpty && val === "") continue;
29467
- if (propertyIndex > 0) this.writeNL_IfNotChain(route);
29463
+ if (!options.forceChain && propertyIndex === 0) this.writeNL_IfNotChain(route);
29468
29464
  this.writeOPA();
29469
29465
  this.writeTagKey(name);
29470
29466
  this.writeColon();
@@ -30737,7 +30733,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
30737
30733
  }
30738
30734
  if (instance2.isOfBitType(bitType, BitType.book)) {
30739
30735
  if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
30740
- if (bitJson.allowPrint == null) bitJson.allowPrint = false;
30736
+ if (bitJson.allowPrint == null) bitJson.allowPrint = "enforceFalse";
30741
30737
  if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
30742
30738
  if (bitJson.enforceUpdateOverUserInput == null) bitJson.enforceUpdateOverUserInput = false;
30743
30739
  if (bitJson.hasMarkAsDone == null) bitJson.hasMarkAsDone = false;
@@ -34479,6 +34475,7 @@ function propertyContentProcessor(context, contentDepth, tagsConfig, content, ta
34479
34475
  chain: void 0,
34480
34476
  jsonKey: void 0,
34481
34477
  format: TagFormat.bitmarkText,
34478
+ values: void 0,
34482
34479
  defaultValue: void 0,
34483
34480
  deprecated: void 0
34484
34481
  })