@wdprlib/parser 5.1.3 → 5.1.4

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
@@ -4692,10 +4692,10 @@ function parseModuleClose(ctx, startPos) {
4692
4692
  }
4693
4693
  let pos = startPos + 1 + closeNameResult.consumed;
4694
4694
  let consumed = 1 + closeNameResult.consumed;
4695
- if (ctx.tokens[pos]?.type === "BLOCK_CLOSE") {
4696
- pos++;
4697
- consumed++;
4698
- }
4695
+ if (ctx.tokens[pos]?.type !== "BLOCK_CLOSE")
4696
+ return null;
4697
+ pos++;
4698
+ consumed++;
4699
4699
  if (ctx.tokens[pos]?.type === "NEWLINE") {
4700
4700
  pos++;
4701
4701
  consumed++;
@@ -6775,12 +6775,9 @@ function isRestOfLineBlank(source, pos) {
6775
6775
 
6776
6776
  // packages/parser/src/parser/rules/block/module/include/directive.ts
6777
6777
  function parseIncludeDirective(inner) {
6778
- const normalized = inner.includes(`
6779
- `) ? inner.replaceAll(`
6780
- `, " ") : inner;
6781
- const parts = normalized.split("|");
6778
+ const parts = inner.split("|");
6782
6779
  const firstSegment = parts[0].trim();
6783
- const spaceIndex = firstSegment.indexOf(" ");
6780
+ const spaceIndex = firstSegment.search(/\s/);
6784
6781
  let target;
6785
6782
  const varSegments = [];
6786
6783
  if (spaceIndex !== -1) {
package/dist/index.js CHANGED
@@ -4627,10 +4627,10 @@ function parseModuleClose(ctx, startPos) {
4627
4627
  }
4628
4628
  let pos = startPos + 1 + closeNameResult.consumed;
4629
4629
  let consumed = 1 + closeNameResult.consumed;
4630
- if (ctx.tokens[pos]?.type === "BLOCK_CLOSE") {
4631
- pos++;
4632
- consumed++;
4633
- }
4630
+ if (ctx.tokens[pos]?.type !== "BLOCK_CLOSE")
4631
+ return null;
4632
+ pos++;
4633
+ consumed++;
4634
4634
  if (ctx.tokens[pos]?.type === "NEWLINE") {
4635
4635
  pos++;
4636
4636
  consumed++;
@@ -6710,12 +6710,9 @@ function isRestOfLineBlank(source, pos) {
6710
6710
 
6711
6711
  // packages/parser/src/parser/rules/block/module/include/directive.ts
6712
6712
  function parseIncludeDirective(inner) {
6713
- const normalized = inner.includes(`
6714
- `) ? inner.replaceAll(`
6715
- `, " ") : inner;
6716
- const parts = normalized.split("|");
6713
+ const parts = inner.split("|");
6717
6714
  const firstSegment = parts[0].trim();
6718
- const spaceIndex = firstSegment.indexOf(" ");
6715
+ const spaceIndex = firstSegment.search(/\s/);
6719
6716
  let target;
6720
6717
  const varSegments = [];
6721
6718
  if (spaceIndex !== -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/parser",
3
- "version": "5.1.3",
3
+ "version": "5.1.4",
4
4
  "description": "Parser for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",
@@ -79,10 +79,9 @@ function parseModuleClose(
79
79
  let pos = startPos + 1 + closeNameResult.consumed;
80
80
  let consumed = 1 + closeNameResult.consumed;
81
81
 
82
- if (ctx.tokens[pos]?.type === "BLOCK_CLOSE") {
83
- pos++;
84
- consumed++;
85
- }
82
+ if (ctx.tokens[pos]?.type !== "BLOCK_CLOSE") return null;
83
+ pos++;
84
+ consumed++;
86
85
  if (ctx.tokens[pos]?.type === "NEWLINE") {
87
86
  pos++;
88
87
  consumed++;
@@ -13,11 +13,10 @@ export function parseIncludeDirective(inner: string): {
13
13
  location: PageRef;
14
14
  assignments: IncludeAssignment[];
15
15
  } {
16
- const normalized = inner.includes("\n") ? inner.replaceAll("\n", " ") : inner;
17
- const parts = normalized.split("|");
16
+ const parts = inner.split("|");
18
17
  const firstSegment = parts[0]!.trim();
19
18
 
20
- const spaceIndex = firstSegment.indexOf(" ");
19
+ const spaceIndex = firstSegment.search(/\s/);
21
20
  let target: string;
22
21
  const varSegments: string[] = [];
23
22