@gmb/bitmark-parser-generator 4.14.1 → 4.15.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
@@ -181,6 +181,9 @@ var BitType = (0, import_superenum.superenum)({
181
181
  bugAlt: "bug-alt",
182
182
  bugCollapsible: "bug-collapsible",
183
183
  buttonCopyText: "button-copy-text",
184
+ catalogItemBook: "catalog-item-book",
185
+ catalogItemExternalBook: "catalog-item-external-book",
186
+ catalogItemProduct: "catalog-item-product",
184
187
  callToAction: "call-to-action",
185
188
  callToActionBookNow: "call-to-action-book-now",
186
189
  callToActionContact: "call-to-action-contact",
@@ -302,8 +305,8 @@ var BitType = (0, import_superenum.superenum)({
302
305
  extractorAiChat: "extractor-ai-chat",
303
306
  extractorBlock: "extractor-block",
304
307
  extractorConfiguration: "extractor-configuration",
305
- extractorImage: "extractor-image",
306
- extractorImageCollapsible: "extractor-image-collapsible",
308
+ extractorImages: "extractor-images",
309
+ extractorImagesCollapsible: "extractor-images-collapsible",
307
310
  extractorInformation: "extractor-information",
308
311
  extractorPage: "extractor-page",
309
312
  extractorPageCollapsible: "extractor-page-collapsible",
@@ -1208,6 +1211,9 @@ var propertyKeys = {
1208
1211
  property_colorTag: "@colorTag",
1209
1212
  property_computerLanguage: "@computerLanguage",
1210
1213
  property_content2Buy: "@content2Buy",
1214
+ property_listPrice: "@listPrice",
1215
+ property_customerProductId: "@customerProductId",
1216
+ property_customerProductShopLink: "@customerProductShopLink",
1211
1217
  property_copyright: "@copyright",
1212
1218
  property_coverColor: "@coverColor",
1213
1219
  property_coverImage: "@coverImage",
@@ -1281,6 +1287,7 @@ var propertyKeys = {
1281
1287
  property_listItemIndent: "@listItemIndent",
1282
1288
  property_location: "@location",
1283
1289
  property_machineTranslated: "@machineTranslated",
1290
+ property_spansPageBreak: "@spansPageBreak",
1284
1291
  property_mailingList: "@mailingList",
1285
1292
  property_mark: "@mark",
1286
1293
  property_maxCreatedBits: "@maxCreatedBits",
@@ -2750,6 +2757,11 @@ var GROUPS = {
2750
2757
  description: "If true, the bit is machine-translated",
2751
2758
  format: TagFormat.plainText
2752
2759
  },
2760
+ {
2761
+ key: ConfigKey.property_spansPageBreak,
2762
+ description: "If true, the bit spans a page break",
2763
+ format: TagFormat.boolean
2764
+ },
2753
2765
  {
2754
2766
  key: ConfigKey.property_searchIndex,
2755
2767
  description: "The search index(es) for the bit",
@@ -4559,6 +4571,120 @@ var BITS = {
4559
4571
  }
4560
4572
  ]
4561
4573
  },
4574
+ [BitType.catalogItemBook]: {
4575
+ since: "4.15.0",
4576
+ baseBitType: BitType._standard,
4577
+ description: "Catalog item book bit, used to represent a book product in a catalog with cover and description",
4578
+ tags: [
4579
+ {
4580
+ key: ConfigKey.tag_title,
4581
+ description: "Title and subtitle of the catalog item",
4582
+ maxCount: 2
4583
+ },
4584
+ {
4585
+ key: ConfigKey.property_coverImage,
4586
+ description: "Cover image of the catalog item",
4587
+ format: TagFormat.plainText
4588
+ },
4589
+ {
4590
+ key: ConfigKey.property_content2Buy,
4591
+ description: "Content to buy identifier",
4592
+ format: TagFormat.plainText
4593
+ },
4594
+ {
4595
+ key: ConfigKey.property_listPrice,
4596
+ description: "List price of the catalog item",
4597
+ format: TagFormat.plainText
4598
+ },
4599
+ {
4600
+ key: ConfigKey.property_buttonCaption,
4601
+ description: "Caption for the buy button",
4602
+ format: TagFormat.plainText
4603
+ },
4604
+ {
4605
+ key: ConfigKey.property_customerProductId,
4606
+ description: "Customer-specific product identifier",
4607
+ format: TagFormat.plainText
4608
+ }
4609
+ ],
4610
+ rootExampleType: ExampleType.string
4611
+ },
4612
+ [BitType.catalogItemExternalBook]: {
4613
+ since: "4.15.0",
4614
+ baseBitType: BitType._standard,
4615
+ description: "Catalog item external book bit, used to represent an external book product in a catalog with link to external shop",
4616
+ tags: [
4617
+ {
4618
+ key: ConfigKey.tag_title,
4619
+ description: "Title and subtitle of the catalog item",
4620
+ maxCount: 2
4621
+ },
4622
+ {
4623
+ key: ConfigKey.property_coverImage,
4624
+ description: "Cover image of the catalog item",
4625
+ format: TagFormat.plainText
4626
+ },
4627
+ {
4628
+ key: ConfigKey.property_customerProductShopLink,
4629
+ description: "Link to external shop for the product",
4630
+ format: TagFormat.plainText
4631
+ },
4632
+ {
4633
+ key: ConfigKey.property_listPrice,
4634
+ description: "List price of the catalog item",
4635
+ format: TagFormat.plainText
4636
+ },
4637
+ {
4638
+ key: ConfigKey.property_buttonCaption,
4639
+ description: "Caption for the buy button",
4640
+ format: TagFormat.plainText
4641
+ },
4642
+ {
4643
+ key: ConfigKey.property_customerProductId,
4644
+ description: "Customer-specific product identifier",
4645
+ format: TagFormat.plainText
4646
+ }
4647
+ ],
4648
+ rootExampleType: ExampleType.string
4649
+ },
4650
+ [BitType.catalogItemProduct]: {
4651
+ since: "4.15.0",
4652
+ baseBitType: BitType._standard,
4653
+ description: "Catalog item product bit, used to represent a general product in a catalog with cover and description",
4654
+ tags: [
4655
+ {
4656
+ key: ConfigKey.tag_title,
4657
+ description: "Title and subtitle of the catalog item",
4658
+ maxCount: 2
4659
+ },
4660
+ {
4661
+ key: ConfigKey.property_coverImage,
4662
+ description: "Cover image of the catalog item",
4663
+ format: TagFormat.plainText
4664
+ },
4665
+ {
4666
+ key: ConfigKey.property_content2Buy,
4667
+ description: "Content to buy identifier",
4668
+ format: TagFormat.plainText
4669
+ },
4670
+ {
4671
+ key: ConfigKey.property_listPrice,
4672
+ description: "List price of the catalog item",
4673
+ format: TagFormat.plainText
4674
+ },
4675
+ {
4676
+ key: ConfigKey.property_buttonCaption,
4677
+ description: "Caption for the buy button",
4678
+ format: TagFormat.plainText
4679
+ },
4680
+ {
4681
+ key: ConfigKey.property_customerProductId,
4682
+ description: "Customer-specific product identifier",
4683
+ format: TagFormat.plainText
4684
+ }
4685
+ ],
4686
+ rootExampleType: ExampleType.string
4687
+ },
4562
4688
  [BitType.callToAction]: {
4563
4689
  since: "1.15.0",
4564
4690
  baseBitType: BitType._standard,
@@ -6642,17 +6768,30 @@ var BITS = {
6642
6768
  description: "Extractor configuration bit, used to configure extractors in articles or books",
6643
6769
  textFormatDefault: TextFormat.plainText
6644
6770
  },
6645
- [BitType.extractorImage]: {
6771
+ [BitType.extractorImages]: {
6646
6772
  since: "4.3.0",
6647
- baseBitType: BitType.image,
6648
- description: "Extractor embedded image bit, used for embedded images extracted from PDFs",
6773
+ baseBitType: BitType._standard,
6774
+ description: "Extractor images bit, used for images extracted from PDFs",
6775
+ tags: [
6776
+ {
6777
+ key: ConfigKey.group_resourceBitTags,
6778
+ description: "Resource bit tags for logo grave images, used to define additional properties"
6779
+ },
6780
+ {
6781
+ // Image resource
6782
+ key: ConfigKey.group_resourceImage,
6783
+ description: "Resource image tags for logo grave images, used to attach images",
6784
+ minCount: 1,
6785
+ maxCount: Count.infinity
6786
+ }
6787
+ ],
6788
+ resourceAttachmentAllowed: false,
6649
6789
  textFormatDefault: TextFormat.plainText
6650
6790
  },
6651
- [BitType.extractorImageCollapsible]: {
6791
+ [BitType.extractorImagesCollapsible]: {
6652
6792
  since: "4.3.0",
6653
- baseBitType: BitType.extractorImage,
6654
- description: "Collapsible extractor embedded image bit, used for embedded images extracted from PDFs",
6655
- textFormatDefault: TextFormat.plainText
6793
+ baseBitType: BitType.extractorImages,
6794
+ description: "Collapsible extractor images bit, used for images extracted from PDFs"
6656
6795
  },
6657
6796
  [BitType.extractorInformation]: {
6658
6797
  since: "3.8.0",
@@ -9619,7 +9758,7 @@ var instance2 = new Config();
9619
9758
  // src/generated/package_info.ts
9620
9759
  var PACKAGE_INFO = {
9621
9760
  "name": "@gmb/bitmark-parser-generator",
9622
- "version": "4.14.1",
9761
+ "version": "4.15.0",
9623
9762
  "author": "Get More Brain Ltd",
9624
9763
  "license": "ISC",
9625
9764
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10086,6 +10225,8 @@ var NodeType = (0, import_superenum20.superenum)({
10086
10225
  customerExternalId: "customerExternalId",
10087
10226
  customerId: "customerId",
10088
10227
  customerIdValue: "customerIdValue",
10228
+ customerProductId: "customerProductId",
10229
+ customerProductShopLink: "customerProductShopLink",
10089
10230
  data: "data",
10090
10231
  dataValue: "dataValue",
10091
10232
  dataValueValue: "dataValueValue",
@@ -10267,11 +10408,14 @@ var NodeType = (0, import_superenum20.superenum)({
10267
10408
  list: "list",
10268
10409
  listItemIndent: "listItemIndent",
10269
10410
  listItemIndentValue: "listItemIndentValue",
10411
+ listPrice: "listPrice",
10270
10412
  listValue: "listValue",
10271
10413
  location: "location",
10272
10414
  locationValue: "locationValue",
10273
10415
  machineTranslated: "machineTranslated",
10274
10416
  machineTranslatedValue: "machineTranslatedValue",
10417
+ spansPageBreak: "spansPageBreak",
10418
+ spansPageBreakValue: "spansPageBreakValue",
10275
10419
  mailingList: "mailingList",
10276
10420
  marginNumber: "marginNumber",
10277
10421
  marginNumberValue: "marginNumberValue",
@@ -11052,22 +11196,22 @@ var DeprecatedTextFormat = (0, import_superenum23.superenum)({
11052
11196
  // src/parser/json/TableUtils.ts
11053
11197
  function isTableBasicFormat(table) {
11054
11198
  const t = table;
11055
- return !!(t.columns || t.data) && !(t.head || t.body || t.foot);
11199
+ return !!(t.columns || t.data) && !(t.header || t.body || t.footer);
11056
11200
  }
11057
11201
  function isTableExtendedFormat(table) {
11058
11202
  const t = table;
11059
- return !!(t.head || t.body || t.foot);
11203
+ return !!(t.header || t.body || t.footer);
11060
11204
  }
11061
11205
  function isMixedTableFormat(table) {
11062
11206
  const t = table;
11063
11207
  const hasOld = !!(t.columns || t.data);
11064
- const hasNew = !!(t.head || t.body || t.foot);
11208
+ const hasNew = !!(t.header || t.body || t.footer);
11065
11209
  return hasOld && hasNew;
11066
11210
  }
11067
11211
  function convertBasicToExtendedTableFormat(table) {
11068
11212
  const tableExtended = {};
11069
11213
  if (table.columns && table.columns.length > 0) {
11070
- tableExtended.head = {
11214
+ tableExtended.header = {
11071
11215
  rows: [
11072
11216
  {
11073
11217
  cells: table.columns.map((col) => ({
@@ -11098,7 +11242,7 @@ function convertExtendedToBasicTableFormat(tableExtended) {
11098
11242
  return row.cells.map((cell) => cell?.content).filter((content) => content !== void 0);
11099
11243
  };
11100
11244
  const dataRows = [];
11101
- const headRows = tableExtended.head?.rows ?? [];
11245
+ const headRows = tableExtended.header?.rows ?? [];
11102
11246
  if (headRows.length > 0) {
11103
11247
  const primaryHeader = extractRowCells(headRows[0]);
11104
11248
  if (primaryHeader.length > 0) {
@@ -11124,7 +11268,7 @@ function convertExtendedToBasicTableFormat(tableExtended) {
11124
11268
  });
11125
11269
  };
11126
11270
  appendSectionRows(tableExtended.body);
11127
- appendSectionRows(tableExtended.foot);
11271
+ appendSectionRows(tableExtended.footer);
11128
11272
  if (dataRows.length > 0) {
11129
11273
  table.data = dataRows;
11130
11274
  }
@@ -22084,7 +22228,8 @@ var ResourceBuilder = class extends BaseBuilder {
22084
22228
  BitType.imageSeparator,
22085
22229
  BitType.pageBanner,
22086
22230
  BitType.imagesLogoGrave,
22087
- BitType.prototypeImages
22231
+ BitType.prototypeImages,
22232
+ BitType.extractorImages
22088
22233
  ])) {
22089
22234
  zoomDisabledDefault = true;
22090
22235
  }
@@ -23035,6 +23180,12 @@ var Builder = class extends BaseBuilder {
23035
23180
  data.machineTranslated,
23036
23181
  options
23037
23182
  ),
23183
+ spansPageBreak: this.toAstProperty(
23184
+ bitType,
23185
+ ConfigKey.property_spansPageBreak,
23186
+ data.spansPageBreak,
23187
+ options
23188
+ ),
23038
23189
  searchIndex: this.toAstProperty(
23039
23190
  bitType,
23040
23191
  ConfigKey.property_searchIndex,
@@ -23503,6 +23654,19 @@ var Builder = class extends BaseBuilder {
23503
23654
  data.content2Buy,
23504
23655
  options
23505
23656
  ),
23657
+ listPrice: this.toAstProperty(bitType, ConfigKey.property_listPrice, data.listPrice, options),
23658
+ customerProductId: this.toAstProperty(
23659
+ bitType,
23660
+ ConfigKey.property_customerProductId,
23661
+ data.customerProductId,
23662
+ options
23663
+ ),
23664
+ customerProductShopLink: this.toAstProperty(
23665
+ bitType,
23666
+ ConfigKey.property_customerProductShopLink,
23667
+ data.customerProductShopLink,
23668
+ options
23669
+ ),
23506
23670
  mailingList: this.toAstProperty(
23507
23671
  bitType,
23508
23672
  ConfigKey.property_mailingList,
@@ -24424,12 +24588,12 @@ var Builder = class extends BaseBuilder {
24424
24588
  rows
24425
24589
  };
24426
24590
  };
24427
- const head = buildSection(nodeTableExtended.head);
24428
- if (head && head.rows?.length > 0) nodeTableExtended.head = head;
24591
+ const header = buildSection(nodeTableExtended.header);
24592
+ if (header && header.rows?.length > 0) nodeTableExtended.header = header;
24429
24593
  const body = buildSection(nodeTableExtended.body);
24430
24594
  if (body && body.rows?.length > 0) nodeTableExtended.body = body;
24431
- const foot = buildSection(nodeTableExtended.foot);
24432
- if (foot && foot.rows?.length > 0) nodeTableExtended.foot = foot;
24595
+ const footer = buildSection(nodeTableExtended.footer);
24596
+ if (footer && footer.rows?.length > 0) nodeTableExtended.footer = footer;
24433
24597
  return node;
24434
24598
  }
24435
24599
  /**
@@ -26624,9 +26788,9 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
26624
26788
  writeAdvancedTable(table) {
26625
26789
  const normalized = normalizeTableFormat(BitType.tableExtended, table);
26626
26790
  const sections = [
26627
- { key: "thead", qualifier: "thead", section: normalized.head },
26628
- { key: "tbody", qualifier: void 0, section: normalized.body },
26629
- { key: "tfoot", qualifier: "tfoot", section: normalized.foot }
26791
+ { key: "header", qualifier: "table-header", section: normalized.header },
26792
+ { key: "body", qualifier: void 0, section: normalized.body },
26793
+ { key: "footer", qualifier: "table-footer", section: normalized.footer }
26630
26794
  ];
26631
26795
  let rowCount = 0;
26632
26796
  for (const { key, qualifier, section } of sections) {
@@ -26654,7 +26818,7 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
26654
26818
  }
26655
26819
  }
26656
26820
  writeTableCell(cell, section) {
26657
- const defaultCellType = section === "tbody" ? "td" : "th";
26821
+ const defaultCellType = section === "body" ? "td" : "th";
26658
26822
  const cellType = cell.title ? "th" : "td";
26659
26823
  if (cellType !== defaultCellType) {
26660
26824
  this.writeTableCellProperty("tableCellType", cellType);
@@ -27357,7 +27521,8 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
27357
27521
  BitType.imageSeparator,
27358
27522
  BitType.pageBanner,
27359
27523
  BitType.imagesLogoGrave,
27360
- BitType.prototypeImages
27524
+ BitType.prototypeImages,
27525
+ BitType.extractorImages
27361
27526
  ])) {
27362
27527
  this.writeProperty("zoomDisabled", node.value, route, {
27363
27528
  format: TagFormat.boolean,
@@ -28565,7 +28730,11 @@ var JsonGenerator = class extends AstWalkerGenerator {
28565
28730
  }
28566
28731
  resourceJson = wrapper;
28567
28732
  }
28568
- } else if (instance2.isOfBitType(bitType, [BitType.imagesLogoGrave, BitType.prototypeImages])) {
28733
+ } else if (instance2.isOfBitType(bitType, [
28734
+ BitType.imagesLogoGrave,
28735
+ BitType.prototypeImages,
28736
+ BitType.extractorImages
28737
+ ])) {
28569
28738
  const images = [];
28570
28739
  for (const r of resources) {
28571
28740
  if (r.type === ResourceType.image) {
@@ -29142,7 +29311,11 @@ var JsonGenerator = class extends AstWalkerGenerator {
29142
29311
  if (bitJson.resolvedDate == null) bitJson.resolvedDate = "";
29143
29312
  if (bitJson.resolvedBy == null) bitJson.resolvedBy = "";
29144
29313
  }
29145
- if (instance2.isOfBitType(bitType, [BitType.imagesLogoGrave, BitType.prototypeImages])) {
29314
+ if (instance2.isOfBitType(bitType, [
29315
+ BitType.imagesLogoGrave,
29316
+ BitType.prototypeImages,
29317
+ BitType.extractorImages
29318
+ ])) {
29146
29319
  if (bitType === BitType.imagesLogoGrave) {
29147
29320
  if (bitJson.logos == null) {
29148
29321
  bitJson.logos = [];
@@ -29570,7 +29743,7 @@ var JsonParser = class {
29570
29743
  processResources(bitType, resource, images, logos) {
29571
29744
  const nodes = [];
29572
29745
  if (resource) nodes.push(resource);
29573
- if (instance2.isOfBitType(bitType, [BitType.prototypeImages])) {
29746
+ if (instance2.isOfBitType(bitType, [BitType.prototypeImages, BitType.extractorImages])) {
29574
29747
  if (Array.isArray(images)) {
29575
29748
  for (const image of images) {
29576
29749
  if (image) nodes.push(image);
@@ -31780,17 +31953,17 @@ function parsePronunciationTable(_context, _bitType, cardSet) {
31780
31953
  }
31781
31954
  function parseTable(context, _bitType, cardSet) {
31782
31955
  const sectionRows = {
31783
- thead: [],
31784
- tbody: [],
31785
- tfoot: []
31956
+ header: [],
31957
+ body: [],
31958
+ footer: []
31786
31959
  };
31787
31960
  const getNormalizedQualifier = (rawQualifier) => {
31788
31961
  if (!rawQualifier) return void 0;
31789
31962
  const normalized = rawQualifier.trim().toLowerCase();
31790
- if (normalized === "thead" || normalized === "tbody" || normalized === "tfoot") {
31791
- return normalized;
31792
- }
31793
- context.addWarning(`Unknown table section qualifier '${rawQualifier}', defaulting to tbody.`);
31963
+ if (normalized === "table-header") return "header";
31964
+ if (normalized === "table-body") return "body";
31965
+ if (normalized === "table-footer") return "footer";
31966
+ context.addWarning(`Unknown table section qualifier '${rawQualifier}', defaulting to body.`);
31794
31967
  return void 0;
31795
31968
  };
31796
31969
  const isLegacyHeadingRow = (card, cardIndex) => {
@@ -31827,7 +32000,7 @@ function parseTable(context, _bitType, cardSet) {
31827
32000
  `Invalid table cell type '${raw}', using default for section '${section}'.`
31828
32001
  );
31829
32002
  }
31830
- return section === "tbody" ? "td" : "th";
32003
+ return section === "body" ? "td" : "th";
31831
32004
  };
31832
32005
  const normalizeSpan = (raw, kind) => {
31833
32006
  if (raw == null) return 1;
@@ -31895,7 +32068,7 @@ function parseTable(context, _bitType, cardSet) {
31895
32068
  for (let cardIdx = 0; cardIdx < cardSet.cards.length; cardIdx++) {
31896
32069
  const card = cardSet.cards[cardIdx];
31897
32070
  const qualifier = resolveSectionQualifier(card);
31898
- const section = qualifier ? qualifier : isLegacyHeadingRow(card, cardIdx) ? "thead" : "tbody";
32071
+ const section = qualifier ? qualifier : isLegacyHeadingRow(card, cardIdx) ? "header" : "body";
31899
32072
  const cells = [];
31900
32073
  for (const side of card.sides) {
31901
32074
  for (const variant of side.variants) {
@@ -31907,28 +32080,28 @@ function parseTable(context, _bitType, cardSet) {
31907
32080
  });
31908
32081
  }
31909
32082
  const table = {};
31910
- const hasHeadRows = sectionRows.thead.length > 0;
31911
- const hasBodyRows = sectionRows.tbody.length > 0;
31912
- const hasFootRows = sectionRows.tfoot.length > 0;
32083
+ const hasHeadRows = sectionRows.header.length > 0;
32084
+ const hasBodyRows = sectionRows.body.length > 0;
32085
+ const hasFootRows = sectionRows.footer.length > 0;
31913
32086
  if (hasHeadRows) {
31914
- table.head = {
31915
- rows: sectionRows.thead
32087
+ table.header = {
32088
+ rows: sectionRows.header
31916
32089
  };
31917
32090
  }
31918
32091
  if (hasBodyRows) {
31919
32092
  table.body = {
31920
- rows: sectionRows.tbody
32093
+ rows: sectionRows.body
31921
32094
  };
31922
32095
  }
31923
32096
  if (hasFootRows) {
31924
- table.foot = {
31925
- rows: sectionRows.tfoot
32097
+ table.footer = {
32098
+ rows: sectionRows.footer
31926
32099
  };
31927
32100
  }
31928
32101
  if (!hasHeadRows && !hasBodyRows && !hasFootRows) {
31929
- table.head = { rows: [] };
32102
+ table.header = { rows: [] };
31930
32103
  table.body = { rows: [] };
31931
- table.foot = { rows: [] };
32104
+ table.footer = { rows: [] };
31932
32105
  }
31933
32106
  return { table };
31934
32107
  }