weml-monaco 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -8,6 +8,13 @@ This package mirrors the language logic of the VS Code extension; entries below
8
8
  track the port catching up with the VS Code provider changes (see the root
9
9
  `CHANGELOG.md` for the extension).
10
10
 
11
+ ## [0.5.1] — 2026-09-26
12
+
13
+ ### Changed
14
+ - Updated the shared V2 normalizer: lowercase tag names, keep the first
15
+ duplicate attribute value and unify inline sentence whitespace handling.
16
+ - Retained compatibility with node-html-parser 6.x and browser bundles.
17
+
11
18
  ## [0.5.0] — 2026-09-09
12
19
 
13
20
  ### Changed
package/dist/index.cjs CHANGED
@@ -6306,7 +6306,7 @@ var require_wemlContentNormalizeV2 = __commonJS({
6306
6306
  }
6307
6307
  result.push(`<${name.toLowerCase()}${attrs} />`);
6308
6308
  } else {
6309
- result.push(input.slice(start, cursor), attrs, ">");
6309
+ result.push(closing ? "</" : "<", name.toLowerCase(), attrs, ">");
6310
6310
  }
6311
6311
  index = end + 1;
6312
6312
  }
@@ -6356,62 +6356,14 @@ var require_wemlContentNormalizeV2 = __commonJS({
6356
6356
  }
6357
6357
  }
6358
6358
  function processInlineContainer(node) {
6359
- if (hasDirectSentChildren(node)) processSentContainer(node, true);
6360
- else processInlineContent(node, true);
6361
- }
6362
- function processSentContainer(node, trimEdges) {
6363
- for (const child of [...node.childNodes]) {
6364
- if (child.nodeType !== 1) continue;
6365
- const name = child.rawTagName.toLowerCase();
6366
- if (isInlineTextElement(child)) {
6367
- if (hasDirectSentChildren(child)) processSentContainer(child, false);
6368
- else processInlineContent(child, false);
6369
- } else if (BLOCK_ELEMENTS.has(name)) {
6370
- processBlockElement(child);
6371
- } else if (INLINE_CONTAINERS.has(name)) {
6372
- processInlineContainer(child);
6373
- }
6374
- }
6375
- for (const child of [...node.childNodes]) {
6376
- if (child.nodeType === 1 && isInlineTextElement(child)) {
6377
- bleedEdgeSpaces(child);
6378
- }
6379
- }
6380
- for (const child of [...node.childNodes]) {
6381
- if (child.nodeType === 3) child.rawText = collapseWhitespace(child.rawText);
6382
- }
6383
- for (const child of [...node.childNodes]) {
6384
- if (child.nodeType === 1 && child.rawTagName.toLowerCase() === "br") {
6385
- const prev = child.previousSibling;
6386
- if (prev && prev.nodeType === 3) prev.rawText = trimEndWhitespace(prev.rawText);
6387
- const next = child.nextSibling;
6388
- if (next && next.nodeType === 3) next.rawText = trimStartWhitespace(next.rawText);
6389
- }
6390
- }
6391
- if (trimEdges) trimContainerEdges(node);
6392
- for (const child of [...node.childNodes]) {
6393
- if (child.nodeType === 3 && child.rawText === "") child.remove();
6394
- }
6395
- }
6396
- function trimContainerEdges(node) {
6397
- const children = [...node.childNodes];
6398
- if (children.length === 0) return;
6399
- const first = children[0];
6400
- const last = children[children.length - 1];
6401
- if (children.length === 1) {
6402
- if (first.nodeType === 3) first.rawText = trimWhitespace(first.rawText);
6403
- } else {
6404
- if (first.nodeType === 3) first.rawText = trimStartWhitespace(first.rawText);
6405
- if (last.nodeType === 3) last.rawText = trimEndWhitespace(last.rawText);
6406
- }
6359
+ processInlineContent(node, true);
6407
6360
  }
6408
6361
  function processInlineContent(node, trimEdges) {
6409
6362
  for (const child of [...node.childNodes]) {
6410
6363
  if (child.nodeType !== 1) continue;
6411
6364
  const name = child.rawTagName.toLowerCase();
6412
6365
  if (isInlineTextElement(child)) {
6413
- if (hasDirectSentChildren(child)) processSentContainer(child, false);
6414
- else processInlineContent(child, false);
6366
+ processInlineContent(child, false);
6415
6367
  } else if (BLOCK_ELEMENTS.has(name)) {
6416
6368
  processBlockElement(child);
6417
6369
  } else if (INLINE_CONTAINERS.has(name)) {
@@ -6521,11 +6473,6 @@ var require_wemlContentNormalizeV2 = __commonJS({
6521
6473
  if (last.nodeType === 3) last.rawText = trimEndWhitespace(last.rawText);
6522
6474
  }
6523
6475
  }
6524
- function hasDirectSentChildren(node) {
6525
- return [...node.childNodes].some(
6526
- (child) => child.nodeType === 1 && child.rawTagName.toLowerCase() === "w-sent"
6527
- );
6528
- }
6529
6476
  function isInlineTextElement(node) {
6530
6477
  if (node.nodeType !== 1) return false;
6531
6478
  const name = node.rawTagName.toLowerCase();
@@ -6599,10 +6546,12 @@ var require_wemlContentNormalizeV2 = __commonJS({
6599
6546
  value = rawAttrs.slice(valueStart, index);
6600
6547
  }
6601
6548
  }
6602
- canonical.set(
6603
- name,
6604
- SPACE_SEPARATED_ATTRIBUTES.has(name) ? normalizeTokenList(value, entities2, marker) : trimWhitespace(value)
6605
- );
6549
+ if (!canonical.has(name)) {
6550
+ canonical.set(
6551
+ name,
6552
+ SPACE_SEPARATED_ATTRIBUTES.has(name) ? normalizeTokenList(value, entities2, marker) : trimWhitespace(value)
6553
+ );
6554
+ }
6606
6555
  }
6607
6556
  return [...canonical.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([name, value]) => ` ${name}="${encodeAttr(String(value))}"`).join("");
6608
6557
  }