@fuzdev/mdz 0.9.0 → 0.10.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.
Files changed (64) hide show
  1. package/dist/Mdz.svelte +37 -1
  2. package/dist/Mdz.svelte.d.ts +35 -0
  3. package/dist/Mdz.svelte.d.ts.map +1 -1
  4. package/dist/MdzNodeView.svelte +143 -27
  5. package/dist/MdzNodeView.svelte.d.ts +13 -1
  6. package/dist/MdzNodeView.svelte.d.ts.map +1 -1
  7. package/dist/MdzPrecompiled.svelte.d.ts.map +1 -1
  8. package/dist/MdzRoot.svelte.d.ts.map +1 -1
  9. package/dist/MdzStream.svelte.d.ts.map +1 -1
  10. package/dist/MdzStreamNodeView.svelte.d.ts.map +1 -1
  11. package/dist/context_helpers.d.ts.map +1 -1
  12. package/dist/mdz.d.ts +4 -1
  13. package/dist/mdz.d.ts.map +1 -1
  14. package/dist/mdz.js +4 -1
  15. package/dist/mdz_contexts.d.ts +14 -2
  16. package/dist/mdz_contexts.d.ts.map +1 -1
  17. package/dist/mdz_debug_work.d.ts.map +1 -1
  18. package/dist/mdz_helpers.d.ts +57 -7
  19. package/dist/mdz_helpers.d.ts.map +1 -1
  20. package/dist/mdz_helpers.js +113 -50
  21. package/dist/mdz_lexer.d.ts.map +1 -1
  22. package/dist/mdz_lexer.js +21 -17
  23. package/dist/mdz_opcodes.d.ts.map +1 -1
  24. package/dist/mdz_opcodes_to_nodes.d.ts.map +1 -1
  25. package/dist/mdz_stream_parser.d.ts +16 -3
  26. package/dist/mdz_stream_parser.d.ts.map +1 -1
  27. package/dist/mdz_stream_parser.js +16 -3
  28. package/dist/mdz_stream_parser_block.d.ts +2 -2
  29. package/dist/mdz_stream_parser_block.d.ts.map +1 -1
  30. package/dist/mdz_stream_parser_block.js +2 -2
  31. package/dist/mdz_stream_parser_inline.d.ts.map +1 -1
  32. package/dist/mdz_stream_parser_inline.js +4 -4
  33. package/dist/mdz_stream_parser_link.d.ts.map +1 -1
  34. package/dist/mdz_stream_parser_list.d.ts.map +1 -1
  35. package/dist/mdz_stream_parser_state.d.ts +32 -12
  36. package/dist/mdz_stream_parser_state.d.ts.map +1 -1
  37. package/dist/mdz_stream_parser_state.js +21 -14
  38. package/dist/mdz_stream_parser_table.d.ts.map +1 -1
  39. package/dist/mdz_stream_parser_text.d.ts.map +1 -1
  40. package/dist/mdz_stream_parser_text.js +7 -4
  41. package/dist/mdz_stream_parser_url.d.ts +3 -2
  42. package/dist/mdz_stream_parser_url.d.ts.map +1 -1
  43. package/dist/mdz_stream_parser_url.js +114 -42
  44. package/dist/mdz_stream_state.svelte.d.ts.map +1 -1
  45. package/dist/mdz_to_svelte.d.ts.map +1 -1
  46. package/dist/mdz_token_parser.d.ts.map +1 -1
  47. package/dist/svelte_preprocess_mdz.d.ts.map +1 -1
  48. package/dist/svelte_preprocess_mdz.js +8 -0
  49. package/dist/tsdoc_mdz.d.ts +8 -4
  50. package/dist/tsdoc_mdz.d.ts.map +1 -1
  51. package/dist/tsdoc_mdz.js +14 -4
  52. package/package.json +5 -5
  53. package/src/lib/mdz.ts +4 -1
  54. package/src/lib/mdz_contexts.ts +20 -2
  55. package/src/lib/mdz_helpers.ts +117 -49
  56. package/src/lib/mdz_lexer.ts +31 -14
  57. package/src/lib/mdz_stream_parser.ts +16 -3
  58. package/src/lib/mdz_stream_parser_block.ts +2 -2
  59. package/src/lib/mdz_stream_parser_inline.ts +4 -4
  60. package/src/lib/mdz_stream_parser_state.ts +34 -13
  61. package/src/lib/mdz_stream_parser_text.ts +13 -6
  62. package/src/lib/mdz_stream_parser_url.ts +130 -49
  63. package/src/lib/svelte_preprocess_mdz.ts +8 -0
  64. package/src/lib/tsdoc_mdz.ts +15 -4
package/dist/Mdz.svelte CHANGED
@@ -17,6 +17,7 @@
17
17
  inline = false,
18
18
  whitespace,
19
19
  base,
20
+ source_offsets = false,
20
21
  ...rest
21
22
  }: (SvelteHTMLElements['div'] | SvelteHTMLElements['span']) & {
22
23
  /**
@@ -31,6 +32,41 @@
31
32
  */
32
33
  whitespace?: MdzWhitespace;
33
34
  base?: string;
35
+ /**
36
+ * Puts each node's source offsets on the elements rendered for it, as
37
+ * `data-mdz-start` and `data-mdz-end`, so a consumer can map rendered
38
+ * output back to the source: scroll sync with an editor, marking the
39
+ * block under its caret, click-to-source, or matching a rendered link
40
+ * to its `MdzNode` by offset rather than document order.
41
+ *
42
+ * The values are the node's `start` and `end` (exclusive) — string
43
+ * indices into `content`, or into the string `nodes` was parsed from.
44
+ * Every element mdz renders for a node carries them: blocks (`p`,
45
+ * headings, `ul`/`ol`, `li`, `blockquote`, `table`, `tr`, `th`/`td`,
46
+ * `hr`, a codeblock's `pre`), inline formatting (`strong`, `em`, `s`,
47
+ * `code`), every rendered link's `a` (markdown links and auto-linked
48
+ * URLs and paths alike), and registered HTML elements. Nothing carries
49
+ * them where mdz renders no element for a node: text, a link whose
50
+ * reference fails the safety check (it renders as its text), padding
51
+ * cells, placeholders for unregistered tags, and the paragraph `inline`
52
+ * unwraps. Elements nest, so an
53
+ * element can share its `start` with a descendant's (a paragraph and
54
+ * its first link) — match by element and both offsets.
55
+ *
56
+ * Injected `code` and `codeblock` components receive the offsets as
57
+ * props (`MdzSourceOffsetProps`), which one that spreads rest props
58
+ * onto its root element carries — on whatever root it renders, so an
59
+ * injected `code` that renders a link puts a `Code` node's offsets on an
60
+ * `a`; registered content components don't
61
+ * (their props are what they register), though the content inside
62
+ * them carries its own. The switch isn't inherited — a nested `Mdz`
63
+ * has its own. Precompiled static content (`svelte_preprocess_mdz`)
64
+ * renders at runtime when this is set, and `MdzStream` has no
65
+ * offsets to offer. Off, the output is unchanged.
66
+ *
67
+ * @default false
68
+ */
69
+ source_offsets?: boolean;
34
70
  } & // pass `content` to parse at render, or `nodes` to render a pre-parsed
35
71
  // tree (e.g. one parsed once and rendered in several places) and skip
36
72
  // `mdz_parse` entirely
@@ -50,5 +86,5 @@
50
86
  </script>
51
87
 
52
88
  <svelte:element this={inline ? 'span' : 'div'} {...rest} style:white-space={whitespace}>
53
- <MdzNodeView {nodes} />
89
+ <MdzNodeView {nodes} {source_offsets} />
54
90
  </svelte:element>
@@ -14,6 +14,41 @@ type $$ComponentProps = (SvelteHTMLElements['div'] | SvelteHTMLElements['span'])
14
14
  */
15
15
  whitespace?: MdzWhitespace;
16
16
  base?: string;
17
+ /**
18
+ * Puts each node's source offsets on the elements rendered for it, as
19
+ * `data-mdz-start` and `data-mdz-end`, so a consumer can map rendered
20
+ * output back to the source: scroll sync with an editor, marking the
21
+ * block under its caret, click-to-source, or matching a rendered link
22
+ * to its `MdzNode` by offset rather than document order.
23
+ *
24
+ * The values are the node's `start` and `end` (exclusive) — string
25
+ * indices into `content`, or into the string `nodes` was parsed from.
26
+ * Every element mdz renders for a node carries them: blocks (`p`,
27
+ * headings, `ul`/`ol`, `li`, `blockquote`, `table`, `tr`, `th`/`td`,
28
+ * `hr`, a codeblock's `pre`), inline formatting (`strong`, `em`, `s`,
29
+ * `code`), every rendered link's `a` (markdown links and auto-linked
30
+ * URLs and paths alike), and registered HTML elements. Nothing carries
31
+ * them where mdz renders no element for a node: text, a link whose
32
+ * reference fails the safety check (it renders as its text), padding
33
+ * cells, placeholders for unregistered tags, and the paragraph `inline`
34
+ * unwraps. Elements nest, so an
35
+ * element can share its `start` with a descendant's (a paragraph and
36
+ * its first link) — match by element and both offsets.
37
+ *
38
+ * Injected `code` and `codeblock` components receive the offsets as
39
+ * props (`MdzSourceOffsetProps`), which one that spreads rest props
40
+ * onto its root element carries — on whatever root it renders, so an
41
+ * injected `code` that renders a link puts a `Code` node's offsets on an
42
+ * `a`; registered content components don't
43
+ * (their props are what they register), though the content inside
44
+ * them carries its own. The switch isn't inherited — a nested `Mdz`
45
+ * has its own. Precompiled static content (`svelte_preprocess_mdz`)
46
+ * renders at runtime when this is set, and `MdzStream` has no
47
+ * offsets to offer. Off, the output is unchanged.
48
+ *
49
+ * @default false
50
+ */
51
+ source_offsets?: boolean;
17
52
  } & // pass `content` to parse at render, or `nodes` to render a pre-parsed
18
53
  ({
19
54
  content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Mdz.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/Mdz.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAGL,KAAK,aAAa,EAClB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,uEAAuE;AAG1E,CACC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CACvF,CAAC;AAoCJ,QAAA,MAAM,GAAG,sDAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Mdz.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Mdz.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAGL,KAAK,aAAa,EAClB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,uEAAuE;AAG1E,CACC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CACvF,CAAC;AAqCJ,QAAA,MAAM,GAAG,sDAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
@@ -22,11 +22,22 @@
22
22
 
23
23
  const {
24
24
  node,
25
- nodes
26
- }:
27
- // exactly one of `node`/`nodes` — the array form renders a whole tree
25
+ nodes,
26
+ source_offsets = false
27
+ }: {
28
+ /**
29
+ * Puts each node's source offsets on the elements rendered for it, as
30
+ * `data-mdz-start` and `data-mdz-end` — see `Mdz`'s `source_offsets` for
31
+ * the contract. A prop rather than a context because offsets index one
32
+ * source string, so a nested `Mdz` (inside a registered component, say)
33
+ * must not inherit the switch.
34
+ *
35
+ * @default false
36
+ */
37
+ source_offsets?: boolean;
38
+ } & // exactly one of `node`/`nodes` — the array form renders a whole tree
28
39
  // through this single component instance (used by `Mdz`)
29
- { node: MdzNode; nodes?: undefined } | { node?: undefined; nodes: Array<MdzNode> } = $props();
40
+ ({ node: MdzNode; nodes?: undefined } | { node?: undefined; nodes: Array<MdzNode> }) = $props();
30
41
 
31
42
  const get_components = mdz_components_context.get_maybe();
32
43
  const get_elements = mdz_elements_context.get_maybe();
@@ -65,9 +76,19 @@ tree instead of per node. -->
65
76
  )}
66
77
  {#if mdz_is_void_element(node.name)}
67
78
  <!-- void elements cannot have content — any parsed children are dropped -->
68
- <svelte:element this={node.name} {...attrs} />
79
+ <svelte:element
80
+ this={node.name}
81
+ {...attrs}
82
+ data-mdz-start={source_offsets ? node.start : undefined}
83
+ data-mdz-end={source_offsets ? node.end : undefined}
84
+ />
69
85
  {:else}
70
- <svelte:element this={node.name} {...attrs}>
86
+ <svelte:element
87
+ this={node.name}
88
+ {...attrs}
89
+ data-mdz-start={source_offsets ? node.start : undefined}
90
+ data-mdz-end={source_offsets ? node.end : undefined}
91
+ >
71
92
  {#if node.children.length > 0}
72
93
  {@render render_children(node.children)}
73
94
  {/if}
@@ -101,56 +122,128 @@ tree instead of per node. -->
101
122
  {:else if node.type === 'Code'}
102
123
  {@const Code = get_code?.()}
103
124
  {#if Code}
104
- <Code reference={node.content} />
125
+ <Code
126
+ reference={node.content}
127
+ data-mdz-start={source_offsets ? node.start : undefined}
128
+ data-mdz-end={source_offsets ? node.end : undefined}
129
+ />
105
130
  {:else}
106
- <code>{node.content}</code>
131
+ <code
132
+ data-mdz-start={source_offsets ? node.start : undefined}
133
+ data-mdz-end={source_offsets ? node.end : undefined}
134
+ >
135
+ {node.content}
136
+ </code>
107
137
  {/if}
108
138
  {:else if node.type === 'Bold'}
109
- <strong>{@render render_children(node.children)}</strong>
139
+ <strong
140
+ data-mdz-start={source_offsets ? node.start : undefined}
141
+ data-mdz-end={source_offsets ? node.end : undefined}
142
+ >
143
+ {@render render_children(node.children)}
144
+ </strong>
110
145
  {:else if node.type === 'Italic'}
111
- <em>{@render render_children(node.children)}</em>
146
+ <em
147
+ data-mdz-start={source_offsets ? node.start : undefined}
148
+ data-mdz-end={source_offsets ? node.end : undefined}
149
+ >
150
+ {@render render_children(node.children)}
151
+ </em>
112
152
  {:else if node.type === 'Strikethrough'}
113
- <s>{@render render_children(node.children)}</s>
153
+ <s
154
+ data-mdz-start={source_offsets ? node.start : undefined}
155
+ data-mdz-end={source_offsets ? node.end : undefined}
156
+ >
157
+ {@render render_children(node.children)}
158
+ </s>
114
159
  {:else if node.type === 'Link'}
115
160
  {@const link = mdz_classify_link(node.reference, node.link_type, get_mdz_base?.())}
116
161
  {#if link.kind === 'unsafe'}
117
162
  {@render render_children(node.children)}
118
163
  {:else if link.kind === 'resolve'}
119
- <a href={resolve_pathname(link.path)}>{@render render_children(node.children)}</a>
164
+ <a
165
+ href={resolve_pathname(link.path)}
166
+ data-mdz-start={source_offsets ? node.start : undefined}
167
+ data-mdz-end={source_offsets ? node.end : undefined}
168
+ >
169
+ {@render render_children(node.children)}
170
+ </a>
120
171
  {:else if link.kind === 'external'}
121
172
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
122
- <a href={link.href} target="_blank" rel="noopener">
173
+ <a
174
+ href={link.href}
175
+ target="_blank"
176
+ rel="noopener"
177
+ data-mdz-start={source_offsets ? node.start : undefined}
178
+ data-mdz-end={source_offsets ? node.end : undefined}
179
+ >
123
180
  {@render render_children(node.children)}
124
181
  </a>
125
182
  {:else}
126
183
  <!-- fragment/query/relative/bare references aren't under the base, so they skip resolve() -->
127
184
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
128
- <a href={link.href}>{@render render_children(node.children)}</a>
185
+ <a
186
+ href={link.href}
187
+ data-mdz-start={source_offsets ? node.start : undefined}
188
+ data-mdz-end={source_offsets ? node.end : undefined}
189
+ >
190
+ {@render render_children(node.children)}
191
+ </a>
129
192
  {/if}
130
193
  {:else if node.type === 'Paragraph'}
131
- <p>{@render render_children(node.children)}</p>
194
+ <p
195
+ data-mdz-start={source_offsets ? node.start : undefined}
196
+ data-mdz-end={source_offsets ? node.end : undefined}
197
+ >
198
+ {@render render_children(node.children)}
199
+ </p>
132
200
  {:else if node.type === 'List'}
133
201
  {#if node.ordered}
134
- <ol start={node.start_number === 1 ? undefined : node.start_number}>
202
+ <ol
203
+ start={node.start_number === 1 ? undefined : node.start_number}
204
+ data-mdz-start={source_offsets ? node.start : undefined}
205
+ data-mdz-end={source_offsets ? node.end : undefined}
206
+ >
135
207
  {@render render_children(node.children)}
136
208
  </ol>
137
209
  {:else}
138
- <ul>{@render render_children(node.children)}</ul>
210
+ <ul
211
+ data-mdz-start={source_offsets ? node.start : undefined}
212
+ data-mdz-end={source_offsets ? node.end : undefined}
213
+ >
214
+ {@render render_children(node.children)}
215
+ </ul>
139
216
  {/if}
140
217
  {:else if node.type === 'ListItem'}
141
- <li>{@render render_children(node.children)}</li>
218
+ <li
219
+ data-mdz-start={source_offsets ? node.start : undefined}
220
+ data-mdz-end={source_offsets ? node.end : undefined}
221
+ >
222
+ {@render render_children(node.children)}
223
+ </li>
142
224
  {:else if node.type === 'Blockquote'}
143
- <blockquote>{@render render_children(node.children)}</blockquote>
225
+ <blockquote
226
+ data-mdz-start={source_offsets ? node.start : undefined}
227
+ data-mdz-end={source_offsets ? node.end : undefined}
228
+ >
229
+ {@render render_children(node.children)}
230
+ </blockquote>
144
231
  {:else if node.type === 'Table'}
145
232
  <!-- by grammar the header row is always first (and the only one) — read
146
233
  it by index and skip it per-row in the body, rather than filtering
147
234
  twice (matches the streaming view, where a filter would go O(n²)
148
235
  across a streamed table) -->
149
236
  {@const header_row = node.children[0]?.header ? node.children[0] : undefined}
150
- <table>
237
+ <table
238
+ data-mdz-start={source_offsets ? node.start : undefined}
239
+ data-mdz-end={source_offsets ? node.end : undefined}
240
+ >
151
241
  {#if header_row}
152
242
  <thead>
153
- <tr>
243
+ <tr
244
+ data-mdz-start={source_offsets ? header_row.start : undefined}
245
+ data-mdz-end={source_offsets ? header_row.end : undefined}
246
+ >
154
247
  {@render render_cells(header_row, 'th', node.align)}
155
248
  </tr>
156
249
  </thead>
@@ -159,7 +252,10 @@ tree instead of per node. -->
159
252
  <tbody>
160
253
  {#each node.children as row, i (i)}
161
254
  {#if !row.header}
162
- <tr>
255
+ <tr
256
+ data-mdz-start={source_offsets ? row.start : undefined}
257
+ data-mdz-end={source_offsets ? row.end : undefined}
258
+ >
163
259
  {@render render_cells(row, 'td', node.align)}
164
260
  </tr>
165
261
  {/if}
@@ -168,17 +264,32 @@ tree instead of per node. -->
168
264
  {/if}
169
265
  </table>
170
266
  {:else if node.type === 'Hr'}
171
- <hr />
267
+ <hr
268
+ data-mdz-start={source_offsets ? node.start : undefined}
269
+ data-mdz-end={source_offsets ? node.end : undefined}
270
+ />
172
271
  {:else if node.type === 'Heading'}
173
- <svelte:element this={`h${node.level}`} id={node.id || undefined}>
272
+ <svelte:element
273
+ this={`h${node.level}`}
274
+ id={node.id || undefined}
275
+ data-mdz-start={source_offsets ? node.start : undefined}
276
+ data-mdz-end={source_offsets ? node.end : undefined}
277
+ >
174
278
  {@render render_children(node.children)}
175
279
  </svelte:element>
176
280
  {:else if node.type === 'Codeblock'}
177
281
  {@const Codeblock = get_codeblock?.()}
178
282
  {#if Codeblock}
179
- <Codeblock lang={node.lang} content={node.content} />
283
+ <Codeblock
284
+ lang={node.lang}
285
+ content={node.content}
286
+ data-mdz-start={source_offsets ? node.start : undefined}
287
+ data-mdz-end={source_offsets ? node.end : undefined}
288
+ />
180
289
  {:else}
181
- <pre><code>{node.content}</code></pre>
290
+ <pre
291
+ data-mdz-start={source_offsets ? node.start : undefined}
292
+ data-mdz-end={source_offsets ? node.end : undefined}><code>{node.content}</code></pre>
182
293
  {/if}
183
294
  {/if}
184
295
  {/snippet}
@@ -197,7 +308,12 @@ tree instead of per node. -->
197
308
  <!-- normalize to the column count: pad short rows, ignore extra cells -->
198
309
  {#each align as a, i (i)}
199
310
  {@const cell = row.children[i]}
200
- <svelte:element this={tag} style={a ? `text-align:${a}` : undefined}>
311
+ <svelte:element
312
+ this={tag}
313
+ style={a ? `text-align:${a}` : undefined}
314
+ data-mdz-start={source_offsets && cell ? cell.start : undefined}
315
+ data-mdz-end={source_offsets && cell ? cell.end : undefined}
316
+ >
201
317
  {#if cell}{@render render_children(cell.children)}{/if}
202
318
  </svelte:element>
203
319
  {/each}
@@ -1,11 +1,23 @@
1
1
  import type { MdzNode } from './mdz.js';
2
2
  type $$ComponentProps = {
3
+ /**
4
+ * Puts each node's source offsets on the elements rendered for it, as
5
+ * `data-mdz-start` and `data-mdz-end` — see `Mdz`'s `source_offsets` for
6
+ * the contract. A prop rather than a context because offsets index one
7
+ * source string, so a nested `Mdz` (inside a registered component, say)
8
+ * must not inherit the switch.
9
+ *
10
+ * @default false
11
+ */
12
+ source_offsets?: boolean;
13
+ } & // exactly one of `node`/`nodes` — the array form renders a whole tree
14
+ ({
3
15
  node: MdzNode;
4
16
  nodes?: undefined;
5
17
  } | {
6
18
  node?: undefined;
7
19
  nodes: Array<MdzNode>;
8
- };
20
+ });
9
21
  declare const MdzNodeView: import("svelte").Component<$$ComponentProps, {}, "">;
10
22
  type MdzNodeView = ReturnType<typeof MdzNodeView>;
11
23
  export default MdzNodeView;
@@ -1 +1 @@
1
- {"version":3,"file":"MdzNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzNodeView.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAgB,OAAO,EAAkC,MAAM,UAAU,CAAC;AAkBrF,KAAK,gBAAgB,GAGpB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAkMrF,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MdzNodeView.svelte.d.ts","sourceRoot":"","sources":["../src/lib/MdzNodeView.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAgB,OAAO,EAAkC,MAAM,UAAU,CAAC;AAkBrF,KAAK,gBAAgB,GAAI;IACxB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,sEAAsE;AAEzE,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,CAAC;AAuNvF,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MdzPrecompiled.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzPrecompiled.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtD,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA4BH,QAAA,MAAM,cAAc,sDAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"MdzPrecompiled.svelte.d.ts","sourceRoot":"","sources":["../src/lib/MdzPrecompiled.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtD,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA4BH,QAAA,MAAM,cAAc,sDAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MdzRoot.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzRoot.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAOL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,gBAAgB,GAAI;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;CAClB,CAAC;AA0BH,QAAA,MAAM,OAAO,sDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"MdzRoot.svelte.d.ts","sourceRoot":"","sources":["../src/lib/MdzR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,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"MdzStream.svelte.d.ts","sourceRoot":"","sources":["../src/lib/MdzStream.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAGL,KAAK,aAAa,EAClB,MAAM,mBAAmB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAElE,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA0BH,QAAA,MAAM,SAAS,sDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MdzStreamNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzStreamNodeView.svelte"],"names":[],"mappings":"AAsBA,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;AAkNjG,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"MdzStreamNodeView.svelte.d.ts","sourceRoot":"","sources":["../src/lib/MdzStreamNodeView.svelte.ts"],"names":[],"mappings":"AAsBA,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;AAkNjG,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/context_helpers.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG;IACrD,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AACF,wBAAgB,cAAc,CAAC,CAAC,KAAK;IACpC,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"context_helpers.d.ts","sourceRoot":"","sources":["../src/lib/context_helpers.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG;IACrD,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AACF,wBAAgB,cAAc,CAAC,CAAC,KAAK;IACpC,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC"}
package/dist/mdz.d.ts CHANGED
@@ -14,7 +14,10 @@
14
14
  *
15
15
  * The dialect supports:
16
16
  * - inline formatting: `code`, **bold**, _italic_, ~~strikethrough~~
17
- * - auto-detected links: external URLs (`https://...`) and internal paths (`/path`)
17
+ * - auto-detected links: external URLs (`https://...`) at the start of input or
18
+ * after any non-word character, and internal paths (`/path`, `./path`, `../path`)
19
+ * at the start of input, after whitespace, or after an opening `(` not preceded
20
+ * by an ASCII letter, digit, or `]` (such a path ends at its matching `)`)
18
21
  * - markdown links: `[text](url)` with custom display text
19
22
  * - inline code in backticks (creates `Code` nodes; auto-linking to identifiers/modules
20
23
  * is handled by the rendering layer via `MdzNodeView.svelte`)
package/dist/mdz.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAOH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,KAAK,CAAC,OAAO,CACI,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,kBAAkB;;IAI9B,gFAAgF;gBACpE,IAAI,EAAE,MAAM;IAIxB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,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;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACpD,IAAI,EAAE,WAAW,CAAC;IAClB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACzB"}
package/dist/mdz.js CHANGED
@@ -14,7 +14,10 @@
14
14
  *
15
15
  * The dialect supports:
16
16
  * - inline formatting: `code`, **bold**, _italic_, ~~strikethrough~~
17
- * - auto-detected links: external URLs (`https://...`) and internal paths (`/path`)
17
+ * - auto-detected links: external URLs (`https://...`) at the start of input or
18
+ * after any non-word character, and internal paths (`/path`, `./path`, `../path`)
19
+ * at the start of input, after whitespace, or after an opening `(` not preceded
20
+ * by an ASCII letter, digit, or `]` (such a path ends at its matching `)`)
18
21
  * - markdown links: `[text](url)` with custom display text
19
22
  * - inline code in backticks (creates `Code` nodes; auto-linking to identifiers/modules
20
23
  * is handled by the rendering layer via `MdzNodeView.svelte`)
@@ -81,6 +81,18 @@ export declare const mdz_base_context: {
81
81
  get_maybe: () => (() => string | undefined) | undefined;
82
82
  set: (value: () => string | undefined) => () => string | undefined;
83
83
  };
84
+ /**
85
+ * The source offsets an injected `code` or `codeblock` component receives
86
+ * when `Mdz`'s `source_offsets` is on: its node's `start` and `end` in the
87
+ * parsed source. Named as the attributes, so a component that spreads rest
88
+ * props onto its root element (like `fuz_ui`'s `DocsLink` and `fuz_code`'s
89
+ * `Code`) carries them with no changes; any other can read them as props.
90
+ * Absent (`undefined`) when `source_offsets` is off.
91
+ */
92
+ export type MdzSourceOffsetProps = {
93
+ 'data-mdz-start'?: number;
94
+ 'data-mdz-end'?: number;
95
+ };
84
96
  /**
85
97
  * Component that renders an inline `` `code` `` span. Receives the raw span
86
98
  * content as `reference` — the prop name matches `fuz_ui`'s `DocsLink`, so it
@@ -88,7 +100,7 @@ export declare const mdz_base_context: {
88
100
  */
89
101
  export type MdzCodeComponent = Component<{
90
102
  reference: string;
91
- }>;
103
+ } & MdzSourceOffsetProps>;
92
104
  /**
93
105
  * Context for overriding how inline `` `code` `` spans render, via a getter
94
106
  * function. When not set, inline code renders as a plain `<code>` element.
@@ -106,7 +118,7 @@ export declare const mdz_code_context: {
106
118
  export type MdzCodeblockComponent = Component<{
107
119
  lang: string | null;
108
120
  content: string;
109
- }>;
121
+ } & MdzSourceOffsetProps>;
110
122
  /**
111
123
  * Context for overriding how fenced code blocks render, via a getter function.
112
124
  * When not set, code blocks render as a plain `<pre><code>` element.
@@ -1 +1 @@
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;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,wEAAwE;IACxE,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,CAAC;AAElF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,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AAS,gBAAgB,CAAC,CAAC,CAAC,EAC5B,UAAU,MAAM,CAAC,GAAG,SAAS,KAC3B,IAGF,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"mdz_debug_work.d.ts","sourceRoot":"","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"}
@@ -287,6 +287,16 @@ export declare const is_tag_name_char: (char_code: number) => boolean;
287
287
  * @nodocs
288
288
  */
289
289
  export declare const is_word_char: (char_code: number) => boolean;
290
+ /**
291
+ * Whether a char next to an italic `_` blocks it from opening (the char
292
+ * before) or closing (the char after): a word char, or `_` itself — italic is
293
+ * self-opaque, so runs like `__init__` never pair. The one italic boundary
294
+ * predicate, shared by the lexer, the streaming parser, and the streaming
295
+ * auto-link span resolution.
296
+ *
297
+ * @nodocs
298
+ */
299
+ export declare const is_italic_boundary_blocker: (char_code: number) => boolean;
290
300
  /** @nodocs */
291
301
  export declare const is_valid_path_char: (char_code: number) => boolean;
292
302
  /** Always ends a text run: `` ` `` `*` `_` `~` `[` `]` `<`. @nodocs */
@@ -295,16 +305,19 @@ export declare const TEXT_CLASS_STOP = 1;
295
305
  export declare const TEXT_CLASS_NEWLINE = 2;
296
306
  /** `h`/`H` — potential URL scheme start, needs the prefix probe. @nodocs */
297
307
  export declare const TEXT_CLASS_URL = 4;
298
- /** `/` and `.` — potential path start, needs the boundary probe. @nodocs */
308
+ /** `/` and `.` — potential path start, needs the `is_path_boundary` probe. @nodocs */
299
309
  export declare const TEXT_CLASS_PATH = 8;
300
310
  /** `\` — a literal-pipe escape candidate inside table cells only. @nodocs */
301
311
  export declare const TEXT_CLASS_BACKSLASH = 16;
302
312
  /** @nodocs */
303
313
  export declare const TEXT_SCAN_CLASS: Uint8Array;
304
314
  /**
305
- * Trim trailing punctuation from URL/path per RFC 3986 and GFM rules.
306
- * - Trims simple trailing: .,;:!?]
307
- * - Balanced logic for () only (valid in path components)
315
+ * Trim the trailing characters a URL/path scan consumed that read as
316
+ * surrounding prose rather than the reference, per GFM's autolink
317
+ * conventions, repeated until nothing more trims:
318
+ * - trailing punctuation `.,;:!?]`
319
+ * - an unbalanced trailing `)` (parens are valid in path components, so a
320
+ * balanced `(…)` stays)
308
321
  *
309
322
  * Note on `]`: the mdz parsers (`mdz.ts`, `mdz_stream_parser_url.ts`,
310
323
  * `mdz_lexer.ts`) scan URL/path chars through `is_valid_path_char`, which
@@ -312,12 +325,48 @@ export declare const TEXT_SCAN_CLASS: Uint8Array;
312
325
  * The `]` branch here is for external callers using this helper directly on
313
326
  * arbitrary URL-ish input as part of the published `@fuzdev/mdz` surface.
314
327
  *
315
- * Optimized to avoid O(n²) string slicing - tracks end index and slices once at the end.
328
+ * Tracks the end index and slices once, avoiding O(n²) string slicing.
316
329
  */
317
330
  export declare const mdz_trim_url_punctuation: (url: string) => string;
331
+ /**
332
+ * End of the URI-char run starting at `start` — where an auto-link scan
333
+ * stops, before any trailing trim. A path opened by `(` (`paren_opened`,
334
+ * see `is_path_boundary`) also ends before the `)` that matches that opener:
335
+ * a `(` inside the path raises the depth, so `(./Foo_(bar))` scans
336
+ * `./Foo_(bar)`.
337
+ *
338
+ * @nodocs
339
+ */
340
+ export declare const scan_uri_chars_end: (text: string, start: number, paren_opened: boolean) => number;
341
+ /**
342
+ * Whether an internal path reference is only its prefix (`/`, `./`, `../`)
343
+ * with nothing after it — such a reference never links, since a path is its
344
+ * prefix plus at least one URI char.
345
+ *
346
+ * @nodocs
347
+ */
348
+ export declare const is_bare_path_prefix: (reference: string) => boolean;
349
+ /**
350
+ * Whether an auto-detected path (`/…`, `./…`, `../…`) may start after the
351
+ * given characters: at the start of input, after a space, tab, or newline, or
352
+ * after an opening `(` that is itself neither glued to a word char nor the
353
+ * `](` of markdown link syntax. The paren case covers parenthesized
354
+ * references like `(./foo.md)` and `(see /docs)` — a path opened by `(` ends
355
+ * at its matching `)` (`scan_uri_chars_end`), and an unbalanced `)` after a
356
+ * whitespace-opened path is trimmed by `mdz_trim_url_punctuation` — while
357
+ * call-shaped `foo(./bar)` and a failed link's `[text](./foo bar)` stay
358
+ * literal. Every other preceding character (word chars, `[`, `{`, quotes,
359
+ * `*`, `_`, `~`, `/`, `.`) keeps a following path literal.
360
+ *
361
+ * @param prev - the char code directly before the path, or `-1` at the start of input
362
+ * @param before_prev - the char code before `prev`, or `-1` at the start of input
363
+ * @nodocs
364
+ */
365
+ export declare const is_path_boundary: (prev: number, before_prev: number) => boolean;
318
366
  /**
319
367
  * Check if position in text is the start of an absolute path (starts with `/`).
320
- * Must be preceded by whitespace or be at the start of the string.
368
+ * Must sit at a path boundary (see `is_path_boundary`): start of input,
369
+ * whitespace, or a `(` not glued to a word or a `]`.
321
370
  * Rejects `//` (comments/protocol-relative) and slash followed by whitespace.
322
371
  *
323
372
  * @nodocs
@@ -325,7 +374,8 @@ export declare const mdz_trim_url_punctuation: (url: string) => string;
325
374
  export declare const is_at_absolute_path: (text: string, index: number) => boolean;
326
375
  /**
327
376
  * Check if position in text is the start of a relative path (`./` or `../`).
328
- * Must be preceded by whitespace or be at the start of the string.
377
+ * Must sit at a path boundary (see `is_path_boundary`): start of input,
378
+ * whitespace, or a `(` not glued to a word or a `]`.
329
379
  * Rejects prefix followed by whitespace, slash, or end of string.
330
380
  *
331
381
  * @nodocs