@abraca/cli 1.8.0 → 1.9.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.
@@ -1256,7 +1256,14 @@ function elementTextContent(el) {
1256
1256
  for (let i = 0; i < el.length; i++) {
1257
1257
  const child = el.get(i);
1258
1258
  if (child instanceof Y.XmlText) parts.push(xmlTextToMarkdown(child));
1259
- else if (child instanceof Y.XmlElement) parts.push(elementTextContent(child));
1259
+ else if (child instanceof Y.XmlElement) {
1260
+ if (child.nodeName === "docLink") {
1261
+ const docId = child.getAttribute("docId");
1262
+ if (docId) parts.push(`[[${docId}]]`);
1263
+ continue;
1264
+ }
1265
+ parts.push(elementTextContent(child));
1266
+ }
1260
1267
  }
1261
1268
  return parts.join("");
1262
1269
  }
@@ -1285,7 +1292,9 @@ function serializeElement(el, indent = "") {
1285
1292
  case "table": return serializeTable(el);
1286
1293
  case "docEmbed": {
1287
1294
  const docId = el.getAttribute("docId");
1288
- return docId ? `![[${docId}]]` : "";
1295
+ if (!docId) return "";
1296
+ const seamlessAttr = el.getAttribute("seamless");
1297
+ return seamlessAttr === true || seamlessAttr === "true" ? `![[${docId}]]{seamless}` : `![[${docId}]]`;
1289
1298
  }
1290
1299
  case "svgEmbed": {
1291
1300
  const svg = el.getAttribute("svg") || "";
@@ -1599,14 +1608,12 @@ function parseInline(text) {
1599
1608
  text: kbdProps["value"] || "",
1600
1609
  attrs: { kbd: { value: kbdProps["value"] || "" } }
1601
1610
  });
1602
- } else if (match[5] !== void 0) {
1603
- const docId = match[5];
1604
- const displayText = match[6] ?? docId;
1605
- tokens.push({
1606
- text: displayText,
1607
- attrs: { link: { href: `/doc/${docId}` } }
1608
- });
1609
- } else if (match[7] !== void 0) tokens.push({
1611
+ } else if (match[5] !== void 0) tokens.push({
1612
+ text: "",
1613
+ node: "docLink",
1614
+ nodeAttrs: { docId: match[5] }
1615
+ });
1616
+ else if (match[7] !== void 0) tokens.push({
1610
1617
  text: match[7],
1611
1618
  attrs: { strike: true }
1612
1619
  });
@@ -1633,7 +1640,7 @@ function parseInline(text) {
1633
1640
  lastIndex = match.index + match[0].length;
1634
1641
  }
1635
1642
  if (lastIndex < stripped.length) tokens.push({ text: stripped.slice(lastIndex) });
1636
- return tokens.filter((t) => t.text.length > 0);
1643
+ return tokens.filter((t) => t.node || t.text.length > 0);
1637
1644
  }
1638
1645
  function parseTableRow(line) {
1639
1646
  const parts = line.split("|");
@@ -1761,11 +1768,14 @@ function parseBlocks(markdown) {
1761
1768
  i++;
1762
1769
  continue;
1763
1770
  }
1764
- const docEmbedMatch = line.match(/^!\[\[([^\]|]+?)(?:\|[^\]]*?)?\]\]\s*$/);
1771
+ const docEmbedMatch = line.match(/^!\[\[([^\]|]+?)(?:\|[^\]]*?)?\]\](\{[^}]*\})?\s*$/);
1765
1772
  if (docEmbedMatch) {
1773
+ const props = parseMdcProps(docEmbedMatch[2]);
1774
+ const seamless = "seamless" in props || props["seamless"] === "true" || /\{[^}]*\bseamless\b[^}]*\}/.test(docEmbedMatch[2] ?? "");
1766
1775
  blocks.push({
1767
1776
  type: "docEmbed",
1768
- docId: docEmbedMatch[1]
1777
+ docId: docEmbedMatch[1],
1778
+ seamless: seamless || void 0
1769
1779
  });
1770
1780
  i++;
1771
1781
  continue;
@@ -2043,13 +2053,22 @@ function parseBlocks(markdown) {
2043
2053
  return blocks;
2044
2054
  }
2045
2055
  function fillTextInto(el, tokens) {
2046
- const filtered = tokens.filter((t) => t.text.length > 0);
2056
+ const filtered = tokens.filter((t) => t.node || t.text.length > 0);
2047
2057
  if (!filtered.length) return;
2048
- const xtNodes = filtered.map(() => new Y.XmlText());
2049
- el.insert(0, xtNodes);
2058
+ const children = filtered.map((tok) => {
2059
+ if (tok.node) {
2060
+ const xe = new Y.XmlElement(tok.node);
2061
+ if (tok.nodeAttrs) for (const [k, v] of Object.entries(tok.nodeAttrs)) xe.setAttribute(k, v);
2062
+ return xe;
2063
+ }
2064
+ return new Y.XmlText();
2065
+ });
2066
+ el.insert(0, children);
2050
2067
  filtered.forEach((tok, i) => {
2051
- if (tok.attrs) xtNodes[i].insert(0, tok.text, tok.attrs);
2052
- else xtNodes[i].insert(0, tok.text);
2068
+ if (tok.node) return;
2069
+ const xt = children[i];
2070
+ if (tok.attrs) xt.insert(0, tok.text, tok.attrs);
2071
+ else xt.insert(0, tok.text);
2053
2072
  });
2054
2073
  }
2055
2074
  function blockElName(b) {
@@ -2296,6 +2315,7 @@ function fillBlock(el, block) {
2296
2315
  break;
2297
2316
  case "docEmbed":
2298
2317
  el.setAttribute("docId", block.docId);
2318
+ if (block.seamless) el.setAttribute("seamless", "true");
2299
2319
  break;
2300
2320
  case "svgEmbed":
2301
2321
  el.setAttribute("svg", block.svg);