@yaks/markdown 0.0.0-stage → 0.2.36

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/structural.js ADDED
@@ -0,0 +1,589 @@
1
+ /** Markdown as structural nodes, never generated HTML or terminal escapes.
2
+ * Uses the same GFM parser/version as the older canvas markdown renderer.
3
+ */ import { Lexer, Marked, Tokenizer } from "marked";
4
+ import { HUMAN, short, WRITTEN } from "@yaks/id";
5
+ import { away } from "./away.js";
6
+ // An id is a word of its own: a T-123 at a boundary, whatever its letter (the
7
+ // number names the entity), a #hex short id, a UUID or a whole SHA. UTF-8 and
8
+ // SHA-256 stay words because their letters sit mid-word, and one after a slash
9
+ // is a segment of a path or an address, which drawn would lead nowhere.
10
+ let UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
11
+ let ID = `${WRITTEN}|#[0-9a-fA-F]{6,64}|${UUID}|[0-9a-f]{64}|[0-9a-f]{40}`;
12
+ let START = new RegExp(`(?<![\\w#/-])(?:${ID})(?![\\w-])`);
13
+ let REF = new RegExp(`^(?:${ID})(?![\\w-])`);
14
+ let NAMED = new RegExp(`^(?:#[0-9a-fA-F]{6,64}|${UUID}|[0-9a-f]{40}|[0-9a-f]{64})$`);
15
+ let HEX = /^[0-9a-f]{7,64}$/i;
16
+ let EID = new RegExp(`^${UUID}$`, 'i');
17
+ let EIDS = new RegExp(UUID, 'i');
18
+ /** Whether a link's target is an entity id rather than an address. */ export let named = (href)=>HUMAN.test(href) || NAMED.test(href);
19
+ /** An id as prose draws it: an eid as the host calls it ({@link Ids}), or its
20
+ * short handle; any other id as written. */ export let shown = (id, ids)=>EID.test(id) ? ids?.(id.toLowerCase()) ?? short(id) : id;
21
+ // Where the next id may start. Marked asks before every run of plain text,
22
+ // about all the text left, so a search of all of it made a long text with few
23
+ // ids quadratic: a 1 MB body took 21 seconds. The search looks a window ahead
24
+ // instead, and with no id in it answers the last boundary well short of its
25
+ // end, where no id the window cut short can have begun. Marked joins adjacent
26
+ // text, and at a boundary its text either stops anyway (`\`, `<`, `!`, `[`,
27
+ // `` ` ``, `*`, `~`, `_`) or nothing else can begin: no address and no email.
28
+ // A boundary that follows a space is passed over, so the spaces of a line
29
+ // break (` \n`) are never split.
30
+ let AHEAD = 512;
31
+ let REACH = 128;
32
+ let BOUND = /[\s"(),;>\]\\<![`*~_]/;
33
+ let next = (src)=>{
34
+ if (src.length <= AHEAD) return src.match(START)?.index;
35
+ let head = src.slice(0, AHEAD);
36
+ let i = head.match(START)?.index;
37
+ if (i != null) return i;
38
+ for(let at = AHEAD - REACH; at > 0; at--){
39
+ if (BOUND.test(head[at]) && !/\s/.test(head[at - 1])) return at;
40
+ }
41
+ return src.match(START)?.index;
42
+ };
43
+ // A setext heading, a run of lines underlined with `=` or `-`: marked's own
44
+ // rule, with each line's run of characters taken whole. Marked reads the run a
45
+ // character at a time, which a paragraph of megabytes runs out of stack on (a
46
+ // 12 MB JSON dump threw); a line at a time, 33 MB reads in a tenth of a second.
47
+ let setext = Lexer.rules.block.gfm.lheading;
48
+ let SETEXT = new RegExp(setext.source.replace('(?:.|\\n(?!', '(?:(?=([^\\n\\r\\u2028\\u2029]+))\\2|\\n(?!'), setext.flags);
49
+ // Emphasis and a strikethrough close within a span of text: a `*`, `_` or `~`
50
+ // whose closer stands farther off stays as typed. Marked looks for
51
+ // the closing `*`, `_` or `~` through the rest of the paragraph, once for every
52
+ // one that opens, so a paragraph of megabytes with a few hundred that never
53
+ // close took a minute. It is asked about the span ahead instead (and the run
54
+ // just behind, which says whether the opener is one), and a closer found where
55
+ // the span cuts its view short is asked about the whole text again.
56
+ let SPAN = 4096;
57
+ let BEHIND = 256;
58
+ let spanned = (close)=>function(src, masked, before) {
59
+ let at = masked.length - src.length;
60
+ let found = close.call(this, src.slice(0, SPAN), masked.slice(Math.max(0, at - BEHIND), at + SPAN), before);
61
+ return found && src.length > SPAN && found.raw.length > SPAN - REACH ? close.call(this, src, masked, before) : found;
62
+ };
63
+ let lexer = new Marked({
64
+ gfm: true,
65
+ tokenizer: {
66
+ emStrong: spanned(Tokenizer.prototype.emStrong),
67
+ del: spanned(Tokenizer.prototype.del),
68
+ lheading (src) {
69
+ let m = SETEXT.exec(src);
70
+ if (!m) return undefined;
71
+ let text = m[1].trim();
72
+ return {
73
+ type: 'heading',
74
+ raw: m[0].replace(/\n+$/, ''),
75
+ depth: m[3][0] == '=' ? 1 : 2,
76
+ text,
77
+ tokens: this.lexer.inline(text)
78
+ };
79
+ }
80
+ },
81
+ extensions: [
82
+ {
83
+ name: 'ref',
84
+ level: 'inline',
85
+ start: next,
86
+ // `start` is asked about the text after a line's first character, so it
87
+ // cannot see that character: the token before says what the id follows,
88
+ // and one glued to a word (`xT-12`) is no id. It is read only where an id
89
+ // starts: marked tries this at every step and joins adjacent text into one
90
+ // token, so reading it each time copied the paragraph so far every step.
91
+ tokenizer: (src, before)=>{
92
+ let m = REF.exec(src);
93
+ if (!m || /[\w#-]/.test(before.at(-1)?.raw.at(-1) ?? '')) return undefined;
94
+ return {
95
+ type: 'ref',
96
+ raw: m[0],
97
+ text: m[0],
98
+ id: m[0]
99
+ };
100
+ }
101
+ }
102
+ ]
103
+ });
104
+ /** Parse GFM. `breaks` turns a single newline into a line break, which is what
105
+ * a chat message or a terminal line wants and what a document does not: prose
106
+ * wrapped at 80 columns would keep every one of those wraps. An entity id in
107
+ * the prose is a `ref` token of its own; code keeps its ids literal. */ export let parse = (source, { breaks = true } = {})=>lexer.lexer(source, {
108
+ ...lexer.defaults,
109
+ breaks
110
+ });
111
+ /** Parse a line of GFM, such as a label or a title: its inline markup only,
112
+ * with no paragraph around it. */ export let parseInline = (source)=>lexer.Lexer.lexInline(source, lexer.defaults);
113
+ /** What a document points at, in reading order, read the way it is drawn: an
114
+ * id written bare, a link written to an id, and a hex word quoted in code
115
+ * (which the host may know as a commit) are entities; any other link or image
116
+ * is its address, unless the renderer would refuse it or it carries a quote
117
+ * or a backslash, the debris of prose around a bare URL. Code keeps its ids
118
+ * literal. */ export let mentions = (tokens)=>{
119
+ let out = [];
120
+ lexer.walkTokens(tokens, (t)=>{
121
+ if (t.type == 'ref') {
122
+ out.push({
123
+ kind: 'entity',
124
+ id: String(t.id)
125
+ });
126
+ } else if (t.type == 'codespan' && HEX.test(t.text)) {
127
+ out.push({
128
+ kind: 'entity',
129
+ id: t.text
130
+ });
131
+ } else if (t.type == 'link' || t.type == 'image') {
132
+ let href = t.href.trim();
133
+ if (named(href)) out.push({
134
+ kind: 'entity',
135
+ id: href
136
+ });
137
+ else if (href && !/["'\\]/.test(href) && safeHref(href) != null) {
138
+ out.push({
139
+ kind: 'link',
140
+ href
141
+ });
142
+ }
143
+ }
144
+ });
145
+ return out;
146
+ };
147
+ // Prose rewritten id by id, still as text: each id written bare or as a link's
148
+ // target is given to `f`, and replaced by what it answers. Code keeps its ids
149
+ // literal, and a link keeps its own words. Marked keeps no offsets, but a
150
+ // token's raw text stands in the source inside its parent's, after its elder
151
+ // sibling's, so each is found there: an id is swapped where it is read, never
152
+ // where the same letters stand inside another word earlier on
153
+ // (`/tmp/T-12-proof … T-12`). A token whose raw the lexer reshaped (a list
154
+ // item's indented lines) is not found, and its children are looked for in
155
+ // what is left of its parent.
156
+ let rewritten = (source, f)=>{
157
+ let edits = [];
158
+ let kids = (t)=>t.type == 'list' ? t.items : t.type == 'table' ? [
159
+ t.header,
160
+ ...t.rows
161
+ ].flatMap((row)=>row.flatMap((cell)=>cell.tokens)) : t.tokens ?? [];
162
+ let walk = (tokens, from, to)=>{
163
+ let at = from;
164
+ for (let t of tokens){
165
+ let i = source.slice(at, to).indexOf(t.raw);
166
+ if (i < 0) {
167
+ if (t.type != 'ref') at = walk(kids(t), at, to);
168
+ continue;
169
+ }
170
+ i += at;
171
+ let end = i + t.raw.length;
172
+ if (t.type == 'ref') {
173
+ let word = f(t.raw);
174
+ if (word != null && word != t.raw) edits.push([
175
+ i,
176
+ end,
177
+ word
178
+ ]);
179
+ } else if (t.type == 'link' && named(t.href)) {
180
+ let { href } = t;
181
+ let j = i + t.raw.lastIndexOf(href);
182
+ let word = f(href);
183
+ if (word != null && word != href) edits.push([
184
+ j,
185
+ j + href.length,
186
+ word
187
+ ]);
188
+ walk(kids(t), i + 1, j);
189
+ } else if (t.type != 'code' && t.type != 'codespan') {
190
+ walk(kids(t), i, end);
191
+ }
192
+ at = end;
193
+ }
194
+ return at;
195
+ };
196
+ walk(parse(source, {
197
+ breaks: false
198
+ }), 0, source.length);
199
+ let out = [];
200
+ let at = 0;
201
+ for (let [from, to, word] of edits.sort((a, b)=>a[0] - b[0])){
202
+ out.push(source.slice(at, from), word);
203
+ at = to;
204
+ }
205
+ out.push(source.slice(at));
206
+ return out.join('');
207
+ };
208
+ /** Prose as its reader reads it, still as text: each eid it holds, written
209
+ * bare or as a link's target, drawn as {@link shown} draws it, so a model or a
210
+ * printout never reads a whole uuid. Code keeps its ids literal, and a link
211
+ * keeps its own words. What the renderer does to the same text, for a reader
212
+ * of text rather than nodes. */ export let drawn = (source, ids)=>EIDS.test(source) ? rewritten(source, (id)=>EID.test(id) ? shown(id, ids) : undefined) : source;
213
+ /** The eids prose holds, written bare or as a link's target, in reading
214
+ * order, once each and in lower case: what {@link drawn} and the renderer ask
215
+ * a host's {@link Ids} about. Code keeps its ids literal, so none in it is
216
+ * listed. */ export let eids = (source)=>{
217
+ if (!EIDS.test(source)) return [];
218
+ let out = new Set();
219
+ rewritten(source, (id)=>{
220
+ if (EID.test(id)) out.add(id.toLowerCase());
221
+ return undefined;
222
+ });
223
+ return [
224
+ ...out
225
+ ];
226
+ };
227
+ // An id a person types for an entity, as prose holds it before it is stored:
228
+ // a human id or a short handle. An eid is already what is stored, and a SHA
229
+ // names its content.
230
+ let TYPED = new RegExp(`^(?:${WRITTEN}|#[0-9a-fA-F]{10,64})$`);
231
+ let TYPES = new RegExp(`(?:${WRITTEN}|#[0-9a-fA-F]{10})`);
232
+ /** The ids typed in prose that a store would name an entity by: each human id
233
+ * (`T-12`) and short handle (`#a3f19c024b`) written bare or as a link's
234
+ * target, in reading order, once each. Code keeps its ids literal, so none in
235
+ * it is listed. What {@link stored} is asked to swap. */ export let typed = (source)=>{
236
+ if (!TYPES.test(source)) return [];
237
+ let out = new Set();
238
+ rewritten(source, (id)=>{
239
+ if (TYPED.test(id)) out.add(id);
240
+ return undefined;
241
+ });
242
+ return [
243
+ ...out
244
+ ];
245
+ };
246
+ /** Prose as a store keeps it: each id {@link typed} lists that `eids` names
247
+ * replaced by that eid, bare or as a link's target, so the text names the
248
+ * entity in any store and under any number. An id it does not name stays as
249
+ * typed, and so does everything in code and a link's own words.
250
+ *
251
+ * Given the text it replaces (`was`), only the ids the new text adds are
252
+ * swapped: one standing where `was` kept the same id as typed stays typed, so
253
+ * words left alone (`P-1 is very useful`) are never bound to whatever entity
254
+ * comes to hold that id later. One standing where `was` held the eid it names
255
+ * (a body written back as its reader saw it drawn) takes that eid again. */ export let stored = (source, eids, was)=>{
256
+ if (!TYPES.test(source)) return source;
257
+ let kept = was == null ? undefined : untouched(said(source), said(was), eids);
258
+ let n = 0;
259
+ return rewritten(source, (id)=>kept?.has(n++) || !TYPED.test(id) ? undefined : eids(id));
260
+ };
261
+ // Every id a text holds bare or as a link's target, in reading order: what
262
+ // `rewritten` hands its function, one per place the id stands.
263
+ let said = (source)=>{
264
+ let out = [];
265
+ rewritten(source, (id)=>{
266
+ out.push(id);
267
+ return undefined;
268
+ });
269
+ return out;
270
+ };
271
+ // Which of the new text's ids stand where the old text kept the same id as
272
+ // typed: the places of the longest run the two share in order, where an old
273
+ // id matches a new one written the same, or an old eid matches the new id
274
+ // that names it. Only a typed match is kept; the rest are the new text's own.
275
+ let untouched = (now, was, eids)=>{
276
+ let same = (a, b)=>a == b || EID.test(b) && TYPED.test(a) && eids(a) == b;
277
+ let head = 0;
278
+ while(head < now.length && head < was.length && same(now[head], was[head])){
279
+ head++;
280
+ }
281
+ let tail = 0;
282
+ while(tail < now.length - head && tail < was.length - head && same(now[now.length - 1 - tail], was[was.length - 1 - tail]))tail++;
283
+ let pairs = [];
284
+ for(let i = 0; i < head; i++)pairs.push([
285
+ i,
286
+ i
287
+ ]);
288
+ for(let k = 1; k <= tail; k++)pairs.push([
289
+ now.length - k,
290
+ was.length - k
291
+ ]);
292
+ let a = now.slice(head, now.length - tail);
293
+ let b = was.slice(head, was.length - tail);
294
+ if (a.length * b.length > 4e6) {
295
+ // Too many ids changed between the ends for a table: matched in order.
296
+ for(let i = 0, j = 0; i < a.length && j < b.length; i++){
297
+ let k = b.indexOf(a[i], j);
298
+ if (k < 0) continue;
299
+ pairs.push([
300
+ head + i,
301
+ head + k
302
+ ]);
303
+ j = k + 1;
304
+ }
305
+ } else if (a.length && b.length) {
306
+ // The longest common subsequence of what is left, table by table.
307
+ let w = b.length + 1;
308
+ let t = new Uint32Array((a.length + 1) * w);
309
+ for(let i = a.length - 1; i >= 0; i--){
310
+ for(let j = b.length - 1; j >= 0; j--){
311
+ t[i * w + j] = same(a[i], b[j]) ? t[(i + 1) * w + j + 1] + 1 : Math.max(t[(i + 1) * w + j], t[i * w + j + 1]);
312
+ }
313
+ }
314
+ for(let i = 0, j = 0; i < a.length && j < b.length;){
315
+ if (same(a[i], b[j])) pairs.push([
316
+ head + i++,
317
+ head + j++
318
+ ]);
319
+ else if (t[(i + 1) * w + j] >= t[i * w + j + 1]) i++;
320
+ else j++;
321
+ }
322
+ }
323
+ return new Set(pairs.filter(([i, j])=>now[i] == was[j] && TYPED.test(was[j])).map(([i])=>i));
324
+ };
325
+ /** The words a heading is made of, with the markup dropped: a reader sees
326
+ * these words, so the anchor is named after them. */ let words = (tokens)=>tokens.map((t)=>{
327
+ let inner = t.tokens;
328
+ return inner ? words(inner) : t.text ?? '';
329
+ }).join('');
330
+ /** A document's anchor names, handed out in reading order: lowercase words
331
+ * joined by hyphens, everything that is not a letter or a number dropped — so
332
+ * a name can never carry a quote or an angle bracket into an attribute — and
333
+ * a number on any name the document says twice. */ export let slugs = ()=>{
334
+ let seen = new Map();
335
+ return (text)=>{
336
+ let base = text.toLowerCase().replace(/[^\p{L}\p{N} -]/gu, '').trim().replace(/\s+/g, '-') || 'section';
337
+ let n = (seen.get(base) ?? 0) + 1;
338
+ seen.set(base, n);
339
+ return n > 1 ? `${base}-${n}` : base;
340
+ };
341
+ };
342
+ /** Every heading of a document in reading order, each under the id `render`
343
+ * gives it — which is how a contents list links what is on the page without
344
+ * drawing the page a second time. */ export let headings = (tokens)=>{
345
+ let name = slugs();
346
+ let found = (items)=>items.flatMap((t)=>{
347
+ if (t.type == 'heading') {
348
+ let text = words(t.tokens);
349
+ return [
350
+ {
351
+ depth: t.depth,
352
+ text,
353
+ id: name(text)
354
+ }
355
+ ];
356
+ }
357
+ let inner = t.tokens;
358
+ return inner ? found(inner) : [];
359
+ });
360
+ return found(tokens);
361
+ };
362
+ /** Only navigable links: no scripting, data, or control-byte URL schemes. */ export let safeHref = (href)=>{
363
+ if ([
364
+ ...href
365
+ ].some((c)=>c.charCodeAt(0) <= 32 || c.charCodeAt(0) == 127)) {
366
+ return undefined;
367
+ }
368
+ if (/^[a-z][a-z\d+.-]*:/i.test(href) && !/^(https?:|mailto:)/i.test(href)) {
369
+ return undefined;
370
+ }
371
+ return href;
372
+ };
373
+ let parts = {
374
+ p: 'Paragraph',
375
+ h1: 'Heading',
376
+ h2: 'Heading',
377
+ h3: 'Heading',
378
+ h4: 'Heading',
379
+ h5: 'Heading',
380
+ h6: 'Heading',
381
+ strong: 'Strong',
382
+ em: 'Emphasis',
383
+ del: 'Deleted',
384
+ code: 'Code',
385
+ pre: 'Source',
386
+ br: 'Break',
387
+ hr: 'Rule',
388
+ blockquote: 'Quote',
389
+ ol: 'Ordered',
390
+ ul: 'Unordered',
391
+ li: 'Item',
392
+ a: 'Link',
393
+ table: 'Table',
394
+ thead: 'Head',
395
+ tbody: 'Rows',
396
+ tr: 'Row',
397
+ th: 'HeadingCell',
398
+ td: 'Cell'
399
+ };
400
+ let bodyClass = (tag)=>`Body_${parts[tag]}` + (/^h[1-6]$/.test(tag) ? ` Body_Heading-${tag.slice(1)}` : '');
401
+ /** The parsed tree's blocks through any @yaks/render host (including
402
+ * Preact), for a caller that holds them in an element of its own, such as a
403
+ * page's `Body`. HTML tokens remain text. Images are descriptive links, never
404
+ * remote fetches.
405
+ */ export let blocks = (tokens, host, { refs, ids, code, flat, site } = {})=>{
406
+ let name = slugs();
407
+ // An id the host can open is an anchor carrying the id, so a host can give
408
+ // it its own click; one it cannot open is the words it was written as. An
409
+ // eid is drawn short, and leads where its short form does.
410
+ let ref = (id, ...words)=>{
411
+ let href = flat ? undefined : refs?.(shown(id, ids));
412
+ let link = href == null ? undefined : safeHref(href);
413
+ return link == null ? words : [
414
+ element('a', {
415
+ href: link,
416
+ 'data-ref': id,
417
+ class: 'Body_Ref'
418
+ }, ...words)
419
+ ];
420
+ };
421
+ let element = (tag, props, ...children)=>{
422
+ return host(tag, {
423
+ ...tag == 'a' && props ? away(props, site) : props,
424
+ class: [
425
+ bodyClass(tag),
426
+ props?.class
427
+ ].filter(Boolean).join(' ')
428
+ }, ...children);
429
+ };
430
+ let children = (items)=>items.flatMap(token);
431
+ let token = (t)=>{
432
+ switch(t.type){
433
+ case 'space':
434
+ return [];
435
+ case 'paragraph':
436
+ return [
437
+ element('p', null, ...children(t.tokens))
438
+ ];
439
+ case 'heading':
440
+ {
441
+ let v = t;
442
+ // The id is the anchor a contents list points at (`headings` hands
443
+ // out the same names in the same order), so every consumer of a
444
+ // document gets headings it can link to.
445
+ let at = {
446
+ id: name(words(v.tokens))
447
+ };
448
+ return [
449
+ element('h' + v.depth, at, ...children(v.tokens))
450
+ ];
451
+ }
452
+ case 'strong':
453
+ return [
454
+ element('strong', null, ...children(t.tokens))
455
+ ];
456
+ case 'em':
457
+ return [
458
+ element('em', null, ...children(t.tokens))
459
+ ];
460
+ case 'del':
461
+ return [
462
+ element('del', null, ...children(t.tokens))
463
+ ];
464
+ case 'codespan':
465
+ {
466
+ let { text } = t;
467
+ let quoted = element('code', null, text);
468
+ return HEX.test(text) ? ref(text, quoted) : [
469
+ quoted
470
+ ];
471
+ }
472
+ case 'ref':
473
+ {
474
+ let id = String(t.id);
475
+ return ref(id, shown(id, ids));
476
+ }
477
+ case 'code':
478
+ {
479
+ let v = t;
480
+ let lang = v.lang?.split(/\s/)[0] || undefined;
481
+ let runs = code?.(v.text, lang);
482
+ return [
483
+ element('pre', null, element('code', {
484
+ class: lang ? 'language-' + lang : undefined
485
+ }, ...runs ? runs.map((r)=>r.classes.length ? host('span', {
486
+ class: r.classes.join(' ')
487
+ }, r.text) : r.text) : [
488
+ v.text
489
+ ]))
490
+ ];
491
+ }
492
+ case 'br':
493
+ return [
494
+ element('br', null)
495
+ ];
496
+ case 'hr':
497
+ return [
498
+ element('hr', null)
499
+ ];
500
+ case 'blockquote':
501
+ return [
502
+ element('blockquote', null, ...children(t.tokens))
503
+ ];
504
+ case 'list':
505
+ {
506
+ let v = t;
507
+ return [
508
+ element(v.ordered ? 'ol' : 'ul', {
509
+ start: v.ordered ? v.start : undefined
510
+ }, ...v.items.map((item, i)=>element('li', {
511
+ 'data-marker': v.ordered ? String(Number(v.start) + i) + '. ' : '• '
512
+ }, item.task ? item.checked ? '[x] ' : '[ ] ' : '', ...children(item.tokens))))
513
+ ];
514
+ }
515
+ case 'link':
516
+ {
517
+ let v = t;
518
+ if (named(v.href)) return ref(v.href, ...children(v.tokens));
519
+ if (flat) return children(v.tokens);
520
+ return [
521
+ element('a', {
522
+ href: safeHref(v.href),
523
+ title: v.title || undefined
524
+ }, ...children(v.tokens))
525
+ ];
526
+ }
527
+ case 'image':
528
+ {
529
+ let v = t;
530
+ if (flat) return [
531
+ v.text
532
+ ];
533
+ return [
534
+ element('a', {
535
+ href: safeHref(v.href),
536
+ title: v.title || undefined
537
+ }, v.text || '[image]')
538
+ ];
539
+ }
540
+ case 'table':
541
+ {
542
+ let v = t;
543
+ return [
544
+ element('table', null, element('thead', null, element('tr', null, ...v.header.map((cell, col)=>element('th', {
545
+ align: v.align[col] ?? undefined
546
+ }, ...children(cell.tokens))))), element('tbody', null, ...v.rows.map((row)=>element('tr', null, ...row.map((cell, col)=>element('td', {
547
+ align: v.align[col] ?? undefined
548
+ }, ...children(cell.tokens)))))))
549
+ ];
550
+ }
551
+ case 'text':
552
+ {
553
+ // A soft line break, kept as a newline when `breaks` is off, is a
554
+ // space in Markdown. Left as a newline, a terminal would break the
555
+ // line there, and a renderer that joins wrapped rows would run its
556
+ // two words together.
557
+ let v = t;
558
+ return v.tokens ? children(v.tokens) : [
559
+ v.text.replace(/ *\n */g, ' ')
560
+ ];
561
+ }
562
+ case 'escape':
563
+ return [
564
+ t.text
565
+ ];
566
+ case 'html':
567
+ {
568
+ // Markup is text here, never markup. A comment is not even that: it
569
+ // is the author writing to whoever opens the file, which every other
570
+ // renderer drops and this one used to paint as words on the page.
571
+ let { text } = t;
572
+ return /^\s*<!--[\s\S]*-->\s*$/.test(text) ? [] : [
573
+ text
574
+ ];
575
+ }
576
+ default:
577
+ return [
578
+ t.raw
579
+ ];
580
+ }
581
+ };
582
+ return children(tokens);
583
+ };
584
+ /** Render the parsed tree through any @yaks/render host: its blocks, in the
585
+ * document's own element. */ export let render = (tokens, host, options)=>host('div', {
586
+ class: 'Markdown',
587
+ wrap: '1'
588
+ }, ...blocks(tokens, host, options));
589
+ //# sourceMappingURL=structural.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structural.js","sources":["./structural.ts"],"names":[],"mappings":"AAAA;;CAEC,GACD,SAAS,KAAK,EAAE,MAAM,EAAc,SAAS,iBAAwC;AACrF,SAAS,KAAK,EAAE,KAAK,EAAE,OAAO,wBAA6B;AAE3D,SAAS,IAAI,oBAA8B;AAqB3C,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,IAAI,OAAO;AACX,IAAI,KAAK,GAAG,QAAQ,oBAAoB,EAAE,KAAK,0BAA0B,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