atdoc-core 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WEDC Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @Doc β€” AI-Native Semantic Document Notation
2
+
3
+ <img src="https://wedc.cc/atd.png" width="64"/>
4
+
5
+ @Doc is a notation designed for three readers: humans who write content, AI that generates content, and compilers that render content. It is not the next Markdown β€” it's the missing notation layer between LLM-generated content and render targets.
6
+
7
+ Start with the [English documentation](docs/en/README.md). Chinese translations and other language editions are also available:
8
+
9
+ | Language | README | Block Syntax Spec | Inline Syntax Spec |
10
+ |:---|:---|:---|:---|
11
+ | πŸ‡ΊπŸ‡Έ English | [README](docs/en/README.md) | [Block-Syntax-Specification](docs/en/Block-Syntax-Specification.md) | [Inline-Syntax-Specification](docs/en/Inline-Syntax-Specification.md) |
12
+ | πŸ‡ΉπŸ‡Ό Traditional Chinese | [README](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-tw/README.md) | [Block-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-tw/Block-Syntax-Specification.md) | [Inline-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-tw/Inline-Syntax-Specification.md) |
13
+ | πŸ‡¨πŸ‡³ Simplified Chinese | [README](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-cn/README.md) | [Block-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-cn/Block-Syntax-Specification.md) | [Inline-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-cn/Inline-Syntax-Specification.md) |
14
+ | πŸ‡―πŸ‡΅ Japanese <sub>(AI translation; may contain errors)</sub> | [README](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ja/README.md) | [Block-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ja/Block-Syntax-Specification.md) | [Inline-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ja/Inline-Syntax-Specification.md) |
15
+ | πŸ‡°πŸ‡· Korean <sub>(AI translation; may contain errors)</sub> | [README](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ko/README.md) | [Block-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ko/Block-Syntax-Specification.md) | [Inline-Syntax-Specification](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ko/Inline-Syntax-Specification.md) |
16
+
17
+ English is the primary language for the package and its documentation; Chinese is secondary. The two `*-Specification.md` files in each language folder describe the grammar (EBNF + semantic rules) for that language edition.
18
+
19
+ ---
20
+
21
+ ## What's in here
22
+
23
+ ```
24
+ src/ Lexer, Parser, registry (single source of truth for nodes), Adapters (two HTML render routes)
25
+ src/editor/ Monarch tokenizer for Monaco-style editors
26
+ tests/ Strict Mode test cases for the Lexer/Parser, plus render verification for each node
27
+ configs/ Node configuration for editor/tooling
28
+ docs/<lang>/ Per-language documentation (README + the two grammar specifications)
29
+ ```
30
+
31
+ ## License
32
+
33
+ MIT β€” see [LICENSE](LICENSE).
@@ -0,0 +1,30 @@
1
+ {
2
+ "id": "AtDoc",
3
+ "extensions": [".atd"],
4
+ "specialRules": {
5
+ "voidNodes": ["hr", "n"],
6
+ "contextNodes": ["tab", "cols", "data"],
7
+ "rawNodes": ["code", "mermaid", "svg", "raw", "kbd", "fn"],
8
+ "escapeSymbols": ["@@"],
9
+ "rawEscapeNodes": ["raw"],
10
+ "rawEscapeSymbols": ["@@]", "@@[", "@]", "@["],
11
+ "strongQuote": { "open": "{[", "close": "]}" }
12
+ },
13
+ "tokenGroups": {
14
+ "Metadata": {
15
+ "metaKeywords": ["meta"]
16
+ },
17
+ "Block": {
18
+ "structuralKeywords": ["heading", "h", "paragraph", "p", "quote", "list", "code", "img", "table", "cols", "data", "hr", "svg"],
19
+ "containerKeywords": ["details", "card"],
20
+ "calloutKeywords": ["note", "tip", "important", "warning", "caution"],
21
+ "widgetKeywords": ["tabs", "tab", "mermaid"]
22
+ },
23
+ "Inline": {
24
+ "formatKeywords": ["mark", "color", "bordered", "bold", "b", "italic", "i", "underline", "u", "del", "raw"],
25
+ "semanticKeywords": ["sup", "sub", "kbd", "link"],
26
+ "footnoteKeywords": ["fn", "defn"],
27
+ "specialKeywords": ["n"]
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,18 @@
1
+ import type { DocASTNode } from './types';
2
+ type Route = 'tailwind' | 'inline';
3
+ export declare class DocTranspiler {
4
+ /** Route A β€” class-driven (Tailwind-style) output. */
5
+ static toTailwindHTML(node: DocASTNode): string;
6
+ /** Route B β€” inline-style output, for universal/legacy targets. */
7
+ static toInlineStyleHTML(node: DocASTNode): string;
8
+ /**
9
+ * Collects every @defn in the document and renders them as one real
10
+ * <ol> at the call site's choosing (normally once, after the full
11
+ * document body) β€” see the 'defn' case in renderNode() for why in-place
12
+ * rendering isn't an option. Returns '' when the document has no
13
+ * footnotes, so callers can append unconditionally.
14
+ */
15
+ static renderFootnotes(nodes: DocASTNode[], route: Route): string;
16
+ }
17
+ export {};
18
+ //# sourceMappingURL=Adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Adapters.d.ts","sourceRoot":"","sources":["../src/Adapters.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;AAscnC,qBAAa,aAAa;IACxB,sDAAsD;IACtD,OAAc,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAErD;IAED,mEAAmE;IACnE,OAAc,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAExD;IAED;;;;;;OAMG;IACH,OAAc,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAKvE;CACF"}
@@ -0,0 +1,484 @@
1
+ // Adapters β€” render a DocASTNode tree to HTML.
2
+ //
3
+ // Tag choices follow the "Renderer Independence" examples already committed
4
+ // to in the syntax/ reference docs (Structural-Blocks.md Β§6, Container-Blocks.md
5
+ // Β§7, Callout-Blocks.md Β§8, Widget-Blocks.md Β§6, Text-Formatting.md Β§7,
6
+ // Semantic-Inline.md Β§6, Footnotes.md Β§7, Special-Nodes.md Β§8) β€” this file
7
+ // exists to make those examples real, not to invent new ones.
8
+ //
9
+ // Two routes, differing only where the grammar actually has something to
10
+ // differ on β€” @mark's, @color's, and @bordered's color tokens (Inline Syntax
11
+ // Specification Β§7, Block Syntax Specification Β§4) and @card's Card Style v1
12
+ // tokens (Block Syntax Specification Β§6) are the only per-instance style
13
+ // slots this Adapter maps to output with a real Route A/B split (class-driven
14
+ // vs inline CSS). @img's Image Style v1 (Β§5, resolveImageStyles()) is also
15
+ // mapped, but always as inline style on both routes β€” same as the pre-existing
16
+ // "(radius=...,border=...)" image options it layers on top of, no Tailwind
17
+ // class equivalent attempted. @details and the Callout Blocks also carry a
18
+ // parsed `styles` slot (registry.ts `styles: true`) but this Adapter doesn't
19
+ // yet map it to visual output. Everything else renders identically on both routes.
20
+ function escapeHtml(s) {
21
+ return s
22
+ .replace(/&/g, '&amp;')
23
+ .replace(/</g, '&lt;')
24
+ .replace(/>/g, '&gt;')
25
+ .replace(/"/g, '&quot;');
26
+ }
27
+ // Word's actual Text Highlight Color swatches (Home > Text Highlight Color),
28
+ // not a muted/pastel reinterpretation β€” index.css's `.mark-<token>` classes
29
+ // (Route A) mirror these exact values, and `mark` there forces black ink on
30
+ // top of them the same way Word never recolors text to match the highlight
31
+ // it sits on. orange has no Word highlighter swatch (only 15 fixed colors,
32
+ // none named "orange") β€” borrowed from Word's Standard Colors row instead.
33
+ const MARK_COLORS = {
34
+ yellow: '#FFFF00',
35
+ red: '#FF0000',
36
+ green: '#00FF00',
37
+ blue: '#0000FF',
38
+ orange: '#FFC000',
39
+ purple: '#800080',
40
+ gray: '#808080',
41
+ };
42
+ // @color's own named-token palette β€” deliberately a separate table from
43
+ // MARK_COLORS: those are Word's highlight-background swatches, and would read
44
+ // as low-contrast, barely-visible text if reused here as a foreground color,
45
+ // so @color gets Word's Font Color "Standard Colors" row instead β€” the same
46
+ // per-key split, just Word's other palette rather than a softened one.
47
+ // index.css's `.color-<token>`/`.bordered-<token>` classes mirror these.
48
+ const COLOR_PRESETS = {
49
+ yellow: '#FFFF00',
50
+ red: '#FF0000',
51
+ green: '#00B050',
52
+ blue: '#0070C0',
53
+ orange: '#FFC000',
54
+ purple: '#7030A0',
55
+ gray: '#808080',
56
+ };
57
+ const HEX_COLOR = /^#[0-9a-fA-F]{6}$/;
58
+ const RADIUS_TOKEN = /^radius-(\d+)$/;
59
+ /**
60
+ * @mark's {styles} color-token resolver β€” accepts either a named token
61
+ * (Inline Syntax Specification Β§7) or a literal "#RRGGBB" hex token.
62
+ * Unknown/malformed tokens resolve to undefined so callers can fall back
63
+ * silently, per Β§6 Unknown Command Fallback's ignore-don't-throw spirit.
64
+ */
65
+ function resolveColorToken(token) {
66
+ if (!token)
67
+ return undefined;
68
+ if (HEX_COLOR.test(token))
69
+ return token;
70
+ return MARK_COLORS[token];
71
+ }
72
+ /** Same idea as resolveColorToken(), but for @color's own {styles} slot and its separate, darker palette (COLOR_PRESETS). */
73
+ function resolveColorPreset(token) {
74
+ if (!token)
75
+ return undefined;
76
+ if (HEX_COLOR.test(token))
77
+ return token;
78
+ return COLOR_PRESETS[token];
79
+ }
80
+ /**
81
+ * @card's {styles} resolver β€” Card Style v1 (Container-Blocks.md Β§4 Card).
82
+ * Deliberately a closed, cross-platform set of two token shapes, not a CSS
83
+ * escape hatch: a literal "#RRGGBB" hex token for background-color, and a
84
+ * "radius-N" token for a border-radius of N pixels. No named-token palette
85
+ * like @mark/@color have β€” either token may be present, absent, or both
86
+ * (comma-separated, order doesn't matter); anything else in the list is
87
+ * silently ignored, per Β§6 Unknown Command Fallback's ignore-don't-throw
88
+ * spirit.
89
+ */
90
+ function resolveCardStyles(tokens) {
91
+ const background = tokens?.find(t => HEX_COLOR.test(t));
92
+ const radiusToken = tokens?.find(t => RADIUS_TOKEN.test(t));
93
+ const radius = radiusToken ? `${radiusToken.match(RADIUS_TOKEN)[1]}px` : undefined;
94
+ return { background, radiusToken, radius };
95
+ }
96
+ /**
97
+ * @img's {styles} resolver β€” Image Style v1 (Block Syntax Specification Β§5
98
+ * Image). Same two token shapes as Card Style v1 (RADIUS_TOKEN/HEX_COLOR are
99
+ * shared), reused for a different, image-appropriate meaning: a "radius-N"
100
+ * token still means border-radius, but the hex token means *border color*
101
+ * here rather than background β€” an image already has its own pixel content,
102
+ * so "paint a background behind it" isn't the useful knob a border is. Both
103
+ * radius and border are opt-in (no styles at all β†’ a bare, undecorated
104
+ * <img>). Explicit {styles} values control the image's border and radius.
105
+ */
106
+ function resolveImageStyles(tokens) {
107
+ const borderColor = tokens?.find(t => HEX_COLOR.test(t));
108
+ const radiusToken = tokens?.find(t => RADIUS_TOKEN.test(t));
109
+ const radius = radiusToken ? `${radiusToken.match(RADIUS_TOKEN)[1]}px` : undefined;
110
+ return { borderColor, radiusToken, radius };
111
+ }
112
+ /** URI scheme inference β€” Inline Syntax Specification Β§8 @link URI Semantics. */
113
+ function resolveUri(raw) {
114
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw))
115
+ return raw; // explicit scheme: MUST be used as-is
116
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(raw))
117
+ return `mailto:${raw}`;
118
+ if (/^\+?[0-9][0-9\- ]*$/.test(raw))
119
+ return `tel:${raw.replace(/[\s-]/g, '')}`;
120
+ return `https://${raw}`;
121
+ }
122
+ /**
123
+ * True for a text child that's pure formatting whitespace β€” the author
124
+ * pretty-printed a nested node onto its own indented line, and the Parser
125
+ * (deliberately, per spec β€” no implicit trimming) kept that indentation as
126
+ * a literal text node. Rendered as-is, it becomes a real, visible space
127
+ * sitting right against the adjacent node's tag boundary (CSS only trims
128
+ * collapsible whitespace at a *line* edge, not at an inline element's inner
129
+ * edge), which is especially obvious once that node has a background or
130
+ * border (@mark, @bordered). A same-line run of spaces with no newline is
131
+ * left untouched β€” that's the author actually asking for a visible gap.
132
+ */
133
+ function isIndentationWhitespace(s) {
134
+ return s.includes('\n') && /^\s*$/.test(s);
135
+ }
136
+ function renderChildren(content, route) {
137
+ return content
138
+ .map(c => {
139
+ if (typeof c !== 'string')
140
+ return renderNode(c, route);
141
+ return isIndentationWhitespace(c) ? '' : escapeHtml(c);
142
+ })
143
+ .join('');
144
+ }
145
+ /**
146
+ * Recursively collects the plain text of a content list, discarding any
147
+ * formatting nodes' tags β€” used where the output must be text-only (e.g.
148
+ * @img's alt attribute), unlike renderChildren() which renders real markup.
149
+ * A formatting node (e.g. @bold) contributes its own nested content's text;
150
+ * a raw-family node (e.g. @kbd, which has no `content`) contributes its
151
+ * `.raw` text instead.
152
+ */
153
+ function extractPlainText(content) {
154
+ return content.map(c => {
155
+ if (typeof c === 'string')
156
+ return c;
157
+ if (c.content.length)
158
+ return extractPlainText(c.content);
159
+ return c.raw ?? '';
160
+ }).join('');
161
+ }
162
+ function renderMark(node, route) {
163
+ const tokens = node.styles ?? [];
164
+ const colorToken = tokens.find(t => resolveColorToken(t) !== undefined);
165
+ const resolvedColor = resolveColorToken(colorToken);
166
+ const inner = renderChildren(node.content, route);
167
+ if (route === 'inline') {
168
+ const styleAttr = resolvedColor ? ` style="background-color: ${resolvedColor};"` : '';
169
+ return `<mark${styleAttr}>${inner}</mark>`;
170
+ }
171
+ // A literal hex token has no Tailwind-style class equivalent β€” fall back to inline style for it.
172
+ const isNamedColor = colorToken !== undefined && !HEX_COLOR.test(colorToken);
173
+ const classes = ['mark', ...(isNamedColor ? [`mark-${colorToken}`] : [])];
174
+ const hexStyle = colorToken && !isNamedColor ? ` style="background-color: ${resolvedColor};"` : '';
175
+ return `<mark class="${classes.join(' ')}"${hexStyle}>${inner}</mark>`;
176
+ }
177
+ /**
178
+ * @bordered β€” shares @color's exact {styles} slot and darker COLOR_PRESETS
179
+ * swatch (resolveColorPreset), just painted onto a border instead of a
180
+ * foreground color. Retires @mark's old 'bordered' modifier token in favor
181
+ * of being its own first-class node, the same way 'underline' already has
182
+ * its own @underline node and 'strikethrough' already has @del.
183
+ */
184
+ function renderBordered(node, route) {
185
+ const resolvedColor = resolveColorPreset(node.color) ?? 'currentColor';
186
+ const inner = renderChildren(node.content, route);
187
+ if (route === 'inline') {
188
+ return `<span style="border: 1px solid ${resolvedColor};">${inner}</span>`;
189
+ }
190
+ const isNamedColor = node.color !== undefined && resolveColorPreset(node.color) !== undefined && !HEX_COLOR.test(node.color);
191
+ const classes = ['bordered', ...(isNamedColor ? [`bordered-${node.color}`] : [])];
192
+ const hexStyle = !isNamedColor ? ` style="border: 1px solid ${resolvedColor};"` : '';
193
+ return `<span class="${classes.join(' ')}"${hexStyle}>${inner}</span>`;
194
+ }
195
+ function renderColor(node, route) {
196
+ // @color is for a precise text color; unlike @mark it doesn't fall back to
197
+ // a default when the token is missing/unrecognized (this Adapter doesn't
198
+ // maintain a "default color" concept for either node) β€” an unresolved
199
+ // token just renders as a plain, uncolored <span>, per the Unknown Command
200
+ // Fallback ignore-don't-throw spirit (Inline Spec Β§6).
201
+ const colorToken = node.color;
202
+ const resolvedColor = resolveColorPreset(colorToken);
203
+ const inner = renderChildren(node.content, route);
204
+ if (route === 'inline') {
205
+ const styleAttr = resolvedColor ? ` style="color: ${resolvedColor};"` : '';
206
+ return `<span${styleAttr}>${inner}</span>`;
207
+ }
208
+ // A literal hex token has no Tailwind-style class equivalent β€” fall back to inline style for it.
209
+ const isNamedColor = resolvedColor !== undefined && !HEX_COLOR.test(colorToken);
210
+ const classes = ['color', ...(isNamedColor ? [`color-${colorToken}`] : [])];
211
+ const hexStyle = resolvedColor && !isNamedColor ? ` style="color: ${resolvedColor};"` : '';
212
+ return `<span class="${classes.join(' ')}"${hexStyle}>${inner}</span>`;
213
+ }
214
+ /**
215
+ * @card β€” Card Style v1's two per-instance styles (see resolveCardStyles()).
216
+ * A hex background has no Tailwind-style class equivalent, so it always
217
+ * falls back to inline style on both routes; radius-N is already a valid
218
+ * class-name fragment, so the tailwind route gets a "card-radius-N" modifier
219
+ * class instead, the same way @mark gets "mark-<token>".
220
+ */
221
+ function renderCard(node, route) {
222
+ const { background, radiusToken, radius } = resolveCardStyles(node.styles);
223
+ const header = node.title ? `<header>${escapeHtml(node.title)}</header>` : '';
224
+ const inner = renderChildren(node.content, route);
225
+ if (route === 'inline') {
226
+ const styleParts = [];
227
+ if (background)
228
+ styleParts.push(`background-color: ${background};`);
229
+ if (radius)
230
+ styleParts.push(`border-radius: ${radius};`);
231
+ const styleAttr = styleParts.length ? ` style="${styleParts.join(' ')}"` : '';
232
+ return `<article${styleAttr}>${header}${inner}</article>`;
233
+ }
234
+ const classes = ['card', ...(radiusToken ? [`card-${radiusToken}`] : [])];
235
+ const styleAttr = background ? ` style="background-color: ${background};"` : '';
236
+ return `<article class="${classes.join(' ')}"${styleAttr}>${header}${inner}</article>`;
237
+ }
238
+ /**
239
+ * @svg is a raw pass-through node (Widget-Blocks-style raw content, like
240
+ * @mermaid) β€” its content is trusted markup the Renderer emits unescaped so
241
+ * the browser actually draws the vector graphic instead of printing source.
242
+ * Because that crosses a trust boundary, strip <script> and on*="" handlers
243
+ * before emitting rather than passing the source through untouched.
244
+ */
245
+ function sanitizeSvg(raw) {
246
+ return raw
247
+ .replace(/<script[\s\S]*?<\/script\s*>/gi, '')
248
+ .replace(/\son[a-z]+\s*=\s*"[^"]*"/gi, '')
249
+ .replace(/\son[a-z]+\s*=\s*'[^']*'/gi, '');
250
+ }
251
+ function renderList(node, route) {
252
+ // @list items are structured 'list-item' nodes built by the Parser
253
+ // (Structural-Blocks.md Β§5 List) β€” every non-empty line is an item, so
254
+ // nested inline nodes (e.g. @bold) inside an item render correctly instead
255
+ // of being flattened to text first. A nested @list is just another content
256
+ // node inside an item, so renderChildren recurses back into renderList for it.
257
+ const items = node.content.filter((c) => typeof c !== 'string' && c.type === 'list-item');
258
+ const tag = node.ordered ? 'ol' : 'ul';
259
+ if (items.length === 0)
260
+ return `<${tag}></${tag}>`;
261
+ const li = items.map(i => {
262
+ const valueAttr = node.ordered && i.marker !== undefined ? ` value="${i.marker}"` : '';
263
+ return `<li${valueAttr}>${renderChildren(i.content, route)}</li>`;
264
+ }).join('');
265
+ return `<${tag}>${li}</${tag}>`;
266
+ }
267
+ function renderTabs(node, route) {
268
+ const tabs = node.tabs ?? [];
269
+ const tablist = tabs
270
+ .map((t, i) => `<button role="tab" aria-controls="tab-panel-${i}">${escapeHtml(t.title ?? '')}</button>`)
271
+ .join('');
272
+ const panels = tabs
273
+ .map((t, i) => `<div role="tabpanel" id="tab-panel-${i}">${renderChildren(t.content, route)}</div>`)
274
+ .join('');
275
+ return `<div class="tabs"><div role="tablist">${tablist}</div>${panels}</div>`;
276
+ }
277
+ function renderNode(node, route) {
278
+ switch (node.type) {
279
+ // Metadata β€” not rendered as visible HTML (Block Syntax Specification Β§9).
280
+ case 'meta':
281
+ return '';
282
+ // Structural Blocks
283
+ case 'heading':
284
+ return `<h${node.level ?? 1}>${renderChildren(node.content, route)}</h${node.level ?? 1}>`;
285
+ case 'paragraph':
286
+ return `<p>${renderChildren(node.content, route)}</p>`;
287
+ case 'quote':
288
+ return `<blockquote>${renderChildren(node.content, route)}</blockquote>`;
289
+ case 'list':
290
+ return renderList(node, route);
291
+ case 'code':
292
+ return `<pre><code class="language-${escapeHtml(node.language ?? 'text')}">${escapeHtml(node.raw ?? '')}</code></pre>`;
293
+ case 'img': {
294
+ const opts = node.imgOptions ?? {};
295
+ const alt = extractPlainText(node.content).trim();
296
+ const attrs = [`src="${escapeHtml(opts.src ?? '')}"`, `alt="${escapeHtml(alt)}"`];
297
+ if (opts.width)
298
+ attrs.push(`width="${escapeHtml(opts.width)}"`);
299
+ if (opts.height)
300
+ attrs.push(`height="${escapeHtml(opts.height)}"`);
301
+ const styleParts = [];
302
+ if (opts.align) {
303
+ const margin = opts.align === 'center' ? '0 auto' : opts.align === 'right' ? '0 0 0 auto' : '0';
304
+ styleParts.push(`display:block;margin:${margin};`);
305
+ }
306
+ // Image Style v1 ({radius-N,#hex} β€” see resolveImageStyles()) takes
307
+ // priority over the older, free-form "(radius=...,border=...)" image
308
+ // options when both are present, since the closed {styles} token set
309
+ // is the more deliberate, more recent input; either source alone still
310
+ // works on its own.
311
+ const { borderColor, radius: styleRadius } = resolveImageStyles(node.styles);
312
+ const radius = styleRadius ?? opts.radius;
313
+ const border = borderColor ? `1px solid ${borderColor}` : opts.border;
314
+ if (radius)
315
+ styleParts.push(`border-radius:${escapeHtml(radius)};`);
316
+ if (border)
317
+ styleParts.push(`border:${escapeHtml(border)};`);
318
+ if (styleParts.length)
319
+ attrs.push(`style="${styleParts.join('')}"`);
320
+ return `<img ${attrs.join(' ')}>`;
321
+ }
322
+ case 'table': {
323
+ // columns/rows hold inline content (text + a curated set of formatting
324
+ // nodes, see registry.ts's isCellAllowedNode), same shape as `content`
325
+ // elsewhere β€” render it the same way, then turn @n's "\n" marker into <br>.
326
+ const thead = `<thead><tr>${(node.columns ?? []).map(c => `<th>${renderChildren(c, route).replace(/\n/g, '<br>')}</th>`).join('')}</tr></thead>`;
327
+ const tbody = `<tbody>${(node.rows ?? [])
328
+ .map(r => `<tr>${r.map(cell => `<td>${renderChildren(cell, route).replace(/\n/g, '<br>')}</td>`).join('')}</tr>`)
329
+ .join('')}</tbody>`;
330
+ return `<table>${thead}${tbody}</table>`;
331
+ }
332
+ case 'hr':
333
+ return '<hr>';
334
+ case 'svg':
335
+ return sanitizeSvg(node.raw ?? '');
336
+ // Container Blocks
337
+ case 'details':
338
+ return `<details><summary>${escapeHtml(node.title ?? 'Details')}</summary>${renderChildren(node.content, route)}</details>`;
339
+ case 'card':
340
+ return renderCard(node, route);
341
+ // Callout Blocks
342
+ case 'note':
343
+ case 'tip':
344
+ case 'important':
345
+ case 'warning':
346
+ case 'caution':
347
+ return `<aside class="${node.type}">${node.title ? `<strong>${escapeHtml(node.title)}</strong> ` : ''}${renderChildren(node.content, route)}</aside>`;
348
+ // Widget Blocks
349
+ case 'tabs':
350
+ return renderTabs(node, route);
351
+ case 'tab':
352
+ // Standalone rendering fallback β€” normally only reached via @tabs.
353
+ return `<section><h4>${escapeHtml(node.title ?? '')}</h4>${renderChildren(node.content, route)}</section>`;
354
+ case 'mermaid':
355
+ return `<pre class="mermaid">${escapeHtml(node.raw ?? '')}</pre>`;
356
+ // Text Formatting
357
+ case 'bold':
358
+ return `<strong>${renderChildren(node.content, route)}</strong>`;
359
+ case 'italic':
360
+ return `<em>${renderChildren(node.content, route)}</em>`;
361
+ case 'underline':
362
+ return `<u>${renderChildren(node.content, route)}</u>`;
363
+ case 'del':
364
+ return `<del>${renderChildren(node.content, route)}</del>`;
365
+ case 'mark':
366
+ return renderMark(node, route);
367
+ case 'color':
368
+ return renderColor(node, route);
369
+ case 'bordered':
370
+ return renderBordered(node, route);
371
+ // Inline code. `@raw`'s opaque domain (Inline Syntax Specification Β§9) is
372
+ // the same thing Markdown's backticks are: content that must not be
373
+ // parsed, shown literally. `<code>` is the semantic tag for exactly that,
374
+ // and its browser default already supplies the monospace font β€” index.css
375
+ // only adds the tint on top. Distinct from `@code`, which is a block and
376
+ // renders as `<pre><code>`; `pre code` resets the inline decoration.
377
+ case 'raw':
378
+ return `<code>${escapeHtml(node.raw ?? '')}</code>`;
379
+ // Semantic Inline
380
+ case 'sup':
381
+ return `<sup>${renderChildren(node.content, route)}</sup>`;
382
+ case 'sub':
383
+ return `<sub>${renderChildren(node.content, route)}</sub>`;
384
+ case 'kbd':
385
+ return `<kbd>${escapeHtml(node.raw ?? '')}</kbd>`;
386
+ case 'link':
387
+ return `<a href="${escapeHtml(resolveUri(node.uri ?? ''))}">${renderChildren(node.content, route)}</a>`;
388
+ // Footnotes
389
+ // @defn is a plain inline-node (Footnotes.md Β§4) β€” an author writing it
390
+ // as its own line at the document's end (the documented convention) gets
391
+ // it wrapped in an implicit <p> by the Parser's paragraph aggregation.
392
+ // Rendering it here as `<li>` (as this case used to) put flow content
393
+ // inside phrasing-only content, which browsers "fix" by force-closing
394
+ // the <p> right before it, splitting it into two empty <p></p>. So
395
+ // @defn renders as nothing in place; DocTranspiler.renderFootnotes()
396
+ // collects every @defn in the document and renders them together as one
397
+ // real <ol> β€” the "collected footnotes list" registry.ts already assumed
398
+ // existed (see its CELL_ALLOWED_INLINE comment).
399
+ case 'defn':
400
+ return '';
401
+ case 'fn':
402
+ return `<sup id="fnref${node.number}"><a href="#fn${node.number}">${node.number}</a></sup>`;
403
+ // Special Nodes
404
+ case 'n':
405
+ return '<br>';
406
+ default:
407
+ // Should be unreachable β€” every registered node is handled above.
408
+ return `<div data-node="${escapeHtml(node.type)}">${renderChildren(node.content, route)}</div>`;
409
+ }
410
+ }
411
+ /**
412
+ * Renders a single @defn as a real footnotes-list item β€” unlike the 'defn'
413
+ * case in renderNode() (which renders nothing in-place, see there for why),
414
+ * this is only ever called on nodes already inside the <ol> built by
415
+ * DocTranspiler.renderFootnotes(), where a bare <li> is legal HTML.
416
+ */
417
+ function renderFootnoteItem(node, route) {
418
+ return `<li id="fn${escapeHtml(node.id ?? '')}">${renderChildren(node.content, route)} <a href="#fnref${escapeHtml(node.id ?? '')}">↩</a></li>`;
419
+ }
420
+ /**
421
+ * Walks the whole document (recursively β€” @defn is a plain inline-node, so
422
+ * it can appear nested inside @quote/@list/@table cells/etc., not just at
423
+ * the top level) collecting every @defn in document order. A @defn's own
424
+ * content isn't walked any further once collected β€” nesting a @defn inside
425
+ * another @defn isn't a meaningful/supported pattern (Footnotes.md Β§4 only
426
+ * documents ordinary inline content there), so there's nothing useful to
427
+ * find by recursing past it.
428
+ */
429
+ function collectFootnoteDefns(nodes) {
430
+ const found = [];
431
+ const visit = (n) => {
432
+ if (n.type === 'defn') {
433
+ found.push(n);
434
+ return;
435
+ }
436
+ for (const c of n.content ?? []) {
437
+ if (typeof c !== 'string')
438
+ visit(c);
439
+ }
440
+ for (const col of n.columns ?? []) {
441
+ for (const c of col)
442
+ if (typeof c !== 'string')
443
+ visit(c);
444
+ }
445
+ for (const row of n.rows ?? []) {
446
+ for (const cell of row)
447
+ for (const c of cell)
448
+ if (typeof c !== 'string')
449
+ visit(c);
450
+ }
451
+ for (const t of n.tabs ?? [])
452
+ visit(t);
453
+ };
454
+ for (const n of nodes) {
455
+ if (typeof n !== 'string')
456
+ visit(n);
457
+ }
458
+ return found;
459
+ }
460
+ export class DocTranspiler {
461
+ /** Route A β€” class-driven (Tailwind-style) output. */
462
+ static toTailwindHTML(node) {
463
+ return renderNode(node, 'tailwind');
464
+ }
465
+ /** Route B β€” inline-style output, for universal/legacy targets. */
466
+ static toInlineStyleHTML(node) {
467
+ return renderNode(node, 'inline');
468
+ }
469
+ /**
470
+ * Collects every @defn in the document and renders them as one real
471
+ * <ol> at the call site's choosing (normally once, after the full
472
+ * document body) β€” see the 'defn' case in renderNode() for why in-place
473
+ * rendering isn't an option. Returns '' when the document has no
474
+ * footnotes, so callers can append unconditionally.
475
+ */
476
+ static renderFootnotes(nodes, route) {
477
+ const defns = collectFootnoteDefns(nodes);
478
+ if (defns.length === 0)
479
+ return '';
480
+ const items = defns.map(n => renderFootnoteItem(n, route)).join('');
481
+ return route === 'tailwind' ? `<ol class="footnotes">${items}</ol>` : `<ol>${items}</ol>`;
482
+ }
483
+ }
484
+ //# sourceMappingURL=Adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../src/Adapters.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,4EAA4E;AAC5E,iFAAiF;AACjF,wEAAwE;AACxE,2EAA2E;AAC3E,8DAA8D;AAC9D,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,mFAAmF;AAMnF,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC;SACL,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,MAAM,WAAW,GAA2B;IAC1C,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;IAChB,I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