weml-monaco 0.5.0 → 0.5.2
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 +19 -0
- package/dist/index.cjs +62 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +46 -46
- package/dist/index.mjs +62 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,25 @@ 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.2] — 2026-09-26
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Support table `align`, hr `background`/`foreground`, paragraph `hash`,
|
|
15
|
+
`refcode-short`/`refcode-long`, and `original-id`/`hash` metadata in
|
|
16
|
+
completions, hover documentation and diagnostics.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Validate paragraph IDs as positive 32-bit integers and detect numerically
|
|
20
|
+
equivalent duplicate IDs, including leading zeros.
|
|
21
|
+
- Preserve multiline metadata descriptions and omit unspecified attribute defaults.
|
|
22
|
+
|
|
23
|
+
## [0.5.1] — 2026-09-26
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- Updated the shared V2 normalizer: lowercase tag names, keep the first
|
|
27
|
+
duplicate attribute value and unify inline sentence whitespace handling.
|
|
28
|
+
- Retained compatibility with node-html-parser 6.x and browser bundles.
|
|
29
|
+
|
|
11
30
|
## [0.5.0] — 2026-09-09
|
|
12
31
|
|
|
13
32
|
### 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(
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
6603
|
-
|
|
6604
|
-
|
|
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
|
}
|
|
@@ -29524,8 +29473,19 @@ var TAGS = {
|
|
|
29524
29473
|
},
|
|
29525
29474
|
"hr": {
|
|
29526
29475
|
"tag": "hr",
|
|
29527
|
-
"description": "Represents a horizontal ruler
|
|
29528
|
-
"attributes": [
|
|
29476
|
+
"description": "Represents a horizontal ruler with optional foreground and background colors.",
|
|
29477
|
+
"attributes": [
|
|
29478
|
+
{
|
|
29479
|
+
"name": "background",
|
|
29480
|
+
"required": false,
|
|
29481
|
+
"description": "Background color. See Colors."
|
|
29482
|
+
},
|
|
29483
|
+
{
|
|
29484
|
+
"name": "foreground",
|
|
29485
|
+
"required": false,
|
|
29486
|
+
"description": "Foreground color. See Colors."
|
|
29487
|
+
}
|
|
29488
|
+
],
|
|
29529
29489
|
"notes": "Usually displayed as an ornament or three centered asterisks.",
|
|
29530
29490
|
"source": "blocks/hr.md"
|
|
29531
29491
|
},
|
|
@@ -29819,7 +29779,14 @@ var TAGS = {
|
|
|
29819
29779
|
"table": {
|
|
29820
29780
|
"tag": "table",
|
|
29821
29781
|
"description": "",
|
|
29822
|
-
"attributes": [
|
|
29782
|
+
"attributes": [
|
|
29783
|
+
{
|
|
29784
|
+
"name": "align",
|
|
29785
|
+
"required": false,
|
|
29786
|
+
"description": "Horizontal alignment of the table. See corresponding page for possible values",
|
|
29787
|
+
"enumRef": "horizontal-alignment"
|
|
29788
|
+
}
|
|
29789
|
+
],
|
|
29823
29790
|
"notes": "Contains optional `<thead>` and `<tbody>` sections. Both of them, if specfied, must\nhave at least one table row.\n\n`THEAD` element includes cells from the table header and `TBODY` represents actual\ntabular data.\n\nIs displayed as a table. Borderless or bordered, is determined by the client",
|
|
29824
29791
|
"source": "blocks/table.md"
|
|
29825
29792
|
},
|
|
@@ -30082,7 +30049,22 @@ var TAGS = {
|
|
|
30082
30049
|
{
|
|
30083
30050
|
"name": "id",
|
|
30084
30051
|
"required": true,
|
|
30085
|
-
"description": "
|
|
30052
|
+
"description": "Positive 32-bit integer ID (1\u20132147483647), unique within the document. Should be preserved between imports."
|
|
30053
|
+
},
|
|
30054
|
+
{
|
|
30055
|
+
"name": "hash",
|
|
30056
|
+
"required": false,
|
|
30057
|
+
"description": "Paragraph hash. Preserved without calculation or verification."
|
|
30058
|
+
},
|
|
30059
|
+
{
|
|
30060
|
+
"name": "refcode-short",
|
|
30061
|
+
"required": false,
|
|
30062
|
+
"description": "Short reference code."
|
|
30063
|
+
},
|
|
30064
|
+
{
|
|
30065
|
+
"name": "refcode-long",
|
|
30066
|
+
"required": false,
|
|
30067
|
+
"description": "Long reference code."
|
|
30086
30068
|
},
|
|
30087
30069
|
{
|
|
30088
30070
|
"name": "data-skip",
|
|
@@ -30099,6 +30081,10 @@ var META_FIELDS = [
|
|
|
30099
30081
|
"name": "pubid",
|
|
30100
30082
|
"description": "Publication id. Must be unique for each publication."
|
|
30101
30083
|
},
|
|
30084
|
+
{
|
|
30085
|
+
"name": "original-id",
|
|
30086
|
+
"description": "Original publication ID for a translation. Optional 32-bit integer, represented by `WemlDocumentHeader.OriginalId` (`int?`). Missing or unparseable WEML values are read as `null`."
|
|
30087
|
+
},
|
|
30102
30088
|
{
|
|
30103
30089
|
"name": "code",
|
|
30104
30090
|
"description": "Publication short code."
|
|
@@ -30142,11 +30128,15 @@ var META_FIELDS = [
|
|
|
30142
30128
|
},
|
|
30143
30129
|
{
|
|
30144
30130
|
"name": "purchase-link",
|
|
30145
|
-
"description": "
|
|
30131
|
+
"description": "Absolute purchase URI."
|
|
30146
30132
|
},
|
|
30147
30133
|
{
|
|
30148
30134
|
"name": "version-id",
|
|
30149
30135
|
"description": "Publication version GUID."
|
|
30136
|
+
},
|
|
30137
|
+
{
|
|
30138
|
+
"name": "hash",
|
|
30139
|
+
"description": "Publication version hash."
|
|
30150
30140
|
}
|
|
30151
30141
|
];
|
|
30152
30142
|
|
|
@@ -30649,7 +30639,9 @@ var ATTRIBUTE_CONSTRAINTS = [
|
|
|
30649
30639
|
{ tag: "td", attribute: "rowspan", kind: "integer-min", min: 1, message: "`rowspan` must be an integer >= 1." },
|
|
30650
30640
|
{ tag: "th", attribute: "colspan", kind: "integer-min", min: 1, message: "`colspan` must be an integer >= 1." },
|
|
30651
30641
|
{ tag: "th", attribute: "rowspan", kind: "integer-min", min: 1, message: "`rowspan` must be an integer >= 1." },
|
|
30652
|
-
{ tag: "
|
|
30642
|
+
{ tag: "hr", attribute: "background", kind: "pattern", pattern: COLOR_VALUE, allowEmpty: false, message: "`background` must be a color in #RGB, #RGBA, #RRGGBB or #RRGGBBAA format." },
|
|
30643
|
+
{ tag: "hr", attribute: "foreground", kind: "pattern", pattern: COLOR_VALUE, allowEmpty: false, message: "`foreground` must be a color in #RGB, #RGBA, #RRGGBB or #RRGGBBAA format." },
|
|
30644
|
+
{ tag: "div", attribute: "id", kind: "integer-range", min: 1, max: 2147483647, pattern: /^\+?\d+$/, message: "`id` must be a positive 32-bit integer (1\u20132147483647), unique within the document." }
|
|
30653
30645
|
];
|
|
30654
30646
|
var META_CONSTRAINTS = [
|
|
30655
30647
|
{ name: "pubid", kind: "digits", message: 'meta[name="pubid"] content must contain only digits.' },
|
|
@@ -31369,9 +31361,10 @@ function validateWemlModel(m, model) {
|
|
|
31369
31361
|
const id = stripQuotes2(node.attributes?.["id"]);
|
|
31370
31362
|
const range = attrs.get("id")?.valueRange ?? tagRange;
|
|
31371
31363
|
if (id !== void 0) {
|
|
31372
|
-
const
|
|
31364
|
+
const key = /^\+?\d+$/.test(id.trim()) ? String(Number(id)) : id;
|
|
31365
|
+
const list = divIds.get(key) ?? [];
|
|
31373
31366
|
list.push(range);
|
|
31374
|
-
divIds.set(
|
|
31367
|
+
divIds.set(key, list);
|
|
31375
31368
|
}
|
|
31376
31369
|
}
|
|
31377
31370
|
}
|
|
@@ -31385,7 +31378,7 @@ function validateWemlModel(m, model) {
|
|
|
31385
31378
|
return;
|
|
31386
31379
|
}
|
|
31387
31380
|
const n = Number(info.value);
|
|
31388
|
-
if (!Number.isInteger(n)) {
|
|
31381
|
+
if (!Number.isInteger(n) || constraint.pattern && !constraint.pattern.test(info.value.trim())) {
|
|
31389
31382
|
push(info.valueRange, constraint.message, "error");
|
|
31390
31383
|
return;
|
|
31391
31384
|
}
|