@fuzdev/mdz 0.2.0 → 0.4.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/README.md +4 -0
- package/dist/Mdz.svelte +18 -9
- package/dist/Mdz.svelte.d.ts +9 -2
- package/dist/Mdz.svelte.d.ts.map +1 -1
- package/dist/MdzNodeView.svelte +129 -115
- package/dist/MdzNodeView.svelte.d.ts +4 -1
- package/dist/MdzNodeView.svelte.d.ts.map +1 -1
- package/dist/MdzPrecompiled.svelte +3 -3
- package/dist/MdzPrecompiled.svelte.d.ts.map +1 -1
- package/dist/MdzRoot.svelte +3 -3
- package/dist/MdzRoot.svelte.d.ts.map +1 -1
- package/dist/MdzStream.svelte +6 -6
- package/dist/MdzStream.svelte.d.ts.map +1 -1
- package/dist/MdzStreamNodeView.svelte +129 -118
- package/dist/MdzStreamNodeView.svelte.d.ts +4 -1
- package/dist/MdzStreamNodeView.svelte.d.ts.map +1 -1
- package/dist/context_helpers.js +1 -1
- package/dist/mdz.d.ts +6 -0
- package/dist/mdz.d.ts.map +1 -1
- package/dist/mdz.js +8 -0
- package/dist/mdz_contexts.d.ts.map +1 -1
- package/dist/mdz_debug_work.d.ts +38 -0
- package/dist/mdz_debug_work.d.ts.map +1 -0
- package/dist/mdz_debug_work.js +37 -0
- package/dist/mdz_helpers.d.ts +61 -0
- package/dist/mdz_helpers.d.ts.map +1 -1
- package/dist/mdz_helpers.js +74 -2
- package/dist/mdz_lexer.d.ts +12 -0
- package/dist/mdz_lexer.d.ts.map +1 -1
- package/dist/mdz_lexer.js +190 -40
- package/dist/mdz_opcodes.d.ts.map +1 -1
- package/dist/mdz_opcodes_to_nodes.d.ts.map +1 -1
- package/dist/mdz_opcodes_to_nodes.js +22 -17
- package/dist/mdz_stream_parser.d.ts.map +1 -1
- package/dist/mdz_stream_parser.js +8 -8
- package/dist/mdz_stream_parser_block.js +5 -5
- package/dist/mdz_stream_parser_inline.d.ts.map +1 -1
- package/dist/mdz_stream_parser_inline.js +22 -20
- package/dist/mdz_stream_parser_link.d.ts.map +1 -1
- package/dist/mdz_stream_parser_link.js +88 -56
- package/dist/mdz_stream_parser_list.d.ts.map +1 -1
- package/dist/mdz_stream_parser_list.js +23 -9
- package/dist/mdz_stream_parser_state.d.ts +29 -0
- package/dist/mdz_stream_parser_state.d.ts.map +1 -1
- package/dist/mdz_stream_parser_state.js +59 -10
- package/dist/mdz_stream_parser_table.d.ts +3 -2
- package/dist/mdz_stream_parser_table.d.ts.map +1 -1
- package/dist/mdz_stream_parser_table.js +24 -13
- package/dist/mdz_stream_parser_text.d.ts.map +1 -1
- package/dist/mdz_stream_parser_text.js +36 -25
- package/dist/mdz_stream_parser_url.js +7 -7
- package/dist/mdz_stream_state.svelte.d.ts.map +1 -1
- package/dist/mdz_to_svelte.d.ts +1 -1
- package/dist/mdz_to_svelte.d.ts.map +1 -1
- package/dist/mdz_to_svelte.js +28 -31
- package/dist/mdz_token_parser.d.ts.map +1 -1
- package/dist/mdz_token_parser.js +24 -25
- package/dist/svelte_preprocess_mdz.d.ts +2 -2
- package/dist/svelte_preprocess_mdz.d.ts.map +1 -1
- package/dist/svelte_preprocess_mdz.js +41 -47
- package/package.json +28 -40
- package/src/lib/context_helpers.ts +2 -2
- package/src/lib/mdz.ts +11 -2
- package/src/lib/mdz_contexts.ts +5 -5
- package/src/lib/mdz_debug_work.ts +38 -0
- package/src/lib/mdz_helpers.ts +126 -23
- package/src/lib/mdz_lexer.ts +243 -93
- package/src/lib/mdz_opcodes.ts +1 -1
- package/src/lib/mdz_opcodes_to_nodes.ts +35 -30
- package/src/lib/mdz_stream_parser.ts +17 -17
- package/src/lib/mdz_stream_parser_block.ts +14 -14
- package/src/lib/mdz_stream_parser_inline.ts +38 -34
- package/src/lib/mdz_stream_parser_link.ts +99 -66
- package/src/lib/mdz_stream_parser_list.ts +41 -29
- package/src/lib/mdz_stream_parser_state.ts +100 -28
- package/src/lib/mdz_stream_parser_table.ts +47 -36
- package/src/lib/mdz_stream_parser_text.ts +40 -39
- package/src/lib/mdz_stream_parser_url.ts +11 -11
- package/src/lib/mdz_stream_state.svelte.ts +8 -8
- package/src/lib/mdz_to_svelte.ts +38 -46
- package/src/lib/mdz_token_parser.ts +55 -58
- package/src/lib/svelte_preprocess_mdz.ts +92 -89
- package/src/lib/tsdoc_mdz.ts +1 -1
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {resolve} from '$app/paths';
|
|
2
|
+
import { resolve } from '$app/paths';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
mdz_resolve_relative_path,
|
|
6
|
-
mdz_is_safe_reference,
|
|
7
|
-
mdz_is_void_element,
|
|
8
|
-
} from './mdz_helpers.js';
|
|
9
|
-
import MdzStreamNodeView from './MdzStreamNodeView.svelte';
|
|
4
|
+
import { mdz_classify_link, mdz_is_void_element } from './mdz_helpers.js';
|
|
10
5
|
import {
|
|
11
6
|
mdz_components_context,
|
|
12
7
|
mdz_elements_context,
|
|
13
8
|
mdz_base_context,
|
|
14
9
|
mdz_code_context,
|
|
15
|
-
mdz_codeblock_context
|
|
10
|
+
mdz_codeblock_context
|
|
16
11
|
} from './mdz_contexts.js';
|
|
17
|
-
import type {MdzStreamNode} from './mdz_stream_state.svelte.js';
|
|
18
|
-
import type {MdzTableAlign} from './mdz.js';
|
|
12
|
+
import type { MdzStreamNode } from './mdz_stream_state.svelte.js';
|
|
13
|
+
import type { MdzTableAlign } from './mdz.js';
|
|
19
14
|
|
|
20
15
|
const {
|
|
21
16
|
node,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
nodes
|
|
18
|
+
}:
|
|
19
|
+
// exactly one of `node`/`nodes` — the array form renders a whole tree
|
|
20
|
+
// through this single component instance (used by `MdzStream`)
|
|
21
|
+
{ node: MdzStreamNode; nodes?: undefined } | { node?: undefined; nodes: Array<MdzStreamNode> } =
|
|
22
|
+
$props();
|
|
25
23
|
|
|
26
24
|
const get_components = mdz_components_context.get_maybe();
|
|
27
25
|
const get_elements = mdz_elements_context.get_maybe();
|
|
@@ -38,125 +36,136 @@
|
|
|
38
36
|
n.content || n.children.map((c) => c.content).join('');
|
|
39
37
|
</script>
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
<!-- The tree renders through recursive snippets rather than recursive
|
|
40
|
+
component instances — one component (and one set of context reads) per
|
|
41
|
+
tree instead of per node. -->
|
|
42
|
+
{#if nodes}
|
|
43
|
+
{@render render_children(nodes)}
|
|
44
|
+
{:else if node}
|
|
45
|
+
{@render render_node(node)}
|
|
46
|
+
{/if}
|
|
47
|
+
|
|
48
|
+
{#snippet render_node(node: MdzStreamNode)}
|
|
49
|
+
{#if node.type === 'Element'}
|
|
50
|
+
{@const element_config = get_elements?.()?.get(node.name ?? '')}
|
|
51
|
+
{#if element_config !== undefined}
|
|
52
|
+
{#if mdz_is_void_element(node.name ?? '')}
|
|
53
|
+
<!-- void elements cannot have content — any parsed children are dropped -->
|
|
54
|
+
<svelte:element this={node.name} />
|
|
55
|
+
{:else}
|
|
56
|
+
<svelte:element this={node.name}>
|
|
57
|
+
{#if node.children.length > 0}
|
|
58
|
+
{@render render_children(node.children)}
|
|
59
|
+
{/if}
|
|
60
|
+
</svelte:element>
|
|
61
|
+
{/if}
|
|
47
62
|
{:else}
|
|
48
|
-
|
|
63
|
+
{@render render_unregistered_tag(node.name ?? '', node.children)}
|
|
64
|
+
{/if}
|
|
65
|
+
{:else if node.type === 'Component'}
|
|
66
|
+
{@const Component = get_components?.()?.get(node.name ?? '')}
|
|
67
|
+
{#if Component}
|
|
68
|
+
<Component>
|
|
49
69
|
{#if node.children.length > 0}
|
|
50
70
|
{@render render_children(node.children)}
|
|
51
71
|
{/if}
|
|
52
|
-
</
|
|
72
|
+
</Component>
|
|
73
|
+
{:else}
|
|
74
|
+
{@render render_unregistered_tag(node.name ?? '', node.children)}
|
|
53
75
|
{/if}
|
|
54
|
-
{:else}
|
|
55
|
-
{
|
|
56
|
-
{
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
{:else if node.type === 'Text'}
|
|
77
|
+
{node.content}
|
|
78
|
+
{:else if node.type === 'Code'}
|
|
79
|
+
{@const Code = get_code?.()}
|
|
80
|
+
{@const code_content = streaming_content(node)}
|
|
81
|
+
{#if Code}
|
|
82
|
+
<Code reference={code_content} />
|
|
83
|
+
{:else}
|
|
84
|
+
<code>{code_content}</code>
|
|
85
|
+
{/if}
|
|
86
|
+
{:else if node.type === 'Bold'}
|
|
87
|
+
<strong>{@render render_children(node.children)}</strong>
|
|
88
|
+
{:else if node.type === 'Italic'}
|
|
89
|
+
<em>{@render render_children(node.children)}</em>
|
|
90
|
+
{:else if node.type === 'Strikethrough'}
|
|
91
|
+
<s>{@render render_children(node.children)}</s>
|
|
92
|
+
{:else if node.type === 'Link'}
|
|
93
|
+
{@const link = mdz_classify_link(node.reference ?? '', node.link_type, get_mdz_base?.())}
|
|
94
|
+
{#if link.kind === 'unsafe'}
|
|
95
|
+
{@render render_children(node.children)}
|
|
96
|
+
{:else if link.kind === 'resolve'}
|
|
97
|
+
<a href={resolve(link.href as any)}>{@render render_children(node.children)}</a>
|
|
98
|
+
{:else if link.kind === 'external'}
|
|
99
|
+
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
|
100
|
+
<a href={link.href} target="_blank" rel="noopener">
|
|
62
101
|
{@render render_children(node.children)}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{@render render_unregistered_tag(node.name ?? '', node.children)}
|
|
67
|
-
{/if}
|
|
68
|
-
{:else if node.type === 'Text'}
|
|
69
|
-
{node.content}
|
|
70
|
-
{:else if node.type === 'Code'}
|
|
71
|
-
{@const Code = get_code?.()}
|
|
72
|
-
{@const code_content = streaming_content(node)}
|
|
73
|
-
{#if Code}
|
|
74
|
-
<Code reference={code_content} />
|
|
75
|
-
{:else}
|
|
76
|
-
<code>{code_content}</code>
|
|
77
|
-
{/if}
|
|
78
|
-
{:else if node.type === 'Bold'}
|
|
79
|
-
<strong>{@render render_children(node.children)}</strong>
|
|
80
|
-
{:else if node.type === 'Italic'}
|
|
81
|
-
<em>{@render render_children(node.children)}</em>
|
|
82
|
-
{:else if node.type === 'Strikethrough'}
|
|
83
|
-
<s>{@render render_children(node.children)}</s>
|
|
84
|
-
{:else if node.type === 'Link'}
|
|
85
|
-
{@const reference = node.reference ?? ''}
|
|
86
|
-
{#if !mdz_is_safe_reference(reference)}
|
|
87
|
-
{@render render_children(node.children)}
|
|
88
|
-
{:else if node.link_type === 'internal'}
|
|
89
|
-
{@const skip_resolve = reference.startsWith('#') || reference.startsWith('?')}
|
|
90
|
-
{@const mdz_base = get_mdz_base?.()}
|
|
91
|
-
{#if reference.startsWith('.') && mdz_base}
|
|
92
|
-
{@const resolved = mdz_resolve_relative_path(reference, mdz_base)}
|
|
93
|
-
<a href={resolve(resolved as any)}>{@render render_children(node.children)}</a>
|
|
94
|
-
{:else if skip_resolve || reference.startsWith('.') || !reference.startsWith('/')}
|
|
95
|
-
<!-- Fragment, query, and relative links (including bare references like `foo`) skip resolve() -->
|
|
96
|
-
<!-- resolve() only accepts absolute pathnames or route IDs and throws on anything else -->
|
|
102
|
+
</a>
|
|
103
|
+
{:else}
|
|
104
|
+
<!-- fragment/query/relative/bare references skip resolve() (it accepts only absolute paths) -->
|
|
97
105
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
|
98
|
-
<a href={
|
|
106
|
+
<a href={link.href}>{@render render_children(node.children)}</a>
|
|
107
|
+
{/if}
|
|
108
|
+
{:else if node.type === 'Paragraph'}
|
|
109
|
+
<p>{@render render_children(node.children)}</p>
|
|
110
|
+
{:else if node.type === 'List'}
|
|
111
|
+
{#if node.ordered}
|
|
112
|
+
<ol start={node.start_number === 1 ? undefined : node.start_number}>
|
|
113
|
+
{@render render_children(node.children)}
|
|
114
|
+
</ol>
|
|
99
115
|
{:else}
|
|
100
|
-
<
|
|
116
|
+
<ul>{@render render_children(node.children)}</ul>
|
|
101
117
|
{/if}
|
|
102
|
-
{:else}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<
|
|
106
|
-
{
|
|
107
|
-
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
{:else if node.type === 'ListItem'}
|
|
119
|
+
<li>{@render render_children(node.children)}</li>
|
|
120
|
+
{:else if node.type === 'Blockquote'}
|
|
121
|
+
<blockquote>{@render render_children(node.children)}</blockquote>
|
|
122
|
+
{:else if node.type === 'Table'}
|
|
123
|
+
{@const align = node.align ?? []}
|
|
124
|
+
<!-- by grammar the header row is always first (and the only one) — read
|
|
125
|
+
it by index and skip it per-row in the body, rather than filtering: a
|
|
126
|
+
filter re-partitions every prior row on each streamed row append,
|
|
127
|
+
going O(n²) across a streamed table -->
|
|
128
|
+
{@const header_row = node.children[0]?.header ? node.children[0] : undefined}
|
|
129
|
+
<table>
|
|
130
|
+
{#if header_row}
|
|
131
|
+
<thead>
|
|
132
|
+
<tr>
|
|
133
|
+
{@render render_cells(header_row, 'th', align)}
|
|
134
|
+
</tr>
|
|
135
|
+
</thead>
|
|
136
|
+
{/if}
|
|
137
|
+
{#if node.children.length > (header_row ? 1 : 0)}
|
|
138
|
+
<tbody>
|
|
139
|
+
{#each node.children as row (row.id)}
|
|
140
|
+
{#if !row.header}
|
|
141
|
+
<tr>
|
|
142
|
+
{@render render_cells(row, 'td', align)}
|
|
143
|
+
</tr>
|
|
144
|
+
{/if}
|
|
145
|
+
{/each}
|
|
146
|
+
</tbody>
|
|
147
|
+
{/if}
|
|
148
|
+
</table>
|
|
149
|
+
{:else if node.type === 'Hr'}
|
|
150
|
+
<hr />
|
|
151
|
+
{:else if node.type === 'Heading'}
|
|
152
|
+
<svelte:element this={`h${node.level}`} id={node.heading_id || undefined}>
|
|
112
153
|
{@render render_children(node.children)}
|
|
113
|
-
</
|
|
114
|
-
{:else}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
{:else
|
|
120
|
-
|
|
121
|
-
{:else if node.type === 'Table'}
|
|
122
|
-
{@const align = node.align ?? []}
|
|
123
|
-
{@const header_rows = node.children.filter((r) => r.header)}
|
|
124
|
-
{@const body_rows = node.children.filter((r) => !r.header)}
|
|
125
|
-
<table>
|
|
126
|
-
{#if header_rows.length > 0}
|
|
127
|
-
<thead>
|
|
128
|
-
{#each header_rows as row (row.id)}
|
|
129
|
-
<tr>{@render render_cells(row, 'th', align)}</tr>
|
|
130
|
-
{/each}
|
|
131
|
-
</thead>
|
|
132
|
-
{/if}
|
|
133
|
-
{#if body_rows.length > 0}
|
|
134
|
-
<tbody>
|
|
135
|
-
{#each body_rows as row (row.id)}
|
|
136
|
-
<tr>{@render render_cells(row, 'td', align)}</tr>
|
|
137
|
-
{/each}
|
|
138
|
-
</tbody>
|
|
154
|
+
</svelte:element>
|
|
155
|
+
{:else if node.type === 'Codeblock'}
|
|
156
|
+
{@const Codeblock = get_codeblock?.()}
|
|
157
|
+
{@const codeblock_content = streaming_content(node)}
|
|
158
|
+
{#if Codeblock}
|
|
159
|
+
<Codeblock lang={node.lang ?? null} content={codeblock_content} />
|
|
160
|
+
{:else}
|
|
161
|
+
<pre><code>{codeblock_content}</code></pre>
|
|
139
162
|
{/if}
|
|
140
|
-
</table>
|
|
141
|
-
{:else if node.type === 'Hr'}
|
|
142
|
-
<hr />
|
|
143
|
-
{:else if node.type === 'Heading'}
|
|
144
|
-
<svelte:element this={`h${node.level}`} id={node.heading_id || undefined}>
|
|
145
|
-
{@render render_children(node.children)}
|
|
146
|
-
</svelte:element>
|
|
147
|
-
{:else if node.type === 'Codeblock'}
|
|
148
|
-
{@const Codeblock = get_codeblock?.()}
|
|
149
|
-
{@const codeblock_content = streaming_content(node)}
|
|
150
|
-
{#if Codeblock}
|
|
151
|
-
<Codeblock lang={node.lang ?? null} content={codeblock_content} />
|
|
152
|
-
{:else}
|
|
153
|
-
<pre><code>{codeblock_content}</code></pre>
|
|
154
163
|
{/if}
|
|
155
|
-
{/
|
|
164
|
+
{/snippet}
|
|
156
165
|
|
|
157
166
|
{#snippet render_children(nodes: Array<MdzStreamNode>)}
|
|
158
167
|
{#each nodes as node (node.id)}
|
|
159
|
-
|
|
168
|
+
{@render render_node(node)}
|
|
160
169
|
{/each}
|
|
161
170
|
{/snippet}
|
|
162
171
|
|
|
@@ -173,8 +182,10 @@
|
|
|
173
182
|
{#snippet render_unregistered_tag(name: string, children: Array<MdzStreamNode>)}
|
|
174
183
|
{#if children.length > 0}
|
|
175
184
|
<code class="color_c_50"><{name}></code>{@render render_children(children)}<code
|
|
176
|
-
class="color_c_50"
|
|
185
|
+
class="color_c_50"
|
|
177
186
|
>
|
|
187
|
+
</{name}>
|
|
188
|
+
</code>
|
|
178
189
|
{:else}
|
|
179
190
|
<code class="color_c_50"><{name} /></code>
|
|
180
191
|
{/if}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import MdzStreamNodeView from './MdzStreamNodeView.svelte';
|
|
2
1
|
import type { MdzStreamNode } from './mdz_stream_state.svelte.js';
|
|
3
2
|
type $$ComponentProps = {
|
|
4
3
|
node: MdzStreamNode;
|
|
4
|
+
nodes?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
node?: undefined;
|
|
7
|
+
nodes: Array<MdzStreamNode>;
|
|
5
8
|
};
|
|
6
9
|
declare const MdzStreamNodeView: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
10
|
type MdzStreamNodeView = ReturnType<typeof MdzStreamNodeView>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MdzStreamNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzStreamNodeView.svelte"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MdzStreamNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzStreamNodeView.svelte"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGjE,KAAK,gBAAgB,GAGpB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CAAE,CAAC;AAoLjG,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
|
package/dist/context_helpers.js
CHANGED
package/dist/mdz.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export declare class MdzTableCellParser {
|
|
|
76
76
|
#private;
|
|
77
77
|
/** @param text - the buffer the cell spans index into (stable across a row). */
|
|
78
78
|
constructor(text: string);
|
|
79
|
+
/**
|
|
80
|
+
* Rebind to a new buffer so one instance serves a whole table — the
|
|
81
|
+
* streaming path rebinds per row (the buffer string changes across feeds;
|
|
82
|
+
* the lexer's search memo survives when it doesn't).
|
|
83
|
+
*/
|
|
84
|
+
rebind(text: string): void;
|
|
79
85
|
parse(cell_start: number, cell_end: number): Array<MdzNode>;
|
|
80
86
|
}
|
|
81
87
|
export type MdzNode = MdzNodeText | MdzNodeCode | MdzNodeCodeblock | MdzNodeBold | MdzNodeItalic | MdzNodeStrikethrough | MdzNodeLink | MdzNodeParagraph | MdzNodeHr | MdzNodeHeading | MdzNodeList | MdzNodeListItem | MdzNodeBlockquote | MdzNodeTable | MdzNodeTableRow | MdzNodeTableCell | MdzNodeElement | MdzNodeComponent;
|
package/dist/mdz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz.ts"],"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WAAW,CAAC;IAClB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACzB"}
|
package/dist/mdz.js
CHANGED
|
@@ -82,6 +82,14 @@ export class MdzTableCellParser {
|
|
|
82
82
|
constructor(text) {
|
|
83
83
|
this.#lexer = new MdzLexer(text);
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Rebind to a new buffer so one instance serves a whole table — the
|
|
87
|
+
* streaming path rebinds per row (the buffer string changes across feeds;
|
|
88
|
+
* the lexer's search memo survives when it doesn't).
|
|
89
|
+
*/
|
|
90
|
+
rebind(text) {
|
|
91
|
+
this.#lexer.rebind(text);
|
|
92
|
+
}
|
|
85
93
|
parse(cell_start, cell_end) {
|
|
86
94
|
this.#parser.reset(this.#lexer.lex_table_cell(cell_start, cell_end));
|
|
87
95
|
return this.#parser.parse_inline_run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_contexts.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mdz_contexts.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIxC;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;AAEnG;;;GAGG;AACH,eAAO,MAAM,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;GAOG;AACH,eAAO,MAAM,6BAA6B,GAAI,CAAC,EAC9C,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAC5B,UAAU,MAAM,CAAC,GAAG,SAAS,KAC3B,IAGF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic scan-work counter for the complexity-ratio guards
|
|
3
|
+
* (`mdz_scaling_ratio.test.ts`). Off by default; when `enabled`, the parser hot
|
|
4
|
+
* paths accumulate the number of characters scanned (and tag-stack frames
|
|
5
|
+
* walked) into `total`. Unlike wall-clock timing this is a pure function of
|
|
6
|
+
* input + algorithm — invariant across machines, runs, and thermal state — so a
|
|
7
|
+
* super-linear regression shows up as a work ratio > ~linear regardless of the
|
|
8
|
+
* ~2× machine variance that makes absolute timing unusable here. Its sole
|
|
9
|
+
* consumer is `mdz_scaling_ratio.test.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Coverage is the dominant re-scan choke points — `#index_of` + `#tokenize_text`
|
|
12
|
+
* (sync) and the streaming memo scans, `consume_text_run`, and `try_close_tag`'s
|
|
13
|
+
* stack walk — not every scan. A super-linear regression isolated to an
|
|
14
|
+
* *uncounted* probe (e.g. `#has_paragraph_break_between`, the tag-name collection
|
|
15
|
+
* loop, the URL/path probes) wouldn't move the ratio; extend the instrumentation
|
|
16
|
+
* if hot cost ever migrates there.
|
|
17
|
+
*
|
|
18
|
+
* Zero store when disabled: each instrumented site guards on `enabled` (a single
|
|
19
|
+
* branch-predicted property load, the same category as the shipped `DEV`
|
|
20
|
+
* checks). It is deliberately NOT the `esm-env` `DEV` flag — `DEV` is true under
|
|
21
|
+
* every `gro test`/`gro dev` run, which would leave the counter live in ordinary
|
|
22
|
+
* development; this flag is flipped true only by the ratio test.
|
|
23
|
+
*
|
|
24
|
+
* @nodocs
|
|
25
|
+
*/
|
|
26
|
+
export declare const mdz_debug_work: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
total: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Reset the counter and set whether the hot paths accumulate into it. Tests call
|
|
32
|
+
* `mdz_debug_work_reset()` immediately before a parse and read
|
|
33
|
+
* `mdz_debug_work.total` immediately after; pass `false` to disable and zero it.
|
|
34
|
+
*
|
|
35
|
+
* @nodocs
|
|
36
|
+
*/
|
|
37
|
+
export declare const mdz_debug_work_reset: (enabled?: boolean) => void;
|
|
38
|
+
//# sourceMappingURL=mdz_debug_work.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdz_debug_work.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_debug_work.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAiC,CAAC;AAEhG;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,iBAAc,KAAG,IAGrD,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic scan-work counter for the complexity-ratio guards
|
|
3
|
+
* (`mdz_scaling_ratio.test.ts`). Off by default; when `enabled`, the parser hot
|
|
4
|
+
* paths accumulate the number of characters scanned (and tag-stack frames
|
|
5
|
+
* walked) into `total`. Unlike wall-clock timing this is a pure function of
|
|
6
|
+
* input + algorithm — invariant across machines, runs, and thermal state — so a
|
|
7
|
+
* super-linear regression shows up as a work ratio > ~linear regardless of the
|
|
8
|
+
* ~2× machine variance that makes absolute timing unusable here. Its sole
|
|
9
|
+
* consumer is `mdz_scaling_ratio.test.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Coverage is the dominant re-scan choke points — `#index_of` + `#tokenize_text`
|
|
12
|
+
* (sync) and the streaming memo scans, `consume_text_run`, and `try_close_tag`'s
|
|
13
|
+
* stack walk — not every scan. A super-linear regression isolated to an
|
|
14
|
+
* *uncounted* probe (e.g. `#has_paragraph_break_between`, the tag-name collection
|
|
15
|
+
* loop, the URL/path probes) wouldn't move the ratio; extend the instrumentation
|
|
16
|
+
* if hot cost ever migrates there.
|
|
17
|
+
*
|
|
18
|
+
* Zero store when disabled: each instrumented site guards on `enabled` (a single
|
|
19
|
+
* branch-predicted property load, the same category as the shipped `DEV`
|
|
20
|
+
* checks). It is deliberately NOT the `esm-env` `DEV` flag — `DEV` is true under
|
|
21
|
+
* every `gro test`/`gro dev` run, which would leave the counter live in ordinary
|
|
22
|
+
* development; this flag is flipped true only by the ratio test.
|
|
23
|
+
*
|
|
24
|
+
* @nodocs
|
|
25
|
+
*/
|
|
26
|
+
export const mdz_debug_work = { enabled: false, total: 0 };
|
|
27
|
+
/**
|
|
28
|
+
* Reset the counter and set whether the hot paths accumulate into it. Tests call
|
|
29
|
+
* `mdz_debug_work_reset()` immediately before a parse and read
|
|
30
|
+
* `mdz_debug_work.total` immediately after; pass `false` to disable and zero it.
|
|
31
|
+
*
|
|
32
|
+
* @nodocs
|
|
33
|
+
*/
|
|
34
|
+
export const mdz_debug_work_reset = (enabled = true) => {
|
|
35
|
+
mdz_debug_work.enabled = enabled;
|
|
36
|
+
mdz_debug_work.total = 0;
|
|
37
|
+
};
|
package/dist/mdz_helpers.d.ts
CHANGED
|
@@ -93,6 +93,23 @@ export declare const MIN_CODEBLOCK_BACKTICKS = 3;
|
|
|
93
93
|
export declare const MAX_LIST_NUMBER_DIGITS = 9;
|
|
94
94
|
/** @nodocs */
|
|
95
95
|
export declare const MAX_HEADING_LEVEL = 6;
|
|
96
|
+
/**
|
|
97
|
+
* Cap on inline link/tag nesting depth. Reached at this many open
|
|
98
|
+
* `Link`/`Element`/`Component` containers, a further `[` or `<tag>` opener
|
|
99
|
+
* renders as literal text in both parsers rather than opening — a strict
|
|
100
|
+
* untrusted-content dialect's bound on pathological nesting (CommonMark
|
|
101
|
+
* permits such a limit). It bounds both the sync lexer's recursion depth (no
|
|
102
|
+
* stack overflow) and, with the failure memo, its revert re-scan work (linear
|
|
103
|
+
* instead of quadratic) on adversarial nested `[`/`<`. Deliberately far above
|
|
104
|
+
* any real content (inline nesting rarely exceeds a handful); only pathological
|
|
105
|
+
* input reaches it. Mirrored in the streaming parser so the two agree on where
|
|
106
|
+
* the cap bites. Delimiters (`**`/`_`/`~~`/`` ` ``) are uncounted: first-closer-wins
|
|
107
|
+
* keeps them from nesting deeply on their own, and mixed delimiter/link chains
|
|
108
|
+
* only deep-nest through the links, which this bounds.
|
|
109
|
+
*
|
|
110
|
+
* @nodocs
|
|
111
|
+
*/
|
|
112
|
+
export declare const MAX_INLINE_NESTING_DEPTH = 100;
|
|
96
113
|
/** @nodocs */
|
|
97
114
|
export declare const HTTPS_PREFIX_LENGTH = 8;
|
|
98
115
|
/** @nodocs */
|
|
@@ -268,6 +285,18 @@ export declare const is_tag_name_char: (char_code: number) => boolean;
|
|
|
268
285
|
export declare const is_word_char: (char_code: number) => boolean;
|
|
269
286
|
/** @nodocs */
|
|
270
287
|
export declare const is_valid_path_char: (char_code: number) => boolean;
|
|
288
|
+
/** Always ends a text run: `` ` `` `*` `_` `~` `[` `]` `<`. @nodocs */
|
|
289
|
+
export declare const TEXT_CLASS_STOP = 1;
|
|
290
|
+
/** `\n` — run handling is context-dependent (soft break, paragraph break, block lookahead). @nodocs */
|
|
291
|
+
export declare const TEXT_CLASS_NEWLINE = 2;
|
|
292
|
+
/** `h`/`H` — potential URL scheme start, needs the prefix probe. @nodocs */
|
|
293
|
+
export declare const TEXT_CLASS_URL = 4;
|
|
294
|
+
/** `/` and `.` — potential path start, needs the boundary probe. @nodocs */
|
|
295
|
+
export declare const TEXT_CLASS_PATH = 8;
|
|
296
|
+
/** `\` — a literal-pipe escape candidate inside table cells only. @nodocs */
|
|
297
|
+
export declare const TEXT_CLASS_BACKSLASH = 16;
|
|
298
|
+
/** @nodocs */
|
|
299
|
+
export declare const TEXT_SCAN_CLASS: Uint8Array;
|
|
271
300
|
/**
|
|
272
301
|
* Trim trailing punctuation from URL/path per RFC 3986 and GFM rules.
|
|
273
302
|
* - Trims simple trailing: .,;:!?]
|
|
@@ -333,6 +362,38 @@ export declare const mdz_is_void_element: (name: string) => boolean;
|
|
|
333
362
|
* @returns an absolute resolved path (e.g., `'/docs/usage/grammar'`)
|
|
334
363
|
*/
|
|
335
364
|
export declare const mdz_resolve_relative_path: (reference: string, base: string) => string;
|
|
365
|
+
/**
|
|
366
|
+
* How a `Link` node's `reference` should render, shared by all three renderers
|
|
367
|
+
* (`MdzNodeView`, `MdzStreamNodeView`, `mdz_to_svelte`) so the safety gate and
|
|
368
|
+
* the resolve-vs-raw classification can't drift between them.
|
|
369
|
+
* @nodocs
|
|
370
|
+
*/
|
|
371
|
+
export type MdzLinkRender =
|
|
372
|
+
/** Unsafe protocol — render children only, no `<a>`. */
|
|
373
|
+
{
|
|
374
|
+
kind: 'unsafe';
|
|
375
|
+
}
|
|
376
|
+
/** Route/relative path — wrap in `resolve()` (needs `$app/paths`). */
|
|
377
|
+
| {
|
|
378
|
+
kind: 'resolve';
|
|
379
|
+
href: string;
|
|
380
|
+
}
|
|
381
|
+
/** Internal fragment/query/relative/bare ref — raw `href`, no `resolve()`. */
|
|
382
|
+
| {
|
|
383
|
+
kind: 'internal';
|
|
384
|
+
href: string;
|
|
385
|
+
}
|
|
386
|
+
/** External link — raw `href` plus `target="_blank" rel="noopener"`. */
|
|
387
|
+
| {
|
|
388
|
+
kind: 'external';
|
|
389
|
+
href: string;
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Classify a `Link` reference into how it should render. Pure — no rendering,
|
|
393
|
+
* no context; `base` is the resolved base path (or `undefined`).
|
|
394
|
+
* @nodocs
|
|
395
|
+
*/
|
|
396
|
+
export declare const mdz_classify_link: (reference: string, link_type: "internal" | "external" | undefined, base: string | undefined) => MdzLinkRender;
|
|
336
397
|
/**
|
|
337
398
|
* Push a node into a children array, coalescing with the previous Text node.
|
|
338
399
|
* Mutates `prev.content` and `prev.end` when both are Text, avoiding array growth
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mdz_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACX,OAAO,EAEP,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,MAAM,UAAU,CAAC;AAGlB,cAAc;AACd,eAAO,MAAM,QAAQ,KAAK,CAAC;AAC3B,cAAc;AACd,eAAO,MAAM,QAAQ,KAAK,CAAC;AAC3B,cAAc;AACd,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,cAAc;AACd,eAAO,MAAM,KAAK,MAAM,CAAC;AACzB,cAAc;AACd,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,cAAc;AACd,eAAO,MAAM,MAAM,KAAK,CAAC;AACzB,cAAc;AACd,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,cAAc;AACd,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,cAAc;AACd,eAAO,MAAM,GAAG,IAAI,CAAC;AACrB,cAAc;AACd,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,cAAc;AACd,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,cAAc;AACd,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,cAAc;AACd,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,cAAc;AACd,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,cAAc;AACd,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,cAAc;AACd,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,cAAc;AACd,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,cAAc;AACd,eAAO,MAAM,KAAK,KAAK,C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