@gmb/bitmark-parser-generator 5.9.1 → 5.11.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/cli/main.js CHANGED
@@ -677,8 +677,10 @@ var TagFormat = {
677
677
  // If the value is treated as a number
678
678
  boolean: "boolean",
679
679
  // If the value is treated as a boolean
680
- invertedBoolean: "invertedBoolean"
680
+ invertedBoolean: "invertedBoolean",
681
681
  // If the value is treated as a boolean with the value inverted (e.g. isLongAnswer ==> isShortAnswer = false)
682
+ enumeration: "enumeration"
683
+ // If the value is treated as an enumeration (the value is a string that must be one of a predefined set of values)
682
684
  };
683
685
  var TextFormat = {
684
686
  // plain text
@@ -804,6 +806,8 @@ var PropertyTagConfig = class extends AbstractTagConfig {
804
806
  // If the property is treated as an array rather than a single value
805
807
  format;
806
808
  // How the property is formatted
809
+ values;
810
+ // If the format is an enumeration, the possible values of the property
807
811
  defaultValue;
808
812
  // The default value of the property - this value can be omitted from the markup
809
813
  constructor(params) {
@@ -813,6 +817,7 @@ var PropertyTagConfig = class extends AbstractTagConfig {
813
817
  });
814
818
  this.array = params.maxCount === Count.infinity || params.maxCount > 1;
815
819
  this.format = params.format;
820
+ this.values = params.values;
816
821
  this.defaultValue = params.defaultValue;
817
822
  }
818
823
  toString(options) {
@@ -824,6 +829,7 @@ var PropertyTagConfig = class extends AbstractTagConfig {
824
829
  if (this.minCount != null) s += `, min=${this.minCount}`;
825
830
  if (this.array != null) s += `, arr=${this.array}`;
826
831
  if (this.format != null) s += `, fmt=${this.format}`;
832
+ if (this.values != null) s += `, vals=[${this.values.join(",")}]`;
827
833
  if (this.defaultValue != null) s += `, def=${this.defaultValue}`;
828
834
  if (this.jsonKey != null) s += `, json=${this.jsonKey}`;
829
835
  }
@@ -1108,7 +1114,6 @@ var propertyKeys = {
1108
1114
  property_aiGenerated: "@aiGenerated",
1109
1115
  property_allowedBit: "@allowedBit",
1110
1116
  property_allowPrint: "@allowPrint",
1111
- property_allowPrintEnforceSpaceConfiguration: "@allowPrintEnforceSpaceConfiguration",
1112
1117
  property_allowSubtitles: "@allowSubtitles",
1113
1118
  property_alt: "@alt",
1114
1119
  property_altLangTag: "@altLangTag",
@@ -3380,14 +3385,9 @@ var GROUPS = {
3380
3385
  {
3381
3386
  key: ConfigKey.property_allowPrint,
3382
3387
  description: "If true, the book allows printing",
3383
- format: TagFormat.boolean,
3384
- defaultValue: "false"
3385
- },
3386
- {
3387
- key: ConfigKey.property_allowPrintEnforceSpaceConfiguration,
3388
- description: "If true, enforces space configuration for printing regardless of the allowPrint setting",
3389
- format: TagFormat.boolean,
3390
- defaultValue: "false"
3388
+ format: TagFormat.enumeration,
3389
+ values: ["enforceFalse", "enforceTrue", "useSpaceConfiguration"],
3390
+ defaultValue: "useSpaceConfiguration"
3391
3391
  },
3392
3392
  {
3393
3393
  key: ConfigKey.property_hasPrintRestriction,
@@ -4363,6 +4363,7 @@ var ConfigHydrator = class {
4363
4363
  chain: _chain,
4364
4364
  deprecated,
4365
4365
  format,
4366
+ values,
4366
4367
  defaultValue,
4367
4368
  jsonKey
4368
4369
  } = _tag;
@@ -4381,6 +4382,7 @@ var ConfigHydrator = class {
4381
4382
  chain,
4382
4383
  jsonKey,
4383
4384
  format,
4385
+ values,
4384
4386
  defaultValue,
4385
4387
  deprecated
4386
4388
  });
@@ -10356,7 +10358,7 @@ var instance2 = new Config();
10356
10358
  // src/generated/package_info.ts
10357
10359
  var PACKAGE_INFO = {
10358
10360
  "name": "@gmb/bitmark-parser-generator",
10359
- "version": "5.9.1",
10361
+ "version": "5.11.0",
10360
10362
  "license": "ISC"};
10361
10363
  var Environment = {
10362
10364
  unknown: "",
@@ -10945,6 +10947,8 @@ var NodeType = {
10945
10947
  indexValue: "indexValue",
10946
10948
  ingredients: "ingredients",
10947
10949
  ingredientsValue: "ingredientsValue",
10950
+ ingredient: "ingredient",
10951
+ ingredientValue: "ingredientValue",
10948
10952
  instruction: "instruction",
10949
10953
  instructionValue: "instructionValue",
10950
10954
  internalComment: "internalComment",
@@ -11257,6 +11261,7 @@ var NodeType = {
11257
11261
  srcAltValue: "srcAltValue",
11258
11262
  start: "start",
11259
11263
  statement: "statement",
11264
+ statementValue: "statementValue",
11260
11265
  statements: "statements",
11261
11266
  statementsValue: "statementsValue",
11262
11267
  statementText: "statementText",
@@ -24703,12 +24708,6 @@ var Builder = class extends BaseBuilder {
24703
24708
  data.allowPrint,
24704
24709
  options
24705
24710
  ),
24706
- allowPrintEnforceSpaceConfiguration: this.toAstProperty(
24707
- bitType,
24708
- ConfigKey.property_allowPrintEnforceSpaceConfiguration,
24709
- data.allowPrintEnforceSpaceConfiguration,
24710
- options
24711
- ),
24712
24711
  printParentChapterLevel: this.toAstProperty(
24713
24712
  bitType,
24714
24713
  ConfigKey.property_printParentChapterLevel,
@@ -27068,7 +27067,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27068
27067
  if (parent?.key !== NodeType.bitsValue) return true;
27069
27068
  for (const gt of groupTag) {
27070
27069
  const { name, tags: tags2 } = gt;
27071
- this.writeNL();
27072
27070
  this.writeProperty("groupTag", name, route, {
27073
27071
  format: TagFormat.plainText,
27074
27072
  writeEmpty: true
@@ -27077,7 +27075,8 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27077
27075
  for (const t of tags2) {
27078
27076
  this.writeProperty("tag", t, route, {
27079
27077
  format: TagFormat.plainText,
27080
- writeEmpty: true
27078
+ writeEmpty: true,
27079
+ forceChain: true
27081
27080
  });
27082
27081
  }
27083
27082
  }
@@ -27085,7 +27084,7 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27085
27084
  return false;
27086
27085
  }
27087
27086
  // bitmarkAst -> bits -> bitsValue -> labelTrue / labelFalse
27088
- enter_labelTrue(node, route) {
27087
+ leaf_labelTrue(node, route) {
27089
27088
  const value = node.value;
27090
27089
  const parent = this.getParentNode(route);
27091
27090
  if (parent?.key !== NodeType.bitsValue) return true;
@@ -27098,16 +27097,18 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27098
27097
  }
27099
27098
  if (haveTrue)
27100
27099
  this.writeProperty("labelTrue", value, route, {
27101
- format: TagFormat.plainText
27100
+ format: TagFormat.plainText,
27101
+ forceChain: true
27102
27102
  });
27103
27103
  if (haveFalse)
27104
27104
  this.writeProperty("labelFalse", bit.labelFalse, route, {
27105
- format: TagFormat.plainText
27105
+ format: TagFormat.plainText,
27106
+ forceChain: true
27106
27107
  });
27107
27108
  }
27108
27109
  return false;
27109
27110
  }
27110
- enter_labelFalse(_node, _route) {
27111
+ leaf_labelFalse(_node, _route) {
27111
27112
  return true;
27112
27113
  }
27113
27114
  // bitmarkAst -> bits -> bitsValue -> imageSource
@@ -27116,26 +27117,29 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27116
27117
  const parent = this.getParentNode(route);
27117
27118
  if (parent?.key !== NodeType.bitsValue) return true;
27118
27119
  const { url, mockupId, size, format, trim } = imageSource;
27119
- this.writeNL();
27120
27120
  this.writeProperty("imageSource", url, route, {
27121
27121
  format: TagFormat.plainText
27122
27122
  });
27123
27123
  if (url) {
27124
27124
  if (mockupId)
27125
27125
  this.writeProperty("mockupId", mockupId, route, {
27126
- format: TagFormat.plainText
27126
+ format: TagFormat.plainText,
27127
+ forceChain: true
27127
27128
  });
27128
27129
  if (size)
27129
27130
  this.writeProperty("size", size, route, {
27130
- format: TagFormat.plainText
27131
+ format: TagFormat.plainText,
27132
+ forceChain: true
27131
27133
  });
27132
27134
  if (format)
27133
27135
  this.writeProperty("format", format, route, {
27134
- format: TagFormat.plainText
27136
+ format: TagFormat.plainText,
27137
+ forceChain: true
27135
27138
  });
27136
27139
  if (instance5.isBoolean(trim))
27137
27140
  this.writeProperty("trim", trim, route, {
27138
- format: TagFormat.plainText
27141
+ format: TagFormat.plainText,
27142
+ forceChain: true
27139
27143
  });
27140
27144
  }
27141
27145
  return false;
@@ -27146,13 +27150,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27146
27150
  const parent = this.getParentNode(route);
27147
27151
  if (parent?.key !== NodeType.bitsValue) return true;
27148
27152
  const { technicalTerm, lang } = nodeValue;
27149
- this.writeNL();
27150
27153
  this.writeProperty("technicalTerm", technicalTerm, route, {
27151
27154
  format: TagFormat.plainText
27152
27155
  });
27153
27156
  if (lang != null) {
27154
27157
  this.writeProperty("lang", lang, route, {
27155
- format: TagFormat.plainText
27158
+ format: TagFormat.plainText,
27159
+ forceChain: true
27156
27160
  });
27157
27161
  }
27158
27162
  return false;
@@ -27163,28 +27167,31 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27163
27167
  const parent = this.getParentNode(route);
27164
27168
  if (parent?.key !== NodeType.bitsValue) return true;
27165
27169
  const { servings, unit, unitAbbr, decimalPlaces, disableCalculation, hint } = nodeValue;
27166
- this.writeNL();
27167
27170
  this.writeProperty("servings", servings, route, {
27168
27171
  format: TagFormat.plainText
27169
27172
  });
27170
27173
  if (unit != null) {
27171
27174
  this.writeProperty("unit", unit, route, {
27172
- format: TagFormat.plainText
27175
+ format: TagFormat.plainText,
27176
+ forceChain: true
27173
27177
  });
27174
27178
  }
27175
27179
  if (unitAbbr != null) {
27176
27180
  this.writeProperty("unitAbbr", unitAbbr, route, {
27177
- format: TagFormat.plainText
27181
+ format: TagFormat.plainText,
27182
+ forceChain: true
27178
27183
  });
27179
27184
  }
27180
27185
  if (decimalPlaces != null) {
27181
27186
  this.writeProperty("decimalPlaces", decimalPlaces, route, {
27182
- format: TagFormat.plainText
27187
+ format: TagFormat.plainText,
27188
+ forceChain: true
27183
27189
  });
27184
27190
  }
27185
27191
  if (disableCalculation != null) {
27186
27192
  this.writeProperty("disableCalculation", disableCalculation, route, {
27187
- format: TagFormat.plainText
27193
+ format: TagFormat.plainText,
27194
+ forceChain: true
27188
27195
  });
27189
27196
  }
27190
27197
  if (hint != null) {
@@ -27200,13 +27207,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27200
27207
  const parent = this.getParentNode(route);
27201
27208
  if (parent?.key !== NodeType.bitsValue) return true;
27202
27209
  const { name, title, avatarImage } = person;
27203
- this.writeNL();
27204
27210
  this.writeProperty("person", name, route, {
27205
27211
  format: TagFormat.plainText
27206
27212
  });
27207
27213
  if (title) {
27208
27214
  this.writeProperty("title", title, route, {
27209
- format: TagFormat.plainText
27215
+ format: TagFormat.plainText,
27216
+ forceChain: true
27210
27217
  });
27211
27218
  }
27212
27219
  if (avatarImage) {
@@ -27254,7 +27261,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27254
27261
  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) {
27255
27262
  return true;
27256
27263
  }
27257
- this.writeNL();
27258
27264
  this.writeResource(ResourceType.icon, resource.image.src);
27259
27265
  return true;
27260
27266
  }
@@ -27282,13 +27288,13 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27282
27288
  if (parent?.key !== NodeType.bitsValue) return true;
27283
27289
  const { level, label } = n;
27284
27290
  const levelKey = node.key === NodeType.ratingLevelStart ? "ratingLevelStart" : "ratingLevelEnd";
27285
- this.writeNL();
27286
27291
  this.writeProperty(levelKey, level, route, {
27287
27292
  format: TagFormat.plainText
27288
27293
  });
27289
27294
  if (label) {
27290
27295
  this.writeProperty("label", label, route, {
27291
- format: TagFormat.bitmarkText
27296
+ format: TagFormat.bitmarkText,
27297
+ forceChain: true
27292
27298
  });
27293
27299
  }
27294
27300
  return false;
@@ -27310,12 +27316,14 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27310
27316
  });
27311
27317
  if (color) {
27312
27318
  this.writeProperty("color", color, route, {
27313
- format: TagFormat.plainText
27319
+ format: TagFormat.plainText,
27320
+ forceChain: true
27314
27321
  });
27315
27322
  }
27316
27323
  if (emphasis) {
27317
27324
  this.writeProperty("emphasis", emphasis, route, {
27318
- format: TagFormat.plainText
27325
+ format: TagFormat.plainText,
27326
+ forceChain: true
27319
27327
  });
27320
27328
  }
27321
27329
  }
@@ -27324,7 +27332,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27324
27332
  // bitmarkAst -> bits -> bitsValue -> partialAnswer
27325
27333
  enter_partialAnswer(node, route) {
27326
27334
  if (node.value) {
27327
- this.writeNL();
27328
27335
  this.writeProperty("partialAnswer", node.value, route, {
27329
27336
  format: TagFormat.plainText
27330
27337
  });
@@ -27334,7 +27341,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27334
27341
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> partialAnswer
27335
27342
  leaf_partialAnswer(node, route) {
27336
27343
  if (node.value) {
27337
- this.writeNL();
27338
27344
  this.writeProperty("partialAnswer", node.value, route, {
27339
27345
  format: TagFormat.plainText
27340
27346
  });
@@ -27345,7 +27351,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27345
27351
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> sampleSolution
27346
27352
  enter_sampleSolution(node, route) {
27347
27353
  if (node.value) {
27348
- this.writeNL();
27349
27354
  this.writeProperty("sampleSolution", node.value, route, {
27350
27355
  format: TagFormat.plainText
27351
27356
  });
@@ -27354,7 +27359,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27354
27359
  }
27355
27360
  leaf_sampleSolution(node, route) {
27356
27361
  if (node.value) {
27357
- this.writeNL();
27358
27362
  this.writeProperty("sampleSolution", node.value, route, {
27359
27363
  format: TagFormat.plainText
27360
27364
  });
@@ -27364,7 +27368,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27364
27368
  // bitmarkAst -> bits -> bitsValue -> reasonableNumOfChars
27365
27369
  // bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> reasonableNumOfChars
27366
27370
  leaf_reasonableNumOfChars(node, route) {
27367
- this.writeNL();
27368
27371
  this.writeProperty("reasonableNumOfChars", node.value, route, {
27369
27372
  format: TagFormat.plainText
27370
27373
  });
@@ -28368,7 +28371,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28368
28371
  // bitmarkAst -> bits -> bitsValue -> * -> lang
28369
28372
  leaf_lang(node, route) {
28370
28373
  if (!node.value) return;
28371
- this.writeNL();
28372
28374
  this.writeProperty("lang", node.value, route, {
28373
28375
  format: TagFormat.boolean
28374
28376
  });
@@ -28376,7 +28378,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28376
28378
  // bitmarkAst -> bits -> bitsValue -> * -> refAuthor
28377
28379
  enter_refAuthor(node, route) {
28378
28380
  if (!node.value) return;
28379
- this.writeNL();
28380
28381
  this.writeProperty("refAuthor", node.value, route, {
28381
28382
  format: TagFormat.plainText,
28382
28383
  array: true
@@ -28385,7 +28386,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28385
28386
  // bitmarkAst -> bits -> bitsValue -> * -> refBookTitle
28386
28387
  leaf_refBookTitle(node, route) {
28387
28388
  if (!node.value) return;
28388
- this.writeNL();
28389
28389
  this.writeProperty("refBookTitle", node.value, route, {
28390
28390
  format: TagFormat.plainText,
28391
28391
  array: true
@@ -28394,7 +28394,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28394
28394
  // bitmarkAst -> bits -> bitsValue -> * -> refPublisher
28395
28395
  enter_refPublisher(node, route) {
28396
28396
  if (!node.value) return;
28397
- this.writeNL();
28398
28397
  this.writeProperty("refPublisher", node.value, route, {
28399
28398
  format: TagFormat.plainText,
28400
28399
  array: true
@@ -28403,7 +28402,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28403
28402
  // bitmarkAst -> bits -> bitsValue -> * -> refPublicationYear
28404
28403
  leaf_refPublicationYear(node, route) {
28405
28404
  if (!node.value) return;
28406
- this.writeNL();
28407
28405
  this.writeProperty("refPublicationYear", node.value, route, {
28408
28406
  format: TagFormat.plainText
28409
28407
  });
@@ -28411,7 +28409,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28411
28409
  // bitmarkAst -> bits -> bitsValue -> * -> citationStyle
28412
28410
  leaf_citationStyle(node, route) {
28413
28411
  if (!node.value) return;
28414
- this.writeNL();
28415
28412
  this.writeProperty("citationStyle", node.value, route, {
28416
28413
  format: TagFormat.plainText
28417
28414
  });
@@ -28742,7 +28739,6 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28742
28739
  const config = instance2.getBitConfig(bitType);
28743
28740
  const propertyConfig = instance2.getTagConfigForTag(config.tags, propertyConfigKey);
28744
28741
  if (!propertyConfig) return;
28745
- this.writeNL_IfNotChain(route);
28746
28742
  this.writeProperty(propertyConfig.tag, node.value, route, {
28747
28743
  format: propertyConfig.format ?? TagFormat.plainText,
28748
28744
  array: propertyConfig.array ?? false,
@@ -29123,7 +29119,7 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
29123
29119
  if (options.ignoreFalse && val === false) continue;
29124
29120
  if (options.ignoreTrue && val === true) continue;
29125
29121
  if (!options.writeEmpty && val === "") continue;
29126
- if (propertyIndex > 0) this.writeNL_IfNotChain(route);
29122
+ if (!options.forceChain && propertyIndex === 0) this.writeNL_IfNotChain(route);
29127
29123
  this.writeOPA();
29128
29124
  this.writeTagKey(name);
29129
29125
  this.writeColon();
@@ -30391,7 +30387,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
30391
30387
  }
30392
30388
  if (instance2.isOfBitType(bitType, BitType.book)) {
30393
30389
  if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
30394
- if (bitJson.allowPrint == null) bitJson.allowPrint = false;
30390
+ if (bitJson.allowPrint == null) bitJson.allowPrint = "useSpaceConfiguration";
30395
30391
  if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
30396
30392
  if (bitJson.enforceUpdateOverUserInput == null) bitJson.enforceUpdateOverUserInput = false;
30397
30393
  if (bitJson.hasMarkAsDone == null) bitJson.hasMarkAsDone = false;
@@ -34038,6 +34034,7 @@ function propertyContentProcessor(context, contentDepth, tagsConfig, content, ta
34038
34034
  chain: void 0,
34039
34035
  jsonKey: void 0,
34040
34036
  format: TagFormat.bitmarkText,
34037
+ values: void 0,
34041
34038
  defaultValue: void 0,
34042
34039
  deprecated: void 0
34043
34040
  })