@particle-academy/last-word 0.1.1 → 0.2.0
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/README.md +11 -0
- package/dist/index.cjs +27 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,17 @@ Images are embedded from data URLs (PNG/JPEG); when `widthPx`/`heightPx` are
|
|
|
85
85
|
omitted the intrinsic size is sniffed from the bytes (PNG IHDR / JPEG SOF)
|
|
86
86
|
and capped at 6.5in width keeping aspect.
|
|
87
87
|
|
|
88
|
+
## Cross-language parity
|
|
89
|
+
|
|
90
|
+
As of 0.2.0 the metadata slots match the PHP mirror exactly: the title is
|
|
91
|
+
carried in `docProps/core.xml` (`dc:title`) and the code block `language` in
|
|
92
|
+
a `lastword:code:{lang}` content-control tag (quotes use `lastword:quote`),
|
|
93
|
+
so the **same file opens in either engine** — title and code language
|
|
94
|
+
round-trip Node ↔ PHP in both directions. Files written by PHP 0.1.x
|
|
95
|
+
(Title-styled paragraph, `LastWordCode_{lang}` bookmark) still read fine;
|
|
96
|
+
the sibling repo's canonical fixture is frozen into each test suite as a
|
|
97
|
+
cross-read vector.
|
|
98
|
+
|
|
88
99
|
---
|
|
89
100
|
|
|
90
101
|
## ⭐ Star Fancy UI
|
package/dist/index.cjs
CHANGED
|
@@ -1097,6 +1097,7 @@ var DocxReader = class {
|
|
|
1097
1097
|
const blocks = [];
|
|
1098
1098
|
let listBuf = [];
|
|
1099
1099
|
let codeBuf = null;
|
|
1100
|
+
let codeLang = null;
|
|
1100
1101
|
let quoteBuf = null;
|
|
1101
1102
|
const flushList = () => {
|
|
1102
1103
|
if (listBuf.length > 0) {
|
|
@@ -1106,8 +1107,11 @@ var DocxReader = class {
|
|
|
1106
1107
|
};
|
|
1107
1108
|
const flushCode = () => {
|
|
1108
1109
|
if (codeBuf !== null) {
|
|
1109
|
-
|
|
1110
|
+
const block = { type: "code", text: codeBuf.join("\n") };
|
|
1111
|
+
if (codeLang !== null) block.language = codeLang;
|
|
1112
|
+
blocks.push(orderCodeKeys(block));
|
|
1110
1113
|
codeBuf = null;
|
|
1114
|
+
codeLang = null;
|
|
1111
1115
|
}
|
|
1112
1116
|
};
|
|
1113
1117
|
const flushQuote = () => {
|
|
@@ -1132,7 +1136,10 @@ var DocxReader = class {
|
|
|
1132
1136
|
} else if (kind.kind === "codeLine") {
|
|
1133
1137
|
flushList();
|
|
1134
1138
|
flushQuote();
|
|
1135
|
-
if (codeBuf === null)
|
|
1139
|
+
if (codeBuf === null) {
|
|
1140
|
+
codeBuf = [];
|
|
1141
|
+
codeLang = kind.language ?? null;
|
|
1142
|
+
}
|
|
1136
1143
|
codeBuf.push(kind.text);
|
|
1137
1144
|
} else if (kind.kind === "quoteParagraph" && !ctx.insideQuote) {
|
|
1138
1145
|
flushList();
|
|
@@ -1201,7 +1208,8 @@ var DocxReader = class {
|
|
|
1201
1208
|
return { kind: "listItem", item: { numId, ilvl, runs: this.parseRuns(p, void 0) } };
|
|
1202
1209
|
}
|
|
1203
1210
|
if (/^(CodeBlock|SourceCode|HTMLPreformatted|Code)$/i.test(styleId)) {
|
|
1204
|
-
|
|
1211
|
+
const language = this.legacyBookmarkLanguage(p);
|
|
1212
|
+
return language !== void 0 ? { kind: "codeLine", text: this.plainText(p), language } : { kind: "codeLine", text: this.plainText(p) };
|
|
1205
1213
|
}
|
|
1206
1214
|
const blocks = [];
|
|
1207
1215
|
const drawings = findAll(p, "drawing");
|
|
@@ -1237,6 +1245,21 @@ var DocxReader = class {
|
|
|
1237
1245
|
}
|
|
1238
1246
|
return { kind: "blocks", blocks };
|
|
1239
1247
|
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Back-compat: the code language from a PHP last-word ≤0.1.x
|
|
1250
|
+
* `LastWordCode_{lang}` bookmark on this paragraph, if present. The
|
|
1251
|
+
* canonical carrier is the `lastword:code:{lang}` sdt tag.
|
|
1252
|
+
*/
|
|
1253
|
+
legacyBookmarkLanguage(p) {
|
|
1254
|
+
for (const child of p.children) {
|
|
1255
|
+
if (child.name !== "bookmarkStart") continue;
|
|
1256
|
+
const name = at(child, "name") ?? "";
|
|
1257
|
+
if (name.startsWith("LastWordCode_") && name.length > "LastWordCode_".length) {
|
|
1258
|
+
return name.slice("LastWordCode_".length);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return void 0;
|
|
1262
|
+
}
|
|
1240
1263
|
/** Concatenated visible text of a paragraph (tabs and soft breaks included). */
|
|
1241
1264
|
plainText(p) {
|
|
1242
1265
|
return this.parseRuns(p, void 0).map((r) => r.text).join("");
|
|
@@ -2285,7 +2308,7 @@ var Validator = class {
|
|
|
2285
2308
|
};
|
|
2286
2309
|
|
|
2287
2310
|
// src/agent.ts
|
|
2288
|
-
var VERSION = "0.
|
|
2311
|
+
var VERSION = "0.2.0";
|
|
2289
2312
|
function toU8(input) {
|
|
2290
2313
|
return input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
2291
2314
|
}
|