@gmb/bitmark-parser-generator 5.20.0 → 5.21.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.
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>@gmb/bitmark-parser-generator [13 Apr 2026 at 05:37]</title>
6
+ <title>@gmb/bitmark-parser-generator [19 Apr 2026 at 23:37]</title>
7
7
  <link
8
8
  rel="shortcut icon"
9
9
  href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0d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gPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII="
@@ -86,7 +86,7 @@ function(){var e="function"==typeof Object.defineProperties?Object.definePropert
86
86
  <body>
87
87
  <div id="app"></div>
88
88
  <script>
89
- window.chartData = [{"label":"bitmark-parser-generator.min.js","isAsset":true,"statSize":1295055,"parsedSize":566936,"gzipSize":109804,"groups":[{"label":"dist/browser/cjs","path":"./dist/browser/cjs","statSize":1288993,"groups":[{"id":922,"label":"index.cjs","path":"./dist/browser/cjs/index.cjs","statSize":1288993,"parsedSize":566832,"gzipSize":109804}],"parsedSize":566832,"gzipSize":109804},{"label":"node_modules/@ncoderz/superenum/dist","path":"./node_modules/@ncoderz/superenum/dist","statSize":6062,"groups":[{"id":722,"label":"index.cjs","path":"./node_modules/@ncoderz/superenum/dist/index.cjs","statSize":6062}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"main":true}}];
89
+ window.chartData = [{"label":"bitmark-parser-generator.min.js","isAsset":true,"statSize":1295871,"parsedSize":567279,"gzipSize":109943,"groups":[{"label":"dist/browser/cjs","path":"./dist/browser/cjs","statSize":1289809,"groups":[{"id":922,"label":"index.cjs","path":"./dist/browser/cjs/index.cjs","statSize":1289809,"parsedSize":567175,"gzipSize":109943}],"parsedSize":567175,"gzipSize":109943},{"label":"node_modules/@ncoderz/superenum/dist","path":"./node_modules/@ncoderz/superenum/dist","statSize":6062,"groups":[{"id":722,"label":"index.cjs","path":"./node_modules/@ncoderz/superenum/dist/index.cjs","statSize":6062}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"main":true}}];
90
90
  window.entrypoints = ["main"];
91
91
  window.defaultSizes = "stat";
92
92
  window.compressionAlgorithm = "gzip";
@@ -11064,7 +11064,7 @@ var instance2 = new Config();
11064
11064
  // src/generated/package_info.ts
11065
11065
  var PACKAGE_INFO = {
11066
11066
  "name": "@gmb/bitmark-parser-generator",
11067
- "version": "5.20.0",
11067
+ "version": "5.21.0",
11068
11068
  "author": "Get More Brain Ltd",
11069
11069
  "license": "ISC",
11070
11070
  "description": "A bitmark parser and generator using Peggy.js"
@@ -12819,6 +12819,31 @@ var AstWalkerGenerator = class {
12819
12819
  }
12820
12820
  return void 0;
12821
12821
  }
12822
+ getSiblingNodes(route) {
12823
+ const parentNode = this.getParentNode(route);
12824
+ if (!parentNode || !parentNode.value || !Array.isArray(parentNode.value)) {
12825
+ return {};
12826
+ }
12827
+ const siblings = parentNode.value;
12828
+ const index = siblings.findIndex((s) => s === route[route.length - 1]?.value);
12829
+ if (index === -1) {
12830
+ return {};
12831
+ }
12832
+ return {
12833
+ left: index > 0 ? siblings[index - 1] : void 0,
12834
+ right: index < siblings.length - 1 ? siblings[index + 1] : void 0
12835
+ };
12836
+ }
12837
+ isEmptyParagraph(node) {
12838
+ if (!node) return false;
12839
+ if (node.type !== TextNodeType.paragraph) return false;
12840
+ if (!node.content || !Array.isArray(node.content)) return true;
12841
+ for (const contentNode of node.content) {
12842
+ if (contentNode.type !== TextNodeType.text) return false;
12843
+ if (contentNode.text && contentNode.text.trim() !== "") return false;
12844
+ }
12845
+ return true;
12846
+ }
12822
12847
  };
12823
12848
 
12824
12849
  // src/generator/text/TextGenerator.ts
@@ -12944,7 +12969,6 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
12944
12969
  __publicField(this, "inParagraph", false);
12945
12970
  __publicField(this, "inHeading", false);
12946
12971
  __publicField(this, "inCodeBlock", false);
12947
- __publicField(this, "exitedCodeBlock", false);
12948
12972
  __publicField(this, "inBulletList", false);
12949
12973
  __publicField(this, "inInline", false);
12950
12974
  __publicField(this, "markDepth", 0);
@@ -13033,7 +13057,6 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
13033
13057
  this.inParagraph = false;
13034
13058
  this.inHeading = false;
13035
13059
  this.inCodeBlock = false;
13036
- this.exitedCodeBlock = false;
13037
13060
  this.inBulletList = false;
13038
13061
  this.inInline = false;
13039
13062
  this.markDepth = 0;
@@ -13099,7 +13122,7 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
13099
13122
  switch (node.type) {
13100
13123
  case TextNodeType.paragraph:
13101
13124
  this.inParagraph = true;
13102
- this.writeParagraph(node);
13125
+ this.writeParagraph(node, route);
13103
13126
  break;
13104
13127
  case TextNodeType.hardBreak:
13105
13128
  this.writeHardBreak(node);
@@ -13156,7 +13179,6 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
13156
13179
  return false;
13157
13180
  default:
13158
13181
  }
13159
- this.exitedCodeBlock = false;
13160
13182
  }
13161
13183
  handleBetweenNode(node, _left, _right, _route) {
13162
13184
  switch (node.type) {
@@ -13190,7 +13212,6 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
13190
13212
  this.writeNL();
13191
13213
  this.writeNL();
13192
13214
  this.inCodeBlock = false;
13193
- this.exitedCodeBlock = true;
13194
13215
  break;
13195
13216
  case TextNodeType.noBulletList:
13196
13217
  case TextNodeType.bulletList:
@@ -13554,21 +13575,19 @@ var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
13554
13575
  }
13555
13576
  }
13556
13577
  }
13557
- writeParagraph(node) {
13578
+ writeParagraph(node, route) {
13558
13579
  if (this.textFormat === TextFormat2.bitmarkText) {
13559
13580
  if (this.inBulletList) return;
13560
- const nodeContentLength = node.content?.length ?? 0;
13561
- if (this.nodeIndex === 0) {
13562
- if (nodeContentLength === 1) {
13563
- const isTextNode = node.content?.[0].type === TextNodeType.text;
13564
- const text = node.content?.[0].text ?? "";
13565
- if (!isTextNode || text !== "") return;
13566
- }
13567
- if (nodeContentLength > 1) return;
13581
+ const siblingNodes = this.getSiblingNodes(route);
13582
+ const prevSiblingNodeType = siblingNodes.left?.type;
13583
+ const inBody = this.textLocation === TextLocation2.body;
13584
+ const isEmptyParagraph = this.isEmptyParagraph(node);
13585
+ if (!inBody || !isEmptyParagraph && !(prevSiblingNodeType === TextNodeType.codeBlock || prevSiblingNodeType === TextNodeType.paragraph)) {
13586
+ return;
13568
13587
  }
13569
13588
  this.write("|");
13570
13589
  this.writeNL();
13571
- if (this.exitedCodeBlock) {
13590
+ if (prevSiblingNodeType === TextNodeType.codeBlock) {
13572
13591
  this.writeNL();
13573
13592
  }
13574
13593
  }