@wdprlib/parser 2.0.6 → 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 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
- let quoted = this.advance();
440
- while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
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
- quoted += this.advance();
443
- }
444
- if (this.current() === '"') {
445
- quoted += this.advance();
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.addToken("QUOTED_STRING", quoted);
460
+ this.advance();
461
+ this.addToken("TEXT", '"');
448
462
  return;
449
463
  }
450
464
  if (char === ":") {
package/dist/index.d.cts CHANGED
@@ -110,6 +110,10 @@ declare class Lexer {
110
110
  */
111
111
  private advance;
112
112
  /**
113
+ * Returns the type of the last non-whitespace token, or null if none.
114
+ */
115
+ private lastNonWhitespaceTokenType;
116
+ /**
113
117
  * Add token
114
118
  */
115
119
  private addToken;
package/dist/index.d.ts CHANGED
@@ -110,6 +110,10 @@ declare class Lexer {
110
110
  */
111
111
  private advance;
112
112
  /**
113
+ * Returns the type of the last non-whitespace token, or null if none.
114
+ */
115
+ private lastNonWhitespaceTokenType;
116
+ /**
113
117
  * Add token
114
118
  */
115
119
  private addToken;
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
- let quoted = this.advance();
385
- while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
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
- quoted += this.advance();
388
- }
389
- if (this.current() === '"') {
390
- quoted += this.advance();
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.addToken("QUOTED_STRING", quoted);
405
+ this.advance();
406
+ this.addToken("TEXT", '"');
393
407
  return;
394
408
  }
395
409
  if (char === ":") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/parser",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Parser for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",