@gmb/bitmark-parser-generator 5.1.0 → 5.2.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
@@ -655,6 +655,7 @@ var BitType = {
655
655
  trueFalse: "true-false",
656
656
  trueFalse1: "true-false-1",
657
657
  vendorAmcharts5Chart: "vendor-amcharts-5-chart",
658
+ vendorDatadogDashboard: "vendor-datadog-dashboard",
658
659
  vendorDatadogDashboardEmbed: "vendor-datadog-dashboard-embed",
659
660
  vendorFormbricksEmbed: "vendor-formbricks-embed",
660
661
  vendorFormbricksLink: "vendor-formbricks-link",
@@ -1294,6 +1295,7 @@ var propertyKeys = {
1294
1295
  property_internalComment: "@internalComment",
1295
1296
  property_internalPrintPdf: "@internalPrintPdf",
1296
1297
  property_hasPrintRestriction: "@hasPrintRestriction",
1298
+ property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
1297
1299
  property_isCaseSensitive: "@isCaseSensitive",
1298
1300
  property_isInfoOnly: "@isInfoOnly",
1299
1301
  property_isPublic: "@isPublic",
@@ -1320,6 +1322,7 @@ var propertyKeys = {
1320
1322
  property_listItemIndent: "@listItemIndent",
1321
1323
  property_location: "@location",
1322
1324
  property_machineTranslated: "@machineTranslated",
1325
+ property_translationOf: "@translationOf",
1323
1326
  property_spansPageBreak: "@spansPageBreak",
1324
1327
  property_mailingList: "@mailingList",
1325
1328
  property_mark: "@mark",
@@ -2807,6 +2810,11 @@ var GROUPS = {
2807
2810
  description: "If true, the bit is machine-translated",
2808
2811
  format: TagFormat.plainText
2809
2812
  },
2813
+ {
2814
+ key: ConfigKey.property_translationOf,
2815
+ description: "Translation source reference",
2816
+ format: TagFormat.plainText
2817
+ },
2810
2818
  {
2811
2819
  key: ConfigKey.property_spansPageBreak,
2812
2820
  description: "If true, the bit spans a page break",
@@ -3457,6 +3465,12 @@ var GROUPS = {
3457
3465
  description: "If true, the book has print restrictions",
3458
3466
  format: TagFormat.boolean,
3459
3467
  defaultValue: "true"
3468
+ },
3469
+ {
3470
+ key: ConfigKey.property_enforceUpdateOverUserInput,
3471
+ description: "If true, prioritize new content over legacy content from the instance API",
3472
+ format: TagFormat.boolean,
3473
+ defaultValue: "false"
3460
3474
  }
3461
3475
  ]
3462
3476
  },
@@ -9645,6 +9659,11 @@ var BITS = {
9645
9659
  description: "AmCharts 5 chart bit, used to embed AmCharts 5 charts in articles or books",
9646
9660
  textFormatDefault: TextFormat.json
9647
9661
  },
9662
+ [BitType.vendorDatadogDashboard]: {
9663
+ since: "5.2.0",
9664
+ baseBitType: BitType.nonProductionPrototypeIframe,
9665
+ description: "A Datadog dashboard bit, used to embed Datadog dashboards"
9666
+ },
9648
9667
  [BitType.vendorDatadogDashboardEmbed]: {
9649
9668
  since: "3.12.0",
9650
9669
  baseBitType: BitType.code,
@@ -10274,7 +10293,7 @@ var instance2 = new Config();
10274
10293
  // src/generated/package_info.ts
10275
10294
  var PACKAGE_INFO = {
10276
10295
  "name": "@gmb/bitmark-parser-generator",
10277
- "version": "5.1.0",
10296
+ "version": "5.2.0",
10278
10297
  "author": "Get More Brain Ltd",
10279
10298
  "license": "ISC",
10280
10299
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10895,6 +10914,8 @@ var NodeType = {
10895
10914
  internalPrintPdfValue: "internalPrintPdfValue",
10896
10915
  hasPrintRestriction: "hasPrintRestriction",
10897
10916
  hasPrintRestrictionValue: "hasPrintRestrictionValue",
10917
+ enforceUpdateOverUserInput: "enforceUpdateOverUserInput",
10918
+ enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue",
10898
10919
  isCaseSensitive: "isCaseSensitive",
10899
10920
  isCommented: "isCommented",
10900
10921
  isCorrect: "isCorrect",
@@ -10961,6 +10982,8 @@ var NodeType = {
10961
10982
  locationValue: "locationValue",
10962
10983
  machineTranslated: "machineTranslated",
10963
10984
  machineTranslatedValue: "machineTranslatedValue",
10985
+ translationOf: "translationOf",
10986
+ translationOfValue: "translationOfValue",
10964
10987
  spansPageBreak: "spansPageBreak",
10965
10988
  spansPageBreakValue: "spansPageBreakValue",
10966
10989
  mailingList: "mailingList",
@@ -12080,7 +12103,7 @@ var Stage = {
12080
12103
  between: "between",
12081
12104
  exit: "exit"
12082
12105
  };
12083
- var TextGenerator = class extends AstWalkerGenerator {
12106
+ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
12084
12107
  /**
12085
12108
  * Generate text from a bitmark text AST
12086
12109
  *
@@ -12092,6 +12115,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12092
12115
  __publicField(this, "ast", new Ast());
12093
12116
  __publicField(this, "bitmarkVersion");
12094
12117
  __publicField(this, "options");
12118
+ __publicField(this, "internalTextGenerator", null);
12095
12119
  // State
12096
12120
  __publicField(this, "generateOptions", {});
12097
12121
  __publicField(this, "textFormat", TextFormat.bitmarkText);
@@ -12107,6 +12131,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12107
12131
  __publicField(this, "exitedCodeBlock", false);
12108
12132
  __publicField(this, "inBulletList", false);
12109
12133
  __publicField(this, "inInline", false);
12134
+ __publicField(this, "markDepth", 0);
12110
12135
  __publicField(this, "textDepth", 0);
12111
12136
  __publicField(this, "placeholderIndex", 0);
12112
12137
  __publicField(this, "placeholders", {});
@@ -12131,6 +12156,13 @@ var TextGenerator = class extends AstWalkerGenerator {
12131
12156
  this.between = this.between.bind(this);
12132
12157
  this.exit = this.exit.bind(this);
12133
12158
  this.leaf = this.leaf.bind(this);
12159
+ if (!this.options.isInternal) {
12160
+ this.internalTextGenerator = new _TextGenerator(bitmarkVersion, {
12161
+ ...this.options,
12162
+ writeCallback: void 0,
12163
+ isInternal: true
12164
+ });
12165
+ }
12134
12166
  }
12135
12167
  /**
12136
12168
  * Generate text from a bitmark text AST
@@ -12187,6 +12219,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12187
12219
  this.exitedCodeBlock = false;
12188
12220
  this.inBulletList = false;
12189
12221
  this.inInline = false;
12222
+ this.markDepth = 0;
12190
12223
  this.textDepth = 0;
12191
12224
  this.placeholderIndex = 0;
12192
12225
  this.placeholders = {};
@@ -12234,8 +12267,16 @@ var TextGenerator = class extends AstWalkerGenerator {
12234
12267
  exit_contentValueValue(node, route) {
12235
12268
  return this.handleExitNode(node.value, route);
12236
12269
  }
12270
+ // * -> marks
12271
+ enter_marks(_node, _route) {
12272
+ this.markDepth++;
12273
+ }
12274
+ exit_marks(_node, _route) {
12275
+ this.markDepth--;
12276
+ }
12237
12277
  // END NODE HANDLERS
12238
12278
  handleEnterNode(node, route) {
12279
+ if (this.markDepth > 0) return;
12239
12280
  this.handleEnterNodePreTextCheck(node, route);
12240
12281
  this.handleIndent(node);
12241
12282
  switch (node.type) {
@@ -12246,7 +12287,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12246
12287
  case TextNodeType.hardBreak:
12247
12288
  this.writeHardBreak(node);
12248
12289
  break;
12249
- case TextNodeType.text:
12290
+ case TextNodeType.text: {
12250
12291
  this.writeMarks(node, Stage.enter);
12251
12292
  this.writeText(node);
12252
12293
  this.writeMarks(node, Stage.between);
@@ -12255,6 +12296,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12255
12296
  }
12256
12297
  this.textDepth++;
12257
12298
  break;
12299
+ }
12258
12300
  case TextNodeType.heading:
12259
12301
  this.writeHeading(node);
12260
12302
  this.inHeading = true;
@@ -12305,6 +12347,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12305
12347
  }
12306
12348
  }
12307
12349
  handleExitNode(node, _route) {
12350
+ if (this.markDepth > 0) return;
12308
12351
  switch (node.type) {
12309
12352
  case TextNodeType.text:
12310
12353
  this.textDepth--;
@@ -12611,7 +12654,7 @@ var TextGenerator = class extends AstWalkerGenerator {
12611
12654
  */
12612
12655
  writeMarks(node, stage) {
12613
12656
  if (node.marks) {
12614
- const forceSingleMark = !!(this.inInline || this.inHeading);
12657
+ const forceSingleMark = this.generateOptions.forceInline || !!(this.inInline || this.inHeading);
12615
12658
  this.thisNodeIsPreText = false;
12616
12659
  const emptyMarks = node.marks.length === 0;
12617
12660
  if (emptyMarks) {
@@ -12842,13 +12885,33 @@ var TextGenerator = class extends AstWalkerGenerator {
12842
12885
  s += `|provider:${provider}`;
12843
12886
  this.write(s);
12844
12887
  }
12845
- writeFootnoteMark(_mark) {
12888
+ writeFootnoteMark(mark) {
12846
12889
  const s = `footnote:`;
12847
12890
  this.write(s);
12891
+ const text = this.internalTextGenerator?.generateSync(
12892
+ mark.attrs?.content,
12893
+ this.textFormat,
12894
+ this.textLocation,
12895
+ {
12896
+ ...this.generateOptions,
12897
+ forceInline: true
12898
+ }
12899
+ ) ?? "";
12900
+ this.write(text);
12848
12901
  }
12849
- writeFootnoteStarMark(_mark) {
12902
+ writeFootnoteStarMark(mark) {
12850
12903
  const s = `footnote*:`;
12851
12904
  this.write(s);
12905
+ const text = this.internalTextGenerator?.generateSync(
12906
+ mark.attrs?.content,
12907
+ this.textFormat,
12908
+ this.textLocation,
12909
+ {
12910
+ ...this.generateOptions,
12911
+ forceInline: true
12912
+ }
12913
+ ) ?? "";
12914
+ this.write(text);
12852
12915
  }
12853
12916
  writeSymbolMark(mark) {
12854
12917
  if (mark.attrs == null) return;
@@ -24005,6 +24068,12 @@ var Builder = class extends BaseBuilder {
24005
24068
  data.machineTranslated,
24006
24069
  options
24007
24070
  ),
24071
+ translationOf: this.toAstProperty(
24072
+ bitType,
24073
+ ConfigKey.property_translationOf,
24074
+ data.translationOf,
24075
+ options
24076
+ ),
24008
24077
  spansPageBreak: this.toAstProperty(
24009
24078
  bitType,
24010
24079
  ConfigKey.property_spansPageBreak,
@@ -24721,6 +24790,12 @@ var Builder = class extends BaseBuilder {
24721
24790
  data.hasPrintRestriction,
24722
24791
  options
24723
24792
  ),
24793
+ enforceUpdateOverUserInput: this.toAstProperty(
24794
+ bitType,
24795
+ ConfigKey.property_enforceUpdateOverUserInput,
24796
+ data.enforceUpdateOverUserInput,
24797
+ options
24798
+ ),
24724
24799
  tocResource: this.toAstProperty(
24725
24800
  bitType,
24726
24801
  ConfigKey.property_tocResource,
@@ -30421,6 +30496,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
30421
30496
  if (instance2.isOfBitType(bitType, BitType.book)) {
30422
30497
  if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
30423
30498
  if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
30499
+ if (bitJson.enforceUpdateOverUserInput == null) bitJson.enforceUpdateOverUserInput = false;
30424
30500
  if (bitJson.hasMarkAsDone == null) bitJson.hasMarkAsDone = false;
30425
30501
  if (bitJson.processHandIn == null) bitJson.processHandIn = false;
30426
30502
  if (bitJson.isPublic == null) bitJson.isPublic = false;