@limaformat/lima 0.8.0 → 0.8.1

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/scalars.js CHANGED
@@ -436,19 +436,8 @@ export const unescapeDQ = (s, strict = false, line = 0) => {
436
436
  }
437
437
  });
438
438
  };
439
- /**
440
- * The value text with a trailing `#` comment removed, but with `\#`
441
- * escapes left as written. This is the *physical* form a References 2.0
442
- * token's column is measured against (§2.4): the comment is not part of
443
- * the value (so its `${…}`-shaped text must not be scanned as a token),
444
- * but a `\#` before a token still occupies its two source columns.
445
- *
446
- * `trimEnd()` is exactly the project whitespace set (ECMAScript WhiteSpace
447
- * + LineTerminator = `isTrimWhitespace`) — a U+00A0 / FEFF between the
448
- * value and the `#` is not part of the value. The Rust and Go ports must
449
- * use `is_trim_whitespace` here, not a host `trim_end` or `" \t"`.
450
- */
451
- export const stripCommentKeepEscapes = (val) => {
439
+ /** UTF-16 offset of the first unescaped, unquoted hash, or -1. */
440
+ export const commentStart = (val) => {
452
441
  let quote = 0;
453
442
  for (let i = 0; i < val.length; i++) {
454
443
  const cc = val.charCodeAt(i);
@@ -465,10 +454,26 @@ export const stripCommentKeepEscapes = (val) => {
465
454
  i++;
466
455
  }
467
456
  else if (cc === 35) {
468
- return val.slice(0, i).trimEnd();
457
+ return i;
469
458
  }
470
459
  }
471
- return val;
460
+ return -1;
461
+ };
462
+ /**
463
+ * The value text with a trailing `#` comment removed, but with `\#`
464
+ * escapes left as written. This is the *physical* form a References 2.0
465
+ * token's column is measured against (§2.4): the comment is not part of
466
+ * the value (so its `${…}`-shaped text must not be scanned as a token),
467
+ * but a `\#` before a token still occupies its two source columns.
468
+ *
469
+ * `trimEnd()` is exactly the project whitespace set (ECMAScript WhiteSpace
470
+ * + LineTerminator = `isTrimWhitespace`) — a U+00A0 / FEFF between the
471
+ * value and the `#` is not part of the value. The Rust and Go ports must
472
+ * use `is_trim_whitespace` here, not a host `trim_end` or `" \t"`.
473
+ */
474
+ export const stripCommentKeepEscapes = (val) => {
475
+ const start = commentStart(val);
476
+ return start === -1 ? val : val.slice(0, start).trimEnd();
472
477
  };
473
478
  /**
474
479
  * The value text with a trailing `#` comment removed and each `\#` *outside*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limaformat/lima",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Lima frontmatter parser — LIMA Is Metadata Annotation",
5
5
  "keywords": ["frontmatter", "parser", "yaml", "markdown", "metadata"],
6
6
  "homepage": "https://limaformat.dev",