@haklex/rich-litexml-cli 0.39.3 → 0.39.4
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/cli.mjs +51 -8
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -23502,14 +23502,15 @@ function registerBuiltinReaders(registry) {
|
|
|
23502
23502
|
}));
|
|
23503
23503
|
registry.registerReader("blockquote", (el, ctx) => {
|
|
23504
23504
|
const attribution = el.getAttribute("attribution");
|
|
23505
|
+
const isRichQuote = el.getAttribute("rich") !== null || attribution !== null;
|
|
23505
23506
|
const base = {
|
|
23506
23507
|
...extractBlockId$1(el),
|
|
23507
23508
|
children: ctx.parseChildren(el),
|
|
23508
23509
|
...ELEMENT_DEFAULTS
|
|
23509
23510
|
};
|
|
23510
|
-
if (
|
|
23511
|
+
if (isRichQuote) return {
|
|
23511
23512
|
type: "rich-quote",
|
|
23512
|
-
attribution,
|
|
23513
|
+
attribution: attribution?.trim() ? attribution : null,
|
|
23513
23514
|
...base
|
|
23514
23515
|
};
|
|
23515
23516
|
return {
|
|
@@ -23564,7 +23565,7 @@ function registerBuiltinReaders(registry) {
|
|
|
23564
23565
|
url: el.getAttribute("href") ?? "",
|
|
23565
23566
|
target: el.getAttribute("target") ?? null,
|
|
23566
23567
|
title: el.getAttribute("title") ?? null,
|
|
23567
|
-
rel:
|
|
23568
|
+
rel: el.getAttribute("rel"),
|
|
23568
23569
|
children: ctx.parseChildren(el),
|
|
23569
23570
|
direction: "ltr",
|
|
23570
23571
|
format: "",
|
|
@@ -24182,7 +24183,10 @@ function registerBuiltinWriters(registry) {
|
|
|
24182
24183
|
const writeQuote = (node, ctx) => {
|
|
24183
24184
|
const n = node;
|
|
24184
24185
|
const attrs = { ...blockId$1(n) };
|
|
24185
|
-
if (
|
|
24186
|
+
if (n.type === "rich-quote") {
|
|
24187
|
+
if ((typeof n.attribution === "string" ? n.attribution.trim() : "") !== "") attrs.attribution = n.attribution;
|
|
24188
|
+
else attrs.rich = "true";
|
|
24189
|
+
}
|
|
24186
24190
|
return {
|
|
24187
24191
|
tag: "blockquote",
|
|
24188
24192
|
attrs,
|
|
@@ -24221,9 +24225,10 @@ function registerBuiltinWriters(registry) {
|
|
|
24221
24225
|
});
|
|
24222
24226
|
registry.registerWriter("link", (node, ctx) => {
|
|
24223
24227
|
const n = node;
|
|
24224
|
-
const attrs = { href: n.url
|
|
24225
|
-
if (n.target) attrs.target = n.target;
|
|
24226
|
-
if (n.title) attrs.title = n.title;
|
|
24228
|
+
const attrs = { href: typeof n.url === "string" ? n.url : "" };
|
|
24229
|
+
if (typeof n.target === "string" && n.target !== "") attrs.target = n.target;
|
|
24230
|
+
if (typeof n.title === "string" && n.title !== "") attrs.title = n.title;
|
|
24231
|
+
if (typeof n.rel === "string" && n.rel !== "") attrs.rel = n.rel;
|
|
24227
24232
|
return {
|
|
24228
24233
|
tag: "a",
|
|
24229
24234
|
attrs,
|
|
@@ -24686,6 +24691,43 @@ function getFormatBit(tagName) {
|
|
|
24686
24691
|
return FORMAT_TAG_TO_BIT[tagName.toLowerCase()] ?? 0;
|
|
24687
24692
|
}
|
|
24688
24693
|
//#endregion
|
|
24694
|
+
//#region ../rich-litexml/src/xml-utils.ts
|
|
24695
|
+
/**
|
|
24696
|
+
* Elements that sit inside a text run without forcing a line break, so the
|
|
24697
|
+
* serializer keeps them on the same line as their siblings and the reader does
|
|
24698
|
+
* not mistake the surrounding indentation for content.
|
|
24699
|
+
*
|
|
24700
|
+
* The void elements (`br`, `img`) belong here: a paragraph holding a line break
|
|
24701
|
+
* or an inline image is still a single line of prose.
|
|
24702
|
+
*/
|
|
24703
|
+
var INLINE_TAGS = /* @__PURE__ */ new Set([
|
|
24704
|
+
"b",
|
|
24705
|
+
"i",
|
|
24706
|
+
"u",
|
|
24707
|
+
"s",
|
|
24708
|
+
"code",
|
|
24709
|
+
"sub",
|
|
24710
|
+
"sup",
|
|
24711
|
+
"mark",
|
|
24712
|
+
"strong",
|
|
24713
|
+
"em",
|
|
24714
|
+
"del",
|
|
24715
|
+
"a",
|
|
24716
|
+
"mention",
|
|
24717
|
+
"tag",
|
|
24718
|
+
"spoiler",
|
|
24719
|
+
"ruby",
|
|
24720
|
+
"math",
|
|
24721
|
+
"footnote",
|
|
24722
|
+
"comment",
|
|
24723
|
+
"br",
|
|
24724
|
+
"img"
|
|
24725
|
+
]);
|
|
24726
|
+
/** Tags rendered inline (no line break between siblings). */
|
|
24727
|
+
function isInlineTag(tag) {
|
|
24728
|
+
return INLINE_TAGS.has(tag.toLowerCase());
|
|
24729
|
+
}
|
|
24730
|
+
//#endregion
|
|
24689
24731
|
//#region ../rich-litexml/src/deserializer.ts
|
|
24690
24732
|
/**
|
|
24691
24733
|
* HTML5 void elements — tags the HTML parser already treats as self-closing
|
|
@@ -24788,7 +24830,8 @@ function isBlockContainer(element) {
|
|
|
24788
24830
|
function createReaderContext(registry) {
|
|
24789
24831
|
const ctx = {
|
|
24790
24832
|
parseChildren(element) {
|
|
24791
|
-
const
|
|
24833
|
+
const holdsBlockChild = [...element.children].some((child) => !isInlineTag(child.tagName));
|
|
24834
|
+
const blockLevel = isBlockContainer(element) || holdsBlockChild;
|
|
24792
24835
|
const nodes = [];
|
|
24793
24836
|
let pendingText = "";
|
|
24794
24837
|
const flushText = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-litexml-cli",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.4",
|
|
4
4
|
"description": "Unified CLI for haklex LiteXML: convert LiteXML or Lexical JSON to HTML, JSON, or Markdown.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@lexical/headless": "^0.49.0",
|
|
20
20
|
"lexical": "^0.49.0",
|
|
21
|
-
"@haklex/rich-
|
|
22
|
-
"@haklex/rich-
|
|
23
|
-
"@haklex/rich-
|
|
21
|
+
"@haklex/rich-headless": "0.39.4",
|
|
22
|
+
"@haklex/rich-litexml": "0.39.4",
|
|
23
|
+
"@haklex/rich-compose": "0.39.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "26.1.0",
|