@ai-matrx/content-ir 0.19.12 → 0.19.14

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.14
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/content-ir-core/v0.19.12..npm/content-ir-core/v0.19.14 -- apps/shared/content-ir-core`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.19.13
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/content-ir-core/v0.19.12..npm/content-ir-core/v0.19.13 -- apps/shared/content-ir-core`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.19.12
4
16
 
5
17
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -21,6 +33,7 @@ No source changes intended and no consumer action required.
21
33
  ## 0.19.9
22
34
  ### Unreleased
23
35
 
36
+ - `/source` **`isHtmlBlockTagName(name)`** (verify-RC-B4 round 9): the tag names CommonMark reads as an HTML BLOCK when they open a line (conditions 1 and 6: `div`, `details`, `section`, `script`, …; case-insensitive) — so a splitter can leave such a line to the markdown renderer, ending where GFM ends it, instead of opening a custom XML container that owns what follows.
24
37
  - `/source` **A table ends where GFM ends it (verify-RC-B4 round 9):** `continuesTable` / `findTableEnd` end a table at an HTML block start (all seven CommonMark 4.6 conditions — `<script`/`<pre`/`<style`/`<textarea`, `<!--`, `<?`, `<!X`, `<![CDATA[`, a block tag name, or any other complete tag alone on its line such as `</artifact>`) and at indented code: a line 4+ columns past the table's container. New `startsHtmlBlock`, `lineIndent`, `tableContainerIndent` (the content column of the list item a table sits in); `continuesTable(line, containerIndent = 0)`. A lone `|` is a row (one empty cell) — `rowCells("|")` is `[""]`, no longer `[]`. Since 0.19.4 an HTML line or an indented line after a table was read as a table row. Shared vectors gain `tableEnds` (30 cases, each judged against remark-gfm in matrx-frontend); the Python twin moved with them.
25
38
  - `/source` **A table never opens on a lazy continuation line (verify-RC-B4 round 9):** `opensTable` / `tableStartsAt` / `findTableStart` refuse a header that lazily continues a list item's or a block quote's paragraph (no blank line above, not indented to the item's content column, or missing the quote's `>`) — GFM reads it as paragraph text (`- item` then `| a | b |` is no table). Vectors gain `tableStarts` (15 cases, judged against remark-gfm).
26
39
  - `/source` **A table opens exactly where GFM opens one (verify-RC-B4 round 9):** `tableStartsAt` requires the delimiter row to match the header's width for pipe-led headers too (`| a | b |` over `|---|` is no table), refuses a "delimiter" that is a list item (`- | -`), and refuses a header indented 4+ columns past its container (indented code). `startsPipelessTable` accepts a header with one pipe (`| a`) or none (`Notes` over `|---|` is a one-column table), as GFM does. Vectors gain 8 opening cases.
package/dist/index.cjs CHANGED
@@ -7665,6 +7665,51 @@ function mapRange(changes, start, end, unit = "utf16") {
7665
7665
  return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
7666
7666
  }
7667
7667
 
7668
+ // source/link-references.ts
7669
+ function normalizeLinkLabel(label) {
7670
+ return label.trim().replace(/\s+/g, " ").toLowerCase();
7671
+ }
7672
+ var DEFINITION = /^ {0,3}\[((?:[^\]\\]|\\.){1,999})\]:[ \t]*(?:<([^<>\n]*)>|(\S+))(?:[ \t]+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|\(((?:[^()\\]|\\.)*)\)))?[ \t]*$/;
7673
+ function collectLinkDefinitions(text) {
7674
+ const defs = /* @__PURE__ */ new Map();
7675
+ if (!text.includes("]:")) return defs;
7676
+ const lines = text.split("\n");
7677
+ const kinds = fenceLineKinds(text);
7678
+ lines.forEach((line, i) => {
7679
+ if (kinds[i] !== "prose") return;
7680
+ const m = DEFINITION.exec(line);
7681
+ if (!m) return;
7682
+ const label = m[1] ?? "";
7683
+ if (label.startsWith("^")) return;
7684
+ const key = normalizeLinkLabel(label);
7685
+ if (!key || defs.has(key)) return;
7686
+ defs.set(key, { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null });
7687
+ });
7688
+ return defs;
7689
+ }
7690
+ var REFERENCE = /(!?)\[((?:[^\]\\]|\\.)*)\](?:\[((?:[^\]\\]|\\.)*)\])?(?![(:[])/g;
7691
+ var escapeTitle = (title) => title.replace(/["\\]/g, "\\$&");
7692
+ function resolveReferenceLinks(fragment, defs) {
7693
+ if (defs.size === 0 || !fragment.includes("[")) return fragment;
7694
+ const PLACEHOLDER = "\uE011";
7695
+ const spans = [];
7696
+ const masked = mapInlineCodeSpans(fragment, (_range, raw) => {
7697
+ spans.push(raw);
7698
+ return `${PLACEHOLDER}${spans.length - 1}${PLACEHOLDER}`;
7699
+ });
7700
+ const resolved = masked.replace(REFERENCE, (whole, bang, text, ref, at) => {
7701
+ if (at > 0 && masked[at - 1] === "\\") return whole;
7702
+ if (text.startsWith("^")) return whole;
7703
+ const key = normalizeLinkLabel(ref === void 0 || ref === "" ? text : ref);
7704
+ const def = defs.get(key);
7705
+ if (!def) return whole;
7706
+ const title = def.title === null ? "" : ` "${escapeTitle(def.title)}"`;
7707
+ const url = /[\s()<>]/.test(def.url) ? `<${def.url}>` : def.url;
7708
+ return `${bang}[${text}](${url}${title})`;
7709
+ });
7710
+ return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
7711
+ }
7712
+
7668
7713
  // source/gfm-table.ts
7669
7714
  function splitRowSegments(line) {
7670
7715
  const segments = [];
@@ -7693,7 +7738,7 @@ function rowCells(line) {
7693
7738
  function unescapeCellPipes(cell) {
7694
7739
  return cell.replace(/\\\|/g, "|");
7695
7740
  }
7696
- var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
7741
+ var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
7697
7742
  var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
7698
7743
  var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
7699
7744
  var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
@@ -7783,11 +7828,45 @@ function continuesTable(line, containerIndent = 0) {
7783
7828
  function opensTable(lines, index) {
7784
7829
  const line = lines[index] ?? "";
7785
7830
  if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
7786
- return !isLazyContinuation(lines, index);
7831
+ return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
7787
7832
  }
7788
7833
  var QUOTE_LINE = /^ {0,3}>/;
7789
7834
  var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
7790
7835
  var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
7836
+ function htmlBlockEnd(trimmed) {
7837
+ if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
7838
+ if (trimmed.startsWith("<!--")) return /-->/;
7839
+ if (trimmed.startsWith("<?")) return /\?>/;
7840
+ if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
7841
+ if (/^<![A-Za-z]/.test(trimmed)) return />/;
7842
+ if (HTML_BLOCK_TAG.test(trimmed)) return null;
7843
+ if (HTML_COMPLETE_TAG.test(trimmed)) return null;
7844
+ return void 0;
7845
+ }
7846
+ function insideHtmlBlock(lines, index) {
7847
+ let start = index;
7848
+ while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
7849
+ let open;
7850
+ let paragraph = false;
7851
+ for (let k = start; k < index; k += 1) {
7852
+ const line = lines[k] ?? "";
7853
+ if (open !== void 0) {
7854
+ if (open && open.test(line)) open = void 0;
7855
+ continue;
7856
+ }
7857
+ const trimmed = line.trim();
7858
+ const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
7859
+ const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
7860
+ const interrupts = end !== void 0 && !(paragraph && type7);
7861
+ if (!interrupts) {
7862
+ paragraph = true;
7863
+ continue;
7864
+ }
7865
+ paragraph = false;
7866
+ open = end && end.test(trimmed.slice(2)) ? void 0 : end;
7867
+ }
7868
+ return open !== void 0;
7869
+ }
7791
7870
  function isLazyContinuation(lines, index) {
7792
7871
  const header = lines[index] ?? "";
7793
7872
  let first = -1;
@@ -7876,6 +7955,7 @@ exports.classifyInboundEnvelopeMetadata = classifyInboundEnvelopeMetadata;
7876
7955
  exports.classifyInnerFenceLine = classifyInnerFenceLine;
7877
7956
  exports.closeFence = closeFence;
7878
7957
  exports.codeSpanText = codeSpanText;
7958
+ exports.collectLinkDefinitions = collectLinkDefinitions;
7879
7959
  exports.collectReferencedKinds = collectReferencedKinds;
7880
7960
  exports.collectSchemaReferencedKinds = collectSchemaReferencedKinds;
7881
7961
  exports.compareWithExistingKindSchema = compareWithExistingKindSchema;
@@ -7955,6 +8035,7 @@ exports.mapRange = mapRange;
7955
8035
  exports.mergeResidueIntoValue = mergeResidueIntoValue;
7956
8036
  exports.normalizeAiSchemaInput = normalizeAiSchemaInput;
7957
8037
  exports.normalizeJsonRegion = normalizeJsonRegion;
8038
+ exports.normalizeLinkLabel = normalizeLinkLabel;
7958
8039
  exports.nounFamily = nounFamily;
7959
8040
  exports.nounLabel = nounLabel;
7960
8041
  exports.nounTitleColumn = nounTitleColumn;
@@ -7975,6 +8056,7 @@ exports.reconstructRegionValue = reconstructRegionValue;
7975
8056
  exports.rehydrateNodeOutcome = rehydrateNodeOutcome;
7976
8057
  exports.rehydrateRunResult = rehydrateRunResult;
7977
8058
  exports.resetLegacyShellUses = resetLegacyShellUses;
8059
+ exports.resolveReferenceLinks = resolveReferenceLinks;
7978
8060
  exports.resolvesInContent = resolvesInContent;
7979
8061
  exports.reuseEnvelopeIfCurrent = reuseEnvelopeIfCurrent;
7980
8062
  exports.rowCells = rowCells;