@dogsbay/format-openknowledge 0.2.0-beta.101

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.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * OpenKnowledge serializer — TreeNode[] → MDX in the dialect Inkeep
3
+ * OpenKnowledge parses (remark-parse + gfm + github-alerts + math +
4
+ * frontmatter + mdx-jsx; NO remark-directive, wikilinks deprecated).
5
+ *
6
+ * The three blockers the research measured on a real corpus
7
+ * (dogsbay-research/plans/format-openknowledge.md §2) are decided here:
8
+ * 1. links are ROOT-ABSOLUTE with `.md` and a HEADING-SLUG fragment
9
+ * (`/ai/kueue/install.md#installing-kueue`), because OpenKnowledge
10
+ * resolves extension-less paths source-relative and shows `^anchor`
11
+ * block ids as text;
12
+ * 2. NO `^anchor` markers are emitted at all;
13
+ * 3. code blocks are PLAIN fences (`lang` on the info string, `title` as
14
+ * fence meta) — never the `dogsbay-code` envelope.
15
+ *
16
+ * Rich components use the FUMADOCS VOCABULARY (§3.0) with OpenKnowledge's
17
+ * prop names: `<Callout>` (or GFM `> [!note]` when it has no title),
18
+ * `<Accordion title defaultOpen>`, `<Tabs><Tab label>` render natively;
19
+ * `<Steps><Step>`, `<Cards><Card>` land on OpenKnowledge's wildcard
20
+ * (editable raw-MDX blocks — content survives, rendering does not).
21
+ * `deflist` — 13,614 instances on the reference corpus, prose not code —
22
+ * is emitted as READABLE MARKDOWN (a term list), never as a code block.
23
+ * Navigational nodes become plain markdown links (their graph/backlinks
24
+ * feed on links, and a rendered block that cannot navigate is worse).
25
+ *
26
+ * MDX is stricter than markdown: `{` `}` `<` in prose are escaped, and raw
27
+ * HTML is converted to markdown (unbalanced HTML breaks an MDX parse).
28
+ * Everything the target cannot represent is recorded in the ExportLedger
29
+ * against `OPENKNOWLEDGE_CAPABILITIES` — a loss is declared, never silent.
30
+ */
31
+ import type { TreeNode } from "@dogsbay/types";
32
+ import { ExportLedger } from "@dogsbay/serialize-core";
33
+ export interface OpenKnowledgeSerializeOptions {
34
+ /**
35
+ * Rewrites a link target for the exported corpus (root-absolute `.md` +
36
+ * heading fragment). The project layer supplies it with knowledge of every
37
+ * page; the default only normalizes the shape.
38
+ */
39
+ href?: (href: string) => string;
40
+ /** Records degradations; a fresh ledger is used when none is given. */
41
+ ledger?: ExportLedger;
42
+ /** Page path recorded with ledger entries. */
43
+ page?: string;
44
+ }
45
+ export declare function treeToOpenKnowledge(nodes: TreeNode[], options?: OpenKnowledgeSerializeOptions): string;
46
+ /** Root-absolute `.md` shape without page knowledge: `/a/b/` → `/a/b.md`, `#x` kept, external kept. */
47
+ export declare function defaultHref(href: string): string;
48
+ export declare function splitFragment(href: string): [string, string];
49
+ /**
50
+ * MDX treats `{`/`}` as expressions and `<` followed by anything but
51
+ * whitespace as a tag start (`<3`, `<=`, `<-` are all errors); a backslash
52
+ * escape renders literally in both the strict MDX stack and OpenKnowledge's
53
+ * (which restores backslash escapes). Backslashes are escaped FIRST so a
54
+ * literal `\{` in prose does not become `\\{` (= escaped backslash + a LIVE
55
+ * expression). Text starting a paragraph with `import`/`export` is ESM in
56
+ * strict MDX — see `noEsmStart`.
57
+ */
58
+ export declare function escapeMdxText(text: string): string;
59
+ /**
60
+ * The headings a page WILL emit, in emit order, as OpenKnowledge will see
61
+ * their text — headings nested in callouts/tabs/lists included, and the
62
+ * `### class \`name\`` lines api-class/api-member emit (whose textContent
63
+ * is "class name"). Anchors must be computed from THIS, not from an
64
+ * importer's `page.headings` (top-level only, importer-defined text).
65
+ */
66
+ export declare function collectEmittedHeadings(nodes: TreeNode[]): Array<{
67
+ slug: string;
68
+ text: string;
69
+ }>;
70
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAcL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAChC,uEAAuE;IACvE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA8BD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAE,6BAAkC,GAAG,MAAM,CAQ1G;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG5D;AAID;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAukBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAiB/F"}