@haklex/rich-litexml 0.15.5 → 0.15.7

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/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-DM53MOSd.js";
1
+ import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-z3l9E6En.js";
2
2
  //#region src/index-browser.ts
3
3
  registerParseHTML((html) => new DOMParser().parseFromString(html, "text/html"));
4
4
  //#endregion
package/dist/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-DM53MOSd.js";
1
+ import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-z3l9E6En.js";
2
2
  import { parseHTML } from "linkedom";
3
3
  //#region src/index-node.ts
4
4
  registerParseHTML((html) => parseHTML(html).document);
@@ -1133,16 +1133,24 @@ function createReaderContext(registry) {
1133
1133
  parseChildren(element) {
1134
1134
  const blockLevel = isBlockContainer(element);
1135
1135
  const nodes = [];
1136
- for (const child of element.childNodes) if (child.nodeType === 3) {
1137
- const text = child.textContent ?? "";
1138
- if (blockLevel && text.trim() === "") continue;
1139
- if (text === "") continue;
1140
- nodes.push(makeTextNode(text, 0));
1141
- } else if (child.nodeType === 1) {
1136
+ let pendingText = "";
1137
+ const flushText = () => {
1138
+ if (pendingText === "") return;
1139
+ if (blockLevel && pendingText.trim() === "") {
1140
+ pendingText = "";
1141
+ return;
1142
+ }
1143
+ nodes.push(makeTextNode(pendingText, 0));
1144
+ pendingText = "";
1145
+ };
1146
+ for (const child of element.childNodes) if (child.nodeType === 3) pendingText += child.textContent ?? "";
1147
+ else if (child.nodeType === 1) {
1148
+ flushText();
1142
1149
  const parsed = parseElement(child, registry, ctx, 0);
1143
1150
  if (parsed) if (Array.isArray(parsed)) nodes.push(...parsed);
1144
1151
  else nodes.push(parsed);
1145
1152
  }
1153
+ flushText();
1146
1154
  return nodes;
1147
1155
  },
1148
1156
  parseNestedState(xml) {
@@ -1168,15 +1176,20 @@ function parseElement(element, registry, ctx, inheritedFormat) {
1168
1176
  }
1169
1177
  function parseInlineChildren(element, registry, ctx, format) {
1170
1178
  const nodes = [];
1171
- for (const child of element.childNodes) if (child.nodeType === 3) {
1172
- const text = child.textContent ?? "";
1173
- if (text === "") continue;
1174
- nodes.push(makeTextNode(text, format));
1175
- } else if (child.nodeType === 1) {
1179
+ let pendingText = "";
1180
+ const flushText = () => {
1181
+ if (pendingText === "") return;
1182
+ nodes.push(makeTextNode(pendingText, format));
1183
+ pendingText = "";
1184
+ };
1185
+ for (const child of element.childNodes) if (child.nodeType === 3) pendingText += child.textContent ?? "";
1186
+ else if (child.nodeType === 1) {
1187
+ flushText();
1176
1188
  const parsed = parseElement(child, registry, ctx, format);
1177
1189
  if (parsed) if (Array.isArray(parsed)) nodes.push(...parsed);
1178
1190
  else nodes.push(parsed);
1179
1191
  }
1192
+ flushText();
1180
1193
  return nodes;
1181
1194
  }
1182
1195
  function parseFallbackNode(element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-litexml",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "Bidirectional Lexical SerializedNode <-> XML conversion with plugin registry",
5
5
  "repository": {
6
6
  "type": "git",