@wdprlib/parser 2.0.4 → 2.0.7
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 +26 -13
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -167,6 +167,14 @@ class Lexer {
|
|
|
167
167
|
}
|
|
168
168
|
return result;
|
|
169
169
|
}
|
|
170
|
+
lastNonWhitespaceTokenType() {
|
|
171
|
+
for (let i = this.state.tokens.length - 1;i >= 0; i--) {
|
|
172
|
+
const t = this.state.tokens[i];
|
|
173
|
+
if (t.type !== "WHITESPACE")
|
|
174
|
+
return t.type;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
170
178
|
addToken(type, value) {
|
|
171
179
|
const startPos = import_ast.createPoint(this.state.line, this.state.column - value.length, this.state.pos - value.length);
|
|
172
180
|
const endPos = import_ast.createPoint(this.state.line, this.state.column, this.state.pos);
|
|
@@ -436,15 +444,21 @@ class Lexer {
|
|
|
436
444
|
return;
|
|
437
445
|
}
|
|
438
446
|
if (char === '"') {
|
|
439
|
-
|
|
440
|
-
|
|
447
|
+
const lastNonWs = this.lastNonWhitespaceTokenType();
|
|
448
|
+
if (lastNonWs === "EQUALS") {
|
|
449
|
+
let quoted = this.advance();
|
|
450
|
+
while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
|
|
441
451
|
`) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
452
|
+
quoted += this.advance();
|
|
453
|
+
}
|
|
454
|
+
if (this.current() === '"') {
|
|
455
|
+
quoted += this.advance();
|
|
456
|
+
}
|
|
457
|
+
this.addToken("QUOTED_STRING", quoted);
|
|
458
|
+
return;
|
|
446
459
|
}
|
|
447
|
-
this.
|
|
460
|
+
this.advance();
|
|
461
|
+
this.addToken("TEXT", '"');
|
|
448
462
|
return;
|
|
449
463
|
}
|
|
450
464
|
if (char === ":") {
|
|
@@ -5891,10 +5905,9 @@ var linkTripleRule = {
|
|
|
5891
5905
|
};
|
|
5892
5906
|
}
|
|
5893
5907
|
let finalTarget = trimmedTarget;
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
if (trimmedTarget.startsWith("*") && !foundPipe) {
|
|
5908
|
+
let hasStar = false;
|
|
5909
|
+
if (trimmedTarget.startsWith("*")) {
|
|
5910
|
+
hasStar = true;
|
|
5898
5911
|
finalTarget = trimmedTarget.slice(1);
|
|
5899
5912
|
}
|
|
5900
5913
|
const { linkType, link } = determineLinkTypeAndLocation(finalTarget);
|
|
@@ -5904,7 +5917,7 @@ var linkTripleRule = {
|
|
|
5904
5917
|
displayText = trimmedLabel || finalTarget;
|
|
5905
5918
|
} else {
|
|
5906
5919
|
const colonIdx = trimmedTarget.indexOf(":");
|
|
5907
|
-
if (colonIdx !== -1 && !trimmedTarget.startsWith("http")) {
|
|
5920
|
+
if (colonIdx !== -1 && !trimmedTarget.startsWith("http") && !trimmedTarget.startsWith("*")) {
|
|
5908
5921
|
displayText = trimmedTarget.slice(colonIdx + 1).trim();
|
|
5909
5922
|
} else {
|
|
5910
5923
|
displayText = trimmedTarget;
|
|
@@ -5921,7 +5934,7 @@ var linkTripleRule = {
|
|
|
5921
5934
|
link,
|
|
5922
5935
|
extra: null,
|
|
5923
5936
|
label,
|
|
5924
|
-
target: null
|
|
5937
|
+
target: hasStar && linkType === "direct" ? "new-tab" : null
|
|
5925
5938
|
}
|
|
5926
5939
|
}
|
|
5927
5940
|
],
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -112,6 +112,14 @@ class Lexer {
|
|
|
112
112
|
}
|
|
113
113
|
return result;
|
|
114
114
|
}
|
|
115
|
+
lastNonWhitespaceTokenType() {
|
|
116
|
+
for (let i = this.state.tokens.length - 1;i >= 0; i--) {
|
|
117
|
+
const t = this.state.tokens[i];
|
|
118
|
+
if (t.type !== "WHITESPACE")
|
|
119
|
+
return t.type;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
115
123
|
addToken(type, value) {
|
|
116
124
|
const startPos = createPoint(this.state.line, this.state.column - value.length, this.state.pos - value.length);
|
|
117
125
|
const endPos = createPoint(this.state.line, this.state.column, this.state.pos);
|
|
@@ -381,15 +389,21 @@ class Lexer {
|
|
|
381
389
|
return;
|
|
382
390
|
}
|
|
383
391
|
if (char === '"') {
|
|
384
|
-
|
|
385
|
-
|
|
392
|
+
const lastNonWs = this.lastNonWhitespaceTokenType();
|
|
393
|
+
if (lastNonWs === "EQUALS") {
|
|
394
|
+
let quoted = this.advance();
|
|
395
|
+
while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
|
|
386
396
|
`) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
397
|
+
quoted += this.advance();
|
|
398
|
+
}
|
|
399
|
+
if (this.current() === '"') {
|
|
400
|
+
quoted += this.advance();
|
|
401
|
+
}
|
|
402
|
+
this.addToken("QUOTED_STRING", quoted);
|
|
403
|
+
return;
|
|
391
404
|
}
|
|
392
|
-
this.
|
|
405
|
+
this.advance();
|
|
406
|
+
this.addToken("TEXT", '"');
|
|
393
407
|
return;
|
|
394
408
|
}
|
|
395
409
|
if (char === ":") {
|
|
@@ -5836,10 +5850,9 @@ var linkTripleRule = {
|
|
|
5836
5850
|
};
|
|
5837
5851
|
}
|
|
5838
5852
|
let finalTarget = trimmedTarget;
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
if (trimmedTarget.startsWith("*") && !foundPipe) {
|
|
5853
|
+
let hasStar = false;
|
|
5854
|
+
if (trimmedTarget.startsWith("*")) {
|
|
5855
|
+
hasStar = true;
|
|
5843
5856
|
finalTarget = trimmedTarget.slice(1);
|
|
5844
5857
|
}
|
|
5845
5858
|
const { linkType, link } = determineLinkTypeAndLocation(finalTarget);
|
|
@@ -5849,7 +5862,7 @@ var linkTripleRule = {
|
|
|
5849
5862
|
displayText = trimmedLabel || finalTarget;
|
|
5850
5863
|
} else {
|
|
5851
5864
|
const colonIdx = trimmedTarget.indexOf(":");
|
|
5852
|
-
if (colonIdx !== -1 && !trimmedTarget.startsWith("http")) {
|
|
5865
|
+
if (colonIdx !== -1 && !trimmedTarget.startsWith("http") && !trimmedTarget.startsWith("*")) {
|
|
5853
5866
|
displayText = trimmedTarget.slice(colonIdx + 1).trim();
|
|
5854
5867
|
} else {
|
|
5855
5868
|
displayText = trimmedTarget;
|
|
@@ -5866,7 +5879,7 @@ var linkTripleRule = {
|
|
|
5866
5879
|
link,
|
|
5867
5880
|
extra: null,
|
|
5868
5881
|
label,
|
|
5869
|
-
target: null
|
|
5882
|
+
target: hasStar && linkType === "direct" ? "new-tab" : null
|
|
5870
5883
|
}
|
|
5871
5884
|
}
|
|
5872
5885
|
],
|