@tooee/renderers 0.2.3 → 0.3.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 (116) hide show
  1. package/dist/code-blocks.d.ts +6 -6
  2. package/dist/code-blocks.d.ts.map +1 -1
  3. package/dist/code-blocks.js +52 -42
  4. package/dist/code-blocks.js.map +1 -1
  5. package/dist/{CodeView.d.ts → code-view.d.ts} +3 -3
  6. package/dist/code-view.d.ts.map +1 -0
  7. package/dist/{CodeView.js → code-view.js} +5 -5
  8. package/dist/code-view.js.map +1 -0
  9. package/dist/{CommandPalette.d.ts → command-palette.d.ts} +2 -2
  10. package/dist/command-palette.d.ts.map +1 -0
  11. package/dist/{CommandPalette.js → command-palette.js} +27 -24
  12. package/dist/command-palette.js.map +1 -0
  13. package/dist/{ContextMenu.d.ts → context-menu.d.ts} +2 -2
  14. package/dist/context-menu.d.ts.map +1 -0
  15. package/dist/{ContextMenu.js → context-menu.js} +24 -14
  16. package/dist/context-menu.js.map +1 -0
  17. package/dist/{DecorationLayer.d.ts → decoration-layer.d.ts} +2 -2
  18. package/dist/decoration-layer.d.ts.map +1 -0
  19. package/dist/decoration-layer.js +2 -0
  20. package/dist/decoration-layer.js.map +1 -0
  21. package/dist/{DocumentBindings.d.ts → document-bindings.d.ts} +4 -4
  22. package/dist/document-bindings.d.ts.map +1 -0
  23. package/dist/document-bindings.js +2 -0
  24. package/dist/document-bindings.js.map +1 -0
  25. package/dist/index.d.ts +16 -15
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +9 -9
  28. package/dist/index.js.map +1 -1
  29. package/dist/markdown-blocks.d.ts +9 -13
  30. package/dist/markdown-blocks.d.ts.map +1 -1
  31. package/dist/markdown-blocks.js +98 -79
  32. package/dist/markdown-blocks.js.map +1 -1
  33. package/dist/{MarkdownView.d.ts → markdown-view.d.ts} +20 -6
  34. package/dist/markdown-view.d.ts.map +1 -0
  35. package/dist/markdown-view.js +455 -0
  36. package/dist/markdown-view.js.map +1 -0
  37. package/dist/mermaid.d.ts +5 -5
  38. package/dist/mermaid.d.ts.map +1 -1
  39. package/dist/mermaid.js +33 -25
  40. package/dist/mermaid.js.map +1 -1
  41. package/dist/parsers.d.ts +5 -5
  42. package/dist/parsers.d.ts.map +1 -1
  43. package/dist/parsers.js +64 -44
  44. package/dist/parsers.js.map +1 -1
  45. package/dist/{RowDocumentRenderable.d.ts → row-document-renderable.d.ts} +15 -11
  46. package/dist/row-document-renderable.d.ts.map +1 -0
  47. package/dist/{RowDocumentRenderable.js → row-document-renderable.js} +110 -62
  48. package/dist/row-document-renderable.js.map +1 -0
  49. package/dist/row-document.d.ts +1 -1
  50. package/dist/row-document.d.ts.map +1 -1
  51. package/dist/row-document.js +1 -1
  52. package/dist/row-document.js.map +1 -1
  53. package/dist/source.d.ts +6 -6
  54. package/dist/source.d.ts.map +1 -1
  55. package/dist/source.js +35 -26
  56. package/dist/source.js.map +1 -1
  57. package/dist/table-types.d.ts.map +1 -1
  58. package/dist/{Table.d.ts → table.d.ts} +6 -6
  59. package/dist/table.d.ts.map +1 -0
  60. package/dist/{Table.js → table.js} +65 -35
  61. package/dist/table.js.map +1 -0
  62. package/dist/text-table.d.ts.map +1 -1
  63. package/dist/text-table.js.map +1 -1
  64. package/dist/use-gutter-palette.d.ts +3 -0
  65. package/dist/use-gutter-palette.d.ts.map +1 -0
  66. package/dist/{useGutterPalette.js → use-gutter-palette.js} +4 -4
  67. package/dist/use-gutter-palette.js.map +1 -0
  68. package/package.json +5 -5
  69. package/src/code-blocks.tsx +122 -106
  70. package/src/{CodeView.tsx → code-view.tsx} +19 -14
  71. package/src/command-palette.tsx +163 -0
  72. package/src/context-menu.tsx +157 -0
  73. package/src/decoration-layer.ts +11 -0
  74. package/src/document-bindings.ts +16 -0
  75. package/src/index.ts +24 -23
  76. package/src/markdown-blocks.ts +178 -138
  77. package/src/markdown-view.tsx +853 -0
  78. package/src/mermaid.ts +94 -71
  79. package/src/parsers.ts +141 -103
  80. package/src/row-document-renderable.ts +672 -0
  81. package/src/row-document.ts +4 -4
  82. package/src/source.ts +92 -72
  83. package/src/table-types.ts +4 -4
  84. package/src/table.tsx +346 -0
  85. package/src/text-table.ts +4 -4
  86. package/src/use-gutter-palette.ts +15 -0
  87. package/dist/CodeView.d.ts.map +0 -1
  88. package/dist/CodeView.js.map +0 -1
  89. package/dist/CommandPalette.d.ts.map +0 -1
  90. package/dist/CommandPalette.js.map +0 -1
  91. package/dist/ContextMenu.d.ts.map +0 -1
  92. package/dist/ContextMenu.js.map +0 -1
  93. package/dist/DecorationLayer.d.ts.map +0 -1
  94. package/dist/DecorationLayer.js +0 -2
  95. package/dist/DecorationLayer.js.map +0 -1
  96. package/dist/DocumentBindings.d.ts.map +0 -1
  97. package/dist/DocumentBindings.js +0 -2
  98. package/dist/DocumentBindings.js.map +0 -1
  99. package/dist/MarkdownView.d.ts.map +0 -1
  100. package/dist/MarkdownView.js +0 -275
  101. package/dist/MarkdownView.js.map +0 -1
  102. package/dist/RowDocumentRenderable.d.ts.map +0 -1
  103. package/dist/RowDocumentRenderable.js.map +0 -1
  104. package/dist/Table.d.ts.map +0 -1
  105. package/dist/Table.js.map +0 -1
  106. package/dist/useGutterPalette.d.ts +0 -3
  107. package/dist/useGutterPalette.d.ts.map +0 -1
  108. package/dist/useGutterPalette.js.map +0 -1
  109. package/src/CommandPalette.tsx +0 -147
  110. package/src/ContextMenu.tsx +0 -132
  111. package/src/DecorationLayer.ts +0 -11
  112. package/src/DocumentBindings.ts +0 -16
  113. package/src/MarkdownView.tsx +0 -541
  114. package/src/RowDocumentRenderable.ts +0 -593
  115. package/src/Table.tsx +0 -300
  116. package/src/useGutterPalette.ts +0 -15
@@ -1,5 +1,12 @@
1
- import { marked, type Token, type Tokens } from "marked"
2
- import { SourceIndex, type DocumentRowSource } from "./source.js"
1
+ import { marked } from "marked";
2
+ import type { Token, Tokens } from "marked";
3
+ import { SourceIndex } from "./source.js";
4
+ import type { DocumentRowSource } from "./source.js";
5
+
6
+ const LINE_FEED_CODE = 10;
7
+
8
+ /** Leading indent, bullet/ordinal marker, and optional checkbox on a list item's first line. */
9
+ const LIST_MARKER = /^(?<indent>\s*)(?:[-*+]|\d+[.)])[ \t]*(?:\[[ xX]\])?/u;
3
10
 
4
11
  // ---------------------------------------------------------------------------
5
12
  // Flat block model
@@ -11,23 +18,34 @@ import { SourceIndex, type DocumentRowSource } from "./source.js"
11
18
  * sibling blocks with appropriate indentation.
12
19
  */
13
20
  export interface FlatBlock {
14
- token: Token
15
- indent: number
16
- bullet?: string // "- " or "1. " for list item lines
17
- checked?: boolean // undefined = not a checkbox, true/false = checkbox state
21
+ token: Token;
22
+ indent: number;
23
+ bullet?: string;
24
+ checked?: boolean;
18
25
 
19
26
  /** Provenance in the Markdown input; `null` only if resolution genuinely failed. */
20
- source: DocumentRowSource | null
27
+ source: DocumentRowSource | null;
21
28
  }
22
29
 
23
30
  export interface FlattenMarkdownOptions {
24
- sourceId?: string
31
+ sourceId?: string;
25
32
  }
26
33
 
27
34
  /** Empty synthetic token stamped onto bullet-only rows (nested-list/block/empty items). */
28
- function syntheticTextToken(): Token {
29
- return { type: "text", raw: "", text: "", tokens: [] } as unknown as Token
30
- }
35
+ const syntheticTextToken = function syntheticTextToken(): Token {
36
+ return { raw: "", text: "", tokens: [], type: "text" };
37
+ };
38
+
39
+ /**
40
+ * Task-list marker for a bullet row. Rows that are not checkbox items have no
41
+ * marker. Not re-exported from the package index — internal to the renderers.
42
+ */
43
+ export const checkboxMarker = function checkboxMarker(checked: boolean | undefined): string {
44
+ if (checked === undefined) {
45
+ return "";
46
+ }
47
+ return checked ? "[x] " : "[ ] ";
48
+ };
31
49
 
32
50
  /**
33
51
  * The visible/searchable text for a block. Non-synthetic blocks use the token's
@@ -35,15 +53,16 @@ function syntheticTextToken(): Token {
35
53
  * bullet/checkbox text, then to the resolved source text. This keeps default
36
54
  * search and copy in agreement with the source mapping on synthetic rows.
37
55
  */
38
- export function getFlatBlockText(block: FlatBlock): string {
39
- const raw = "raw" in block.token && typeof block.token.raw === "string" ? block.token.raw : ""
40
- if (raw.length > 0) return raw
56
+ export const getFlatBlockText = function getFlatBlockText(block: FlatBlock): string {
57
+ const raw = "raw" in block.token && typeof block.token.raw === "string" ? block.token.raw : "";
58
+ if (raw.length > 0) {
59
+ return raw;
60
+ }
41
61
  if (block.bullet !== undefined) {
42
- const checkbox = block.checked !== undefined ? (block.checked ? "[x] " : "[ ] ") : ""
43
- return block.bullet + checkbox
62
+ return block.bullet + checkboxMarker(block.checked);
44
63
  }
45
- return block.source?.primary.text ?? ""
46
- }
64
+ return block.source?.primary.text ?? "";
65
+ };
47
66
 
48
67
  // ---------------------------------------------------------------------------
49
68
  // Markdown provenance resolver
@@ -57,27 +76,28 @@ export function getFlatBlockText(block: FlatBlock): string {
57
76
  * occurrences instead of backtracking to an earlier one.
58
77
  */
59
78
  class MarkdownResolver {
60
- readonly index: SourceIndex
61
- cursor = 0
62
-
63
- constructor(
64
- readonly markdown: string,
65
- sourceId?: string,
66
- ) {
67
- this.index = new SourceIndex(markdown, sourceId)
79
+ readonly index: SourceIndex;
80
+ readonly markdown: string;
81
+ cursor = 0;
82
+
83
+ constructor(markdown: string, sourceId?: string) {
84
+ this.markdown = markdown;
85
+ this.index = new SourceIndex(markdown, sourceId);
68
86
  }
69
87
 
70
88
  /** Resolve `raw` at/after the cursor within `[cursor, bound]`, then advance. */
71
89
  resolveRaw(raw: string, bound: number): DocumentRowSource | null {
72
- const match = this.find(raw, bound)
73
- if (!match) return null
74
- this.cursor = match.end
75
- return { primary: this.index.span(match.start, match.end) }
90
+ const match = this.findRaw(raw, bound);
91
+ if (!match) {
92
+ return null;
93
+ }
94
+ this.cursor = match.end;
95
+ return { primary: this.index.span(match.start, match.end) };
76
96
  }
77
97
 
78
98
  /** Find `raw`'s offset range without advancing the cursor. */
79
99
  locate(raw: string, bound: number): { start: number; end: number } | null {
80
- return this.find(raw, bound)
100
+ return this.findRaw(raw, bound);
81
101
  }
82
102
 
83
103
  /**
@@ -87,73 +107,87 @@ class MarkdownResolver {
87
107
  * newline-tolerant match (a needle `\n` matches a source `\r\n` or `\n`) so
88
108
  * offsets keep addressing the original `\r\n` string without normalizing it.
89
109
  */
90
- private find(raw: string, bound: number): { start: number; end: number } | null {
91
- if (raw.length === 0) return null
92
- const md = this.markdown
110
+ private findRaw(raw: string, bound: number): { start: number; end: number } | null {
111
+ if (raw.length === 0) {
112
+ return null;
113
+ }
114
+ const md = this.markdown;
93
115
 
94
- const exact = md.indexOf(raw, this.cursor)
95
- if (exact !== -1 && exact + raw.length <= bound)
96
- return { start: exact, end: exact + raw.length }
116
+ const exact = md.indexOf(raw, this.cursor);
117
+ if (exact !== -1 && exact + raw.length <= bound) {
118
+ return { end: exact + raw.length, start: exact };
119
+ }
97
120
 
98
- if (!raw.includes("\n")) return null
121
+ if (!raw.includes("\n")) {
122
+ return null;
123
+ }
99
124
 
100
- const firstSegment = raw.slice(0, raw.indexOf("\n"))
101
- if (firstSegment.length === 0) return null
125
+ const firstSegment = raw.slice(0, raw.indexOf("\n"));
126
+ if (firstSegment.length === 0) {
127
+ return null;
128
+ }
102
129
 
103
- let from = this.cursor
130
+ let from = this.cursor;
104
131
  for (;;) {
105
- const start = md.indexOf(firstSegment, from)
106
- if (start === -1 || start >= bound) return null
107
- const end = this.matchFlexibleNewlines(raw, start, bound)
108
- if (end !== -1) return { start, end }
109
- from = start + 1
132
+ const start = md.indexOf(firstSegment, from);
133
+ if (start === -1 || start >= bound) {
134
+ return null;
135
+ }
136
+ const end = this.matchFlexibleNewlines(raw, start, bound);
137
+ if (end !== -1) {
138
+ return { end, start };
139
+ }
140
+ from = start + 1;
110
141
  }
111
142
  }
112
143
 
113
144
  /** Match `raw` from `start`, letting a needle `\n` consume a source `\r\n`. */
114
145
  private matchFlexibleNewlines(raw: string, start: number, bound: number): number {
115
- const md = this.markdown
116
- const length = md.length
117
- let h = start
118
- let n = 0
146
+ const md = this.markdown;
147
+ const { length } = md;
148
+ let h = start;
149
+ let n = 0;
119
150
  while (n < raw.length) {
120
- const code = raw.charCodeAt(n)
121
- if (code === 10 /* \n */) {
122
- if (h + 1 < length && md.charCodeAt(h) === 13 && md.charCodeAt(h + 1) === 10) {
123
- h += 2
124
- } else if (h < length && md.charCodeAt(h) === 10) {
125
- h += 1
151
+ const code = raw.codePointAt(n);
152
+ if (code === LINE_FEED_CODE) {
153
+ if (h + 1 < length && md.codePointAt(h) === 13 && md.codePointAt(h + 1) === 10) {
154
+ h += 2;
155
+ } else if (h < length && md.codePointAt(h) === 10) {
156
+ h += 1;
126
157
  } else {
127
- return -1
158
+ return -1;
128
159
  }
129
- n += 1
160
+ n += 1;
161
+ } else if (h < length && md.codePointAt(h) === code) {
162
+ h += 1;
163
+ n += 1;
130
164
  } else {
131
- if (h < length && md.charCodeAt(h) === code) {
132
- h += 1
133
- n += 1
134
- } else {
135
- return -1
136
- }
165
+ return -1;
137
166
  }
138
167
  }
139
- return h <= bound ? h : -1
168
+ return h <= bound ? h : -1;
140
169
  }
141
170
 
142
171
  /** Zero-consumption marker span for a synthetic bullet on the item's first line. */
143
172
  markerSource(itemStart: number, itemEnd: number): DocumentRowSource {
144
- const nl = this.markdown.indexOf("\n", itemStart)
145
- const lineEnd = nl === -1 ? itemEnd : Math.min(nl, itemEnd)
146
- const firstLine = this.markdown.slice(itemStart, lineEnd)
147
- const match = firstLine.match(/^(\s*)(?:[-*+]|\d+[.)])[ \t]*(?:\[[ xX]\])?/)
148
- if (!match) return { primary: this.index.span(itemStart, itemStart, false) }
149
- const markerStart = itemStart + match[1]!.length
150
- let spanEnd = itemStart + match[0].length
173
+ const nl = this.markdown.indexOf("\n", itemStart);
174
+ const lineEnd = nl === -1 ? itemEnd : Math.min(nl, itemEnd);
175
+ const firstLine = this.markdown.slice(itemStart, lineEnd);
176
+ const match = LIST_MARKER.exec(firstLine);
177
+ if (!match) {
178
+ return { primary: this.index.span(itemStart, itemStart, false) };
179
+ }
180
+ const markerStart = itemStart + (match.groups?.indent ?? "").length;
181
+ let spanEnd = itemStart + match[0].length;
151
182
  while (spanEnd > markerStart) {
152
- const code = this.markdown.charCodeAt(spanEnd - 1)
153
- if (code !== 32 && code !== 9) break // space / tab
154
- spanEnd--
183
+ const code = this.markdown.codePointAt(spanEnd - 1);
184
+ // Continue while the character is a space or tab.
185
+ if (code !== 32 && code !== 9) {
186
+ break;
187
+ }
188
+ spanEnd -= 1;
155
189
  }
156
- return { primary: this.index.span(markerStart, spanEnd, false) }
190
+ return { primary: this.index.span(markerStart, spanEnd, false) };
157
191
  }
158
192
  }
159
193
 
@@ -161,39 +195,44 @@ class MarkdownResolver {
161
195
  // Flattening (shared by mapped and unmapped forms)
162
196
  // ---------------------------------------------------------------------------
163
197
 
164
- function bulletFor(list: Tokens.List, itemIndex: number): string {
165
- return list.ordered ? `${itemIndex + (list.start || 1)}. ` : "- "
166
- }
198
+ const bulletFor = function bulletFor(list: Tokens.List, itemIndex: number): string {
199
+ return list.ordered
200
+ ? `${itemIndex + (list.start === "" || list.start === 0 ? 1 : list.start)}. `
201
+ : "- ";
202
+ };
167
203
 
168
- function flattenList(
204
+ const flattenList = function flattenList(
169
205
  list: Tokens.List,
170
206
  indent: number,
171
207
  out: FlatBlock[],
172
208
  res: MarkdownResolver | null,
173
209
  bound: number,
174
210
  ): void {
175
- for (let i = 0; i < list.items.length; i++) {
176
- const item = list.items[i]!
177
- const bullet = bulletFor(list, i)
211
+ for (let i = 0; i < list.items.length; i += 1) {
212
+ const item = list.items[i];
213
+ const bullet = bulletFor(list, i);
178
214
 
179
- let itemStart: number | null = null
180
- let itemEnd = bound
215
+ let itemStart: number | null = null;
216
+ let itemEnd = bound;
181
217
  if (res) {
182
- const loc = res.locate(item.raw, bound)
218
+ const loc = res.locate(item.raw, bound);
183
219
  if (loc) {
184
- itemStart = loc.start
185
- itemEnd = loc.end
186
- res.cursor = loc.start
220
+ itemStart = loc.start;
221
+ itemEnd = loc.end;
222
+ res.cursor = loc.start;
187
223
  }
188
224
  }
189
225
 
190
- flattenListItem(item, indent, bullet, out, res, itemStart, itemEnd)
226
+ // oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): preserve deliberate top-down list flattening organization
227
+ flattenListItem(item, indent, bullet, out, res, itemStart, itemEnd);
191
228
 
192
- if (res && itemStart !== null) res.cursor = itemEnd
229
+ if (res && itemStart !== null) {
230
+ res.cursor = itemEnd;
231
+ }
193
232
  }
194
- }
233
+ };
195
234
 
196
- function flattenListItem(
235
+ const flattenListItem = function flattenListItem(
197
236
  item: Tokens.ListItem,
198
237
  indent: number,
199
238
  bullet: string,
@@ -202,53 +241,62 @@ function flattenListItem(
202
241
  itemStart: number | null,
203
242
  itemEnd: number,
204
243
  ): void {
205
- const checked = item.checked != null ? item.checked : undefined
206
- const childTokens = item.tokens || []
207
- let bulletUsed = false
244
+ const checked = item.checked === null ? undefined : item.checked;
245
+ const childTokens = item.tokens;
246
+ let bulletUsed = false;
208
247
 
209
248
  const emitBulletMarker = () => {
210
249
  out.push({
211
- token: syntheticTextToken(),
212
- indent,
213
250
  bullet,
214
251
  checked,
252
+ indent,
215
253
  source: res && itemStart !== null ? res.markerSource(itemStart, itemEnd) : null,
216
- })
217
- bulletUsed = true
218
- }
254
+ token: syntheticTextToken(),
255
+ });
256
+ bulletUsed = true;
257
+ };
219
258
 
220
259
  for (const token of childTokens) {
221
- if (token.type === "space" || token.type === "checkbox") continue
260
+ if (token.type === "space" || token.type === "checkbox") {
261
+ continue;
262
+ }
222
263
 
223
264
  if (token.type === "text" || token.type === "paragraph") {
224
265
  // Inline content — attach the bullet to the first one.
225
266
  out.push({
226
- token,
227
- indent,
228
267
  bullet: bulletUsed ? undefined : bullet,
229
268
  checked: bulletUsed ? undefined : checked,
269
+ indent,
230
270
  source: res ? res.resolveRaw(token.raw ?? "", itemEnd) : null,
231
- })
232
- bulletUsed = true
271
+ token,
272
+ });
273
+ bulletUsed = true;
233
274
  } else if (token.type === "list") {
234
- if (!bulletUsed) emitBulletMarker()
235
- flattenList(token as Tokens.List, indent + bullet.length, out, res, itemEnd)
275
+ if (!bulletUsed) {
276
+ emitBulletMarker();
277
+ }
278
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Deferred(lint-sweep): marked token narrowing; schema-based validation in a later sweep
279
+ flattenList(token as Tokens.List, indent + bullet.length, out, res, itemEnd);
236
280
  } else {
237
281
  // Block content (code, table, blockquote, hr, etc.).
238
- if (!bulletUsed) emitBulletMarker()
282
+ if (!bulletUsed) {
283
+ emitBulletMarker();
284
+ }
239
285
  out.push({
240
- token,
241
286
  indent: indent + bullet.length,
242
287
  source: res ? res.resolveRaw(token.raw ?? "", itemEnd) : null,
243
- })
288
+ token,
289
+ });
244
290
  }
245
291
  }
246
292
 
247
293
  // List item had no content tokens — still emit the bullet.
248
- if (!bulletUsed) emitBulletMarker()
249
- }
294
+ if (!bulletUsed) {
295
+ emitBulletMarker();
296
+ }
297
+ };
250
298
 
251
- function flattenWalk(
299
+ const flattenWalk = function flattenWalk(
252
300
  tokens: Token[],
253
301
  indent: number,
254
302
  out: FlatBlock[],
@@ -256,14 +304,17 @@ function flattenWalk(
256
304
  bound: number,
257
305
  ): void {
258
306
  for (const token of tokens) {
259
- if (token.type === "space") continue
307
+ if (token.type === "space") {
308
+ continue;
309
+ }
260
310
  if (token.type === "list") {
261
- flattenList(token as Tokens.List, indent, out, res, bound)
311
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Deferred(lint-sweep): marked token narrowing; schema-based validation in a later sweep
312
+ flattenList(token as Tokens.List, indent, out, res, bound);
262
313
  } else {
263
- out.push({ token, indent, source: res ? res.resolveRaw(token.raw ?? "", bound) : null })
314
+ out.push({ indent, source: res ? res.resolveRaw(token.raw ?? "", bound) : null, token });
264
315
  }
265
316
  }
266
- }
317
+ };
267
318
 
268
319
  // ---------------------------------------------------------------------------
269
320
  // Public entry points
@@ -274,23 +325,12 @@ function flattenWalk(
274
325
  * carries a `source` anchor (or `null` when a marked edge case leaves a token
275
326
  * genuinely unresolvable), in the exact order used for navigation/rendering.
276
327
  */
277
- export function flattenMarkdown(markdown: string, options?: FlattenMarkdownOptions): FlatBlock[] {
278
- const res = new MarkdownResolver(markdown, options?.sourceId)
279
- const out: FlatBlock[] = []
280
- flattenWalk(marked.lexer(markdown), 0, out, res, markdown.length)
281
- return out
282
- }
283
-
284
- /**
285
- * The unmapped low-level form: flatten already-lexed tokens with no source
286
- * provenance (every block's `source` is `null`).
287
- *
288
- * @deprecated Prefer `flattenMarkdown(source)` for source-backed rows. Tokens
289
- * carry no positions and the original source is unavailable here, so offsets
290
- * cannot be reconstructed.
291
- */
292
- export function flattenTokens(tokens: Token[]): FlatBlock[] {
293
- const out: FlatBlock[] = []
294
- flattenWalk(tokens, 0, out, null, 0)
295
- return out
296
- }
328
+ export const flattenMarkdown = function flattenMarkdown(
329
+ markdown: string,
330
+ options?: FlattenMarkdownOptions,
331
+ ): FlatBlock[] {
332
+ const res = new MarkdownResolver(markdown, options?.sourceId);
333
+ const out: FlatBlock[] = [];
334
+ flattenWalk(marked.lexer(markdown), 0, out, res, markdown.length);
335
+ return out;
336
+ };