@fuzdev/mdz 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -17
- package/README.md +6 -3
- package/dist/Mdz.svelte +8 -7
- package/dist/Mdz.svelte.d.ts.map +1 -1
- package/dist/MdzNodeView.svelte +74 -30
- package/dist/MdzNodeView.svelte.d.ts +1 -2
- 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 +3 -3
- package/dist/MdzStream.svelte.d.ts.map +1 -1
- package/dist/MdzStreamNodeView.svelte +79 -31
- package/dist/MdzStreamNodeView.svelte.d.ts +1 -2
- package/dist/MdzStreamNodeView.svelte.d.ts.map +1 -1
- package/dist/context_helpers.js +1 -1
- package/dist/mdz.d.ts +12 -1
- package/dist/mdz.d.ts.map +1 -1
- package/dist/mdz.js +1 -1
- package/dist/mdz_contexts.d.ts +33 -6
- package/dist/mdz_contexts.d.ts.map +1 -1
- package/dist/mdz_debug_work.d.ts.map +1 -1
- package/dist/mdz_helpers.d.ts +31 -3
- package/dist/mdz_helpers.d.ts.map +1 -1
- package/dist/mdz_helpers.js +104 -12
- package/dist/mdz_lexer.d.ts +3 -1
- package/dist/mdz_lexer.d.ts.map +1 -1
- package/dist/mdz_lexer.js +115 -31
- package/dist/mdz_opcodes.d.ts +3 -1
- 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 +25 -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.js +4 -4
- package/dist/mdz_stream_parser_link.d.ts.map +1 -1
- package/dist/mdz_stream_parser_link.js +83 -11
- package/dist/mdz_stream_parser_list.d.ts.map +1 -1
- package/dist/mdz_stream_parser_list.js +13 -7
- package/dist/mdz_stream_parser_state.d.ts.map +1 -1
- package/dist/mdz_stream_parser_state.js +7 -7
- package/dist/mdz_stream_parser_table.d.ts.map +1 -1
- package/dist/mdz_stream_parser_table.js +16 -9
- package/dist/mdz_stream_parser_text.js +2 -2
- package/dist/mdz_stream_parser_url.js +7 -7
- package/dist/mdz_stream_state.svelte.d.ts +3 -1
- package/dist/mdz_stream_state.svelte.d.ts.map +1 -1
- package/dist/mdz_stream_state.svelte.js +4 -0
- package/dist/mdz_to_svelte.d.ts +17 -4
- package/dist/mdz_to_svelte.d.ts.map +1 -1
- package/dist/mdz_to_svelte.js +22 -9
- package/dist/mdz_token_parser.d.ts.map +1 -1
- package/dist/mdz_token_parser.js +25 -11
- package/dist/svelte_preprocess_mdz.d.ts +6 -3
- package/dist/svelte_preprocess_mdz.d.ts.map +1 -1
- package/dist/svelte_preprocess_mdz.js +11 -11
- package/package.json +25 -40
- package/src/lib/context_helpers.ts +2 -2
- package/src/lib/mdz.ts +15 -3
- package/src/lib/mdz_contexts.ts +41 -11
- package/src/lib/mdz_debug_work.ts +1 -1
- package/src/lib/mdz_helpers.ts +164 -43
- package/src/lib/mdz_lexer.ts +173 -80
- package/src/lib/mdz_opcodes.ts +3 -1
- package/src/lib/mdz_opcodes_to_nodes.ts +40 -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 +18 -18
- package/src/lib/mdz_stream_parser_link.ts +88 -18
- package/src/lib/mdz_stream_parser_list.ts +31 -25
- package/src/lib/mdz_stream_parser_state.ts +27 -27
- package/src/lib/mdz_stream_parser_table.ts +38 -31
- package/src/lib/mdz_stream_parser_text.ts +3 -3
- package/src/lib/mdz_stream_parser_url.ts +11 -11
- package/src/lib/mdz_stream_state.svelte.ts +11 -8
- package/src/lib/mdz_to_svelte.ts +71 -27
- package/src/lib/mdz_token_parser.ts +52 -38
- package/src/lib/svelte_preprocess_mdz.ts +66 -60
- package/src/lib/tsdoc_mdz.ts +1 -1
package/dist/mdz_lexer.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import { mdz_is_url, mdz_is_safe_reference, is_letter, is_tag_name_char, is_word_char, is_valid_path_char, mdz_trim_url_punctuation, BACKTICK, ASTERISK, UNDERSCORE, TILDE, NEWLINE, HYPHEN, HASH, SPACE, LEFT_ANGLE, RIGHT_ANGLE, SLASH, PERIOD, LEFT_BRACKET, LEFT_PAREN, RIGHT_BRACKET, A_UPPER, Z_UPPER, ZERO, ONE, NINE, HR_HYPHEN_COUNT, MIN_CODEBLOCK_BACKTICKS, MAX_HEADING_LEVEL, MAX_INLINE_NESTING_DEPTH, MAX_LIST_NUMBER_DIGITS, match_url_prefix_case_insensitive, is_at_absolute_path, is_at_relative_path, is_line_whitespace, mdz_match_blockquote_prefix, mdz_blockquote_line_has_content, mdz_blockquote_strip_width, mdz_remap_segments, mdz_split_table_row, mdz_parse_table_delimiter, PIPE, TEXT_CLASS_BACKSLASH, TEXT_CLASS_NEWLINE, TEXT_CLASS_STOP, TEXT_CLASS_URL, TEXT_SCAN_CLASS
|
|
9
|
+
import { mdz_is_url, mdz_is_safe_reference, is_letter, is_tag_name_char, is_word_char, is_valid_path_char, mdz_trim_url_punctuation, BACKTICK, ASTERISK, UNDERSCORE, TILDE, NEWLINE, HYPHEN, HASH, SPACE, LEFT_ANGLE, RIGHT_ANGLE, SLASH, EQUALS, APOSTROPHE, DOUBLE_QUOTE, PERIOD, LEFT_BRACKET, LEFT_PAREN, RIGHT_BRACKET, A_UPPER, Z_UPPER, ZERO, ONE, NINE, HR_HYPHEN_COUNT, MIN_CODEBLOCK_BACKTICKS, MAX_HEADING_LEVEL, MAX_INLINE_NESTING_DEPTH, MAX_LIST_NUMBER_DIGITS, match_url_prefix_case_insensitive, is_at_absolute_path, is_at_relative_path, is_line_whitespace, mdz_match_blockquote_prefix, mdz_blockquote_line_has_content, mdz_blockquote_strip_width, mdz_remap_segments, mdz_split_table_row, mdz_parse_table_delimiter, PIPE, TEXT_CLASS_BACKSLASH, TEXT_CLASS_NEWLINE, TEXT_CLASS_STOP, TEXT_CLASS_URL, TEXT_SCAN_CLASS } from './mdz_helpers.js';
|
|
10
10
|
import { mdz_debug_work } from './mdz_debug_work.js';
|
|
11
11
|
//
|
|
12
12
|
// Lexer
|
|
@@ -261,7 +261,7 @@ export class MdzLexer {
|
|
|
261
261
|
type: 'heading_start',
|
|
262
262
|
level: hash_count,
|
|
263
263
|
start,
|
|
264
|
-
end: this.#index
|
|
264
|
+
end: this.#index // end of "## " prefix
|
|
265
265
|
});
|
|
266
266
|
// Find end-of-line to bound nested tokenizers (prevents tag scanner from scanning past heading)
|
|
267
267
|
let eol = this.#text.indexOf('\n', this.#index);
|
|
@@ -564,7 +564,12 @@ export class MdzLexer {
|
|
|
564
564
|
*/
|
|
565
565
|
#tokenize_item_table(first, marker_indent) {
|
|
566
566
|
const head = this.#match_item_table_head(first, marker_indent);
|
|
567
|
-
this.#tokens.push({
|
|
567
|
+
this.#tokens.push({
|
|
568
|
+
type: 'table_open',
|
|
569
|
+
align: head.align,
|
|
570
|
+
start: first,
|
|
571
|
+
end: head.header_end
|
|
572
|
+
});
|
|
568
573
|
this.#emit_table_row(head.header_cells, true, first, head.header_end);
|
|
569
574
|
this.#index = head.delim_end;
|
|
570
575
|
let table_end = head.delim_end;
|
|
@@ -774,7 +779,7 @@ export class MdzLexer {
|
|
|
774
779
|
start: i,
|
|
775
780
|
marker_end: after,
|
|
776
781
|
content_start: after,
|
|
777
|
-
empty: true
|
|
782
|
+
empty: true
|
|
778
783
|
};
|
|
779
784
|
}
|
|
780
785
|
if (this.#text.charCodeAt(after) !== SPACE)
|
|
@@ -803,7 +808,7 @@ export class MdzLexer {
|
|
|
803
808
|
start: i,
|
|
804
809
|
marker_end: after,
|
|
805
810
|
content_start: after,
|
|
806
|
-
empty: true
|
|
811
|
+
empty: true
|
|
807
812
|
};
|
|
808
813
|
}
|
|
809
814
|
if (this.#text.charCodeAt(after) !== SPACE)
|
|
@@ -843,7 +848,7 @@ export class MdzLexer {
|
|
|
843
848
|
type: 'list_open',
|
|
844
849
|
ordered: marker.ordered,
|
|
845
850
|
start: marker.start,
|
|
846
|
-
end: marker.start
|
|
851
|
+
end: marker.start
|
|
847
852
|
});
|
|
848
853
|
this.#list_item_open(marker);
|
|
849
854
|
levels.push({ indent, ordered: marker.ordered });
|
|
@@ -852,7 +857,12 @@ export class MdzLexer {
|
|
|
852
857
|
#list_item_open(marker) {
|
|
853
858
|
const end = marker.empty ? marker.marker_end : marker.content_start;
|
|
854
859
|
if (marker.ordered) {
|
|
855
|
-
this.#tokens.push({
|
|
860
|
+
this.#tokens.push({
|
|
861
|
+
type: 'list_item_open',
|
|
862
|
+
number: marker.number,
|
|
863
|
+
start: marker.start,
|
|
864
|
+
end
|
|
865
|
+
});
|
|
856
866
|
}
|
|
857
867
|
else {
|
|
858
868
|
this.#tokens.push({ type: 'list_item_open', start: marker.start, end });
|
|
@@ -1012,7 +1022,7 @@ export class MdzLexer {
|
|
|
1012
1022
|
: content_lines.join('\n');
|
|
1013
1023
|
return {
|
|
1014
1024
|
token: { type: 'codeblock', lang, content, start: first, end: m },
|
|
1015
|
-
end: m
|
|
1025
|
+
end: m
|
|
1016
1026
|
};
|
|
1017
1027
|
}
|
|
1018
1028
|
}
|
|
@@ -1034,7 +1044,7 @@ export class MdzLexer {
|
|
|
1034
1044
|
content = content.slice(0, -1);
|
|
1035
1045
|
return {
|
|
1036
1046
|
token: { type: 'codeblock', lang, content, start: first, end: this.#text.length },
|
|
1037
|
-
end: this.#text.length
|
|
1047
|
+
end: this.#text.length
|
|
1038
1048
|
};
|
|
1039
1049
|
}
|
|
1040
1050
|
/**
|
|
@@ -1244,7 +1254,7 @@ export class MdzLexer {
|
|
|
1244
1254
|
this.#tokens.push({
|
|
1245
1255
|
type: 'italic_close',
|
|
1246
1256
|
start: close_index,
|
|
1247
|
-
end: close_index + 1
|
|
1257
|
+
end: close_index + 1
|
|
1248
1258
|
});
|
|
1249
1259
|
this.#index = close_index + 1;
|
|
1250
1260
|
}
|
|
@@ -1254,7 +1264,7 @@ export class MdzLexer {
|
|
|
1254
1264
|
type: 'text',
|
|
1255
1265
|
content: '_',
|
|
1256
1266
|
start,
|
|
1257
|
-
end: start + 1
|
|
1267
|
+
end: start + 1
|
|
1258
1268
|
};
|
|
1259
1269
|
}
|
|
1260
1270
|
}
|
|
@@ -1303,7 +1313,7 @@ export class MdzLexer {
|
|
|
1303
1313
|
this.#tokens.push({
|
|
1304
1314
|
type: 'link_text_close',
|
|
1305
1315
|
start: bracket_close_start,
|
|
1306
|
-
end: this.#index
|
|
1316
|
+
end: this.#index
|
|
1307
1317
|
});
|
|
1308
1318
|
// Check for (
|
|
1309
1319
|
if (this.#index >= this.#text.length || this.#text.charCodeAt(this.#index) !== LEFT_PAREN) {
|
|
@@ -1344,7 +1354,7 @@ export class MdzLexer {
|
|
|
1344
1354
|
reference,
|
|
1345
1355
|
link_type,
|
|
1346
1356
|
start: bracket_close_start + 1, // after ]
|
|
1347
|
-
end: this.#index
|
|
1357
|
+
end: this.#index
|
|
1348
1358
|
});
|
|
1349
1359
|
}
|
|
1350
1360
|
#revert_tokens_from_link_open(start) {
|
|
@@ -1411,9 +1421,75 @@ export class MdzLexer {
|
|
|
1411
1421
|
const tag_name = this.#text.slice(tag_name_start, this.#index);
|
|
1412
1422
|
const first_char_code = tag_name.charCodeAt(0);
|
|
1413
1423
|
const is_component = first_char_code >= A_UPPER && first_char_code <= Z_UPPER;
|
|
1414
|
-
//
|
|
1415
|
-
|
|
1416
|
-
|
|
1424
|
+
// Attribute loop: consume space-separated attributes until `/>` or `>`.
|
|
1425
|
+
// Registry-blind — every syntactically valid attribute is parsed here;
|
|
1426
|
+
// policy (allowlist filtering) happens at render/build time. The scan is
|
|
1427
|
+
// a single forward pass bounded by the line: any newline (or a missing
|
|
1428
|
+
// separator, bad value, or duplicate name) rejects the whole tag to
|
|
1429
|
+
// literal text via the shared `#reject_tag` bailout.
|
|
1430
|
+
const attributes = [];
|
|
1431
|
+
const seen = new Set(); // O(1) duplicate-name detection
|
|
1432
|
+
for (;;) {
|
|
1433
|
+
// skip a run of literal spaces only (tabs/newlines are not SPACE, so
|
|
1434
|
+
// they fall through to the reject path — the single-line, space-only rule)
|
|
1435
|
+
let had_space = false;
|
|
1436
|
+
while (this.#index < this.#text.length && this.#text.charCodeAt(this.#index) === SPACE) {
|
|
1437
|
+
this.#index++;
|
|
1438
|
+
had_space = true;
|
|
1439
|
+
}
|
|
1440
|
+
const c = this.#index < this.#text.length ? this.#text.charCodeAt(this.#index) : -1;
|
|
1441
|
+
// `/>` or `>` ends the open tag — break to the existing self-close / commit
|
|
1442
|
+
if (c === SLASH || c === RIGHT_ANGLE)
|
|
1443
|
+
break;
|
|
1444
|
+
// otherwise an attribute name must follow, space-separated from what
|
|
1445
|
+
// precedes it (`<a x="1"y="2">` rejects — `y` abuts the closing quote)
|
|
1446
|
+
if (c === -1 || !had_space || !is_letter(c)) {
|
|
1447
|
+
this.#reject_tag(start, bound);
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
// collect the attribute name (same grammar as tag names)
|
|
1451
|
+
const attr_start = this.#index;
|
|
1452
|
+
this.#index++; // first char already passed is_letter
|
|
1453
|
+
while (this.#index < this.#text.length &&
|
|
1454
|
+
is_tag_name_char(this.#text.charCodeAt(this.#index))) {
|
|
1455
|
+
this.#index++;
|
|
1456
|
+
}
|
|
1457
|
+
const name = this.#text.slice(attr_start, this.#index);
|
|
1458
|
+
// duplicate names are ambiguous (Svelte compile-errors) → literal tag
|
|
1459
|
+
if (seen.has(name)) {
|
|
1460
|
+
this.#reject_tag(start, bound);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
seen.add(name);
|
|
1464
|
+
let value = true; // bare name is boolean `true`
|
|
1465
|
+
if (this.#index < this.#text.length && this.#text.charCodeAt(this.#index) === EQUALS) {
|
|
1466
|
+
this.#index++; // consume =
|
|
1467
|
+
// the value must be immediately quoted — no space after `=`, no
|
|
1468
|
+
// `{` brace literal, no unquoted value (this one check covers all)
|
|
1469
|
+
const quote = this.#index < this.#text.length ? this.#text.charCodeAt(this.#index) : -1;
|
|
1470
|
+
if (quote !== DOUBLE_QUOTE && quote !== APOSTROPHE) {
|
|
1471
|
+
this.#reject_tag(start, bound);
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
this.#index++; // consume opening quote
|
|
1475
|
+
const value_start = this.#index;
|
|
1476
|
+
// scan to the matching quote, bounded by newline / text end — NOT
|
|
1477
|
+
// by `#max_search_index` (the open-tag scan never is); a `>` inside
|
|
1478
|
+
// the value is content, consumed atomically before `>` is sought
|
|
1479
|
+
while (this.#index < this.#text.length &&
|
|
1480
|
+
this.#text.charCodeAt(this.#index) !== quote &&
|
|
1481
|
+
this.#text.charCodeAt(this.#index) !== NEWLINE) {
|
|
1482
|
+
this.#index++;
|
|
1483
|
+
}
|
|
1484
|
+
if (this.#index >= this.#text.length || this.#text.charCodeAt(this.#index) === NEWLINE) {
|
|
1485
|
+
// unterminated quote (or newline inside the value) → literal tag
|
|
1486
|
+
this.#reject_tag(start, bound);
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
value = this.#text.slice(value_start, this.#index);
|
|
1490
|
+
this.#index++; // consume closing quote
|
|
1491
|
+
}
|
|
1492
|
+
attributes.push({ name, value, start: attr_start, end: this.#index });
|
|
1417
1493
|
}
|
|
1418
1494
|
// Check for self-closing />
|
|
1419
1495
|
if (this.#index + 1 < this.#text.length &&
|
|
@@ -1424,16 +1500,15 @@ export class MdzLexer {
|
|
|
1424
1500
|
type: 'tag_self_close',
|
|
1425
1501
|
name: tag_name,
|
|
1426
1502
|
is_component,
|
|
1503
|
+
attributes,
|
|
1427
1504
|
start,
|
|
1428
|
-
end: this.#index
|
|
1505
|
+
end: this.#index
|
|
1429
1506
|
});
|
|
1430
1507
|
return;
|
|
1431
1508
|
}
|
|
1432
1509
|
// Check for >
|
|
1433
1510
|
if (this.#index >= this.#text.length || this.#text.charCodeAt(this.#index) !== RIGHT_ANGLE) {
|
|
1434
|
-
this.#
|
|
1435
|
-
this.#index = start + 1;
|
|
1436
|
-
this.#emit_text('<', start);
|
|
1511
|
+
this.#reject_tag(start, bound);
|
|
1437
1512
|
return;
|
|
1438
1513
|
}
|
|
1439
1514
|
this.#index++; // consume >
|
|
@@ -1449,20 +1524,23 @@ export class MdzLexer {
|
|
|
1449
1524
|
const search_limit = Math.min(this.#max_search_index, this.#text.length);
|
|
1450
1525
|
const closing_tag_pos = this.#index_of(closing_tag, this.#index);
|
|
1451
1526
|
if (closing_tag_pos === -1 || closing_tag_pos > search_limit) {
|
|
1452
|
-
this.#
|
|
1453
|
-
this.#index = start + 1;
|
|
1454
|
-
this.#emit_text('<', start);
|
|
1527
|
+
this.#reject_tag(start, bound);
|
|
1455
1528
|
return;
|
|
1456
1529
|
}
|
|
1457
1530
|
if (this.#has_paragraph_break_between(this.#index, closing_tag_pos)) {
|
|
1458
|
-
this.#
|
|
1459
|
-
this.#index = start + 1;
|
|
1460
|
-
this.#emit_text('<', start);
|
|
1531
|
+
this.#reject_tag(start, bound);
|
|
1461
1532
|
return;
|
|
1462
1533
|
}
|
|
1463
1534
|
// Emit tag_open
|
|
1464
1535
|
const open_token_index = this.#tokens.length;
|
|
1465
|
-
this.#tokens.push({
|
|
1536
|
+
this.#tokens.push({
|
|
1537
|
+
type: 'tag_open',
|
|
1538
|
+
name: tag_name,
|
|
1539
|
+
is_component,
|
|
1540
|
+
attributes,
|
|
1541
|
+
start,
|
|
1542
|
+
end: this.#index
|
|
1543
|
+
});
|
|
1466
1544
|
// Tokenize children until the closing tag. Each iteration narrows
|
|
1467
1545
|
// `#max_search_index` to the next closer so a child's delimiter scan
|
|
1468
1546
|
// can never cross it (`` <b>`a</b>x` `` must not swallow `</b>` into
|
|
@@ -1480,7 +1558,7 @@ export class MdzLexer {
|
|
|
1480
1558
|
type: 'tag_close',
|
|
1481
1559
|
name: tag_name,
|
|
1482
1560
|
start: close_start,
|
|
1483
|
-
end: this.#index
|
|
1561
|
+
end: this.#index
|
|
1484
1562
|
});
|
|
1485
1563
|
return;
|
|
1486
1564
|
}
|
|
@@ -1499,8 +1577,14 @@ export class MdzLexer {
|
|
|
1499
1577
|
// (the `#revert_tokens_from_link_open` pattern; the old fallthrough
|
|
1500
1578
|
// left a dangling `tag_open` whose parser fallback discarded content)
|
|
1501
1579
|
this.#max_search_index = saved_max;
|
|
1502
|
-
this.#failed_tag.add(`${start}:${bound}`);
|
|
1503
1580
|
this.#tokens.splice(open_token_index);
|
|
1581
|
+
this.#reject_tag(start, bound);
|
|
1582
|
+
}
|
|
1583
|
+
// a tag open at `start` that can't commit: memoizes the failure for this
|
|
1584
|
+
// `bound` so re-entries bail fast, then emits the `<` as text and resumes
|
|
1585
|
+
// scanning after it — the rest re-parses as ordinary content
|
|
1586
|
+
#reject_tag(start, bound) {
|
|
1587
|
+
this.#failed_tag.add(`${start}:${bound}`);
|
|
1504
1588
|
this.#index = start + 1;
|
|
1505
1589
|
this.#emit_text('<', start);
|
|
1506
1590
|
}
|
|
@@ -1644,7 +1728,7 @@ export class MdzLexer {
|
|
|
1644
1728
|
reference,
|
|
1645
1729
|
link_type: 'external',
|
|
1646
1730
|
start,
|
|
1647
|
-
end: this.#index
|
|
1731
|
+
end: this.#index
|
|
1648
1732
|
});
|
|
1649
1733
|
}
|
|
1650
1734
|
#tokenize_auto_link_internal() {
|
|
@@ -1665,7 +1749,7 @@ export class MdzLexer {
|
|
|
1665
1749
|
reference,
|
|
1666
1750
|
link_type: 'internal',
|
|
1667
1751
|
start,
|
|
1668
|
-
end: this.#index
|
|
1752
|
+
end: this.#index
|
|
1669
1753
|
});
|
|
1670
1754
|
}
|
|
1671
1755
|
// -- Helper methods --
|
package/dist/mdz_opcodes.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import type { MdzTableAlign } from './mdz.js';
|
|
14
|
+
import type { MdzAttribute, MdzTableAlign } from './mdz.js';
|
|
15
15
|
/**
|
|
16
16
|
* Unique monotonic identifier for each node created by the parser.
|
|
17
17
|
* IDs are never reused within a parser instance.
|
|
@@ -44,6 +44,8 @@ export interface MdzOpcodeOpen {
|
|
|
44
44
|
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
45
45
|
/** Tag name. Present when `node_type` is `'Element'` or `'Component'`. */
|
|
46
46
|
name?: string;
|
|
47
|
+
/** Parsed attributes. Present (possibly empty) when `node_type` is `'Element'` or `'Component'`. */
|
|
48
|
+
attributes?: Array<MdzAttribute>;
|
|
47
49
|
/** Language hint. Present when `node_type` is `'Codeblock'`. */
|
|
48
50
|
lang?: string | null;
|
|
49
51
|
/** Whether the list is ordered. Present when `node_type` is `'List'`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_opcodes.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_opcodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mdz_opcodes.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_opcodes.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_opcodes_to_nodes.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_opcodes_to_nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mdz_opcodes_to_nodes.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_opcodes_to_nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAEX,OAAO,EASP,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,kBAAkB,CAAC;AA0B7D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,OAAO,CAiM7E,CAAC"}
|
|
@@ -39,12 +39,13 @@ export const mdz_opcodes_to_nodes = (opcodes) => {
|
|
|
39
39
|
start: op.start,
|
|
40
40
|
level: op.level,
|
|
41
41
|
name: op.name,
|
|
42
|
+
attributes: op.attributes,
|
|
42
43
|
lang: op.lang,
|
|
43
44
|
ordered: op.ordered,
|
|
44
45
|
start_number: op.start_number,
|
|
45
46
|
number: op.number,
|
|
46
47
|
align: op.align,
|
|
47
|
-
header: op.header
|
|
48
|
+
header: op.header
|
|
48
49
|
});
|
|
49
50
|
break;
|
|
50
51
|
}
|
|
@@ -180,7 +181,7 @@ export const mdz_opcodes_to_nodes = (opcodes) => {
|
|
|
180
181
|
type: 'Text',
|
|
181
182
|
content: trimmed_content,
|
|
182
183
|
start: text_node.end,
|
|
183
|
-
end: text_node.end + trimmed_content.length
|
|
184
|
+
end: text_node.end + trimmed_content.length
|
|
184
185
|
};
|
|
185
186
|
text_nodes.set(op.trim_id, trimmed_node);
|
|
186
187
|
}
|
|
@@ -191,7 +192,7 @@ export const mdz_opcodes_to_nodes = (opcodes) => {
|
|
|
191
192
|
children: [text_node],
|
|
192
193
|
link_type: op.link_type,
|
|
193
194
|
start: op.start,
|
|
194
|
-
end: op.end
|
|
195
|
+
end: op.end
|
|
195
196
|
};
|
|
196
197
|
// replace text node with [Link, trimmed?] in the buffer
|
|
197
198
|
if (trimmed_node) {
|
|
@@ -250,7 +251,12 @@ const insert_replacement = (children, stack, reverted_idx, at, op) => {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
// 3. standalone Text node
|
|
253
|
-
const node = {
|
|
254
|
+
const node = {
|
|
255
|
+
type: 'Text',
|
|
256
|
+
content: text,
|
|
257
|
+
start: op.start,
|
|
258
|
+
end: op.start + text.length
|
|
259
|
+
};
|
|
254
260
|
if (at >= children.length) {
|
|
255
261
|
children.push(node);
|
|
256
262
|
}
|
|
@@ -284,7 +290,7 @@ const build_node = (frame, frame_children) => {
|
|
|
284
290
|
type: 'Paragraph',
|
|
285
291
|
children,
|
|
286
292
|
start: children[0].start,
|
|
287
|
-
end: children[children.length - 1].end
|
|
293
|
+
end: children[children.length - 1].end
|
|
288
294
|
};
|
|
289
295
|
}
|
|
290
296
|
case 'Heading': {
|
|
@@ -296,7 +302,7 @@ const build_node = (frame, frame_children) => {
|
|
|
296
302
|
id,
|
|
297
303
|
children,
|
|
298
304
|
start: frame.start,
|
|
299
|
-
end: frame.end
|
|
305
|
+
end: frame.end
|
|
300
306
|
};
|
|
301
307
|
}
|
|
302
308
|
case 'Bold':
|
|
@@ -304,21 +310,21 @@ const build_node = (frame, frame_children) => {
|
|
|
304
310
|
type: 'Bold',
|
|
305
311
|
children: mdz_merge_adjacent_text(frame_children),
|
|
306
312
|
start: frame.start,
|
|
307
|
-
end: frame.end
|
|
313
|
+
end: frame.end
|
|
308
314
|
};
|
|
309
315
|
case 'Italic':
|
|
310
316
|
return {
|
|
311
317
|
type: 'Italic',
|
|
312
318
|
children: mdz_merge_adjacent_text(frame_children),
|
|
313
319
|
start: frame.start,
|
|
314
|
-
end: frame.end
|
|
320
|
+
end: frame.end
|
|
315
321
|
};
|
|
316
322
|
case 'Strikethrough':
|
|
317
323
|
return {
|
|
318
324
|
type: 'Strikethrough',
|
|
319
325
|
children: mdz_merge_adjacent_text(frame_children),
|
|
320
326
|
start: frame.start,
|
|
321
|
-
end: frame.end
|
|
327
|
+
end: frame.end
|
|
322
328
|
};
|
|
323
329
|
case 'Link':
|
|
324
330
|
return {
|
|
@@ -327,7 +333,7 @@ const build_node = (frame, frame_children) => {
|
|
|
327
333
|
children: mdz_merge_adjacent_text(frame_children),
|
|
328
334
|
link_type: frame.link_type ?? 'internal',
|
|
329
335
|
start: frame.start,
|
|
330
|
-
end: frame.end
|
|
336
|
+
end: frame.end
|
|
331
337
|
};
|
|
332
338
|
case 'List': {
|
|
333
339
|
// items are the only possible children; `end` derives from the last
|
|
@@ -341,7 +347,7 @@ const build_node = (frame, frame_children) => {
|
|
|
341
347
|
start_number: frame.start_number ?? 1,
|
|
342
348
|
children,
|
|
343
349
|
start: frame.start,
|
|
344
|
-
end
|
|
350
|
+
end
|
|
345
351
|
};
|
|
346
352
|
}
|
|
347
353
|
return { type: 'List', ordered: false, children, start: frame.start, end };
|
|
@@ -375,7 +381,7 @@ const build_node = (frame, frame_children) => {
|
|
|
375
381
|
header: frame.header ?? false,
|
|
376
382
|
children,
|
|
377
383
|
start: frame.start,
|
|
378
|
-
end: frame.end
|
|
384
|
+
end: frame.end
|
|
379
385
|
};
|
|
380
386
|
}
|
|
381
387
|
case 'TableCell':
|
|
@@ -383,7 +389,7 @@ const build_node = (frame, frame_children) => {
|
|
|
383
389
|
type: 'TableCell',
|
|
384
390
|
children: mdz_merge_adjacent_text(frame_children),
|
|
385
391
|
start: frame.start,
|
|
386
|
-
end: frame.end
|
|
392
|
+
end: frame.end
|
|
387
393
|
};
|
|
388
394
|
case 'Code': {
|
|
389
395
|
// optimistic inline code container — concatenate children text into leaf MdzNodeCode
|
|
@@ -396,7 +402,7 @@ const build_node = (frame, frame_children) => {
|
|
|
396
402
|
type: 'Code',
|
|
397
403
|
content,
|
|
398
404
|
start: frame.start,
|
|
399
|
-
end: frame.end
|
|
405
|
+
end: frame.end
|
|
400
406
|
};
|
|
401
407
|
}
|
|
402
408
|
case 'Codeblock': {
|
|
@@ -411,24 +417,26 @@ const build_node = (frame, frame_children) => {
|
|
|
411
417
|
lang: frame.lang ?? null,
|
|
412
418
|
content,
|
|
413
419
|
start: frame.start,
|
|
414
|
-
end: frame.end
|
|
420
|
+
end: frame.end
|
|
415
421
|
};
|
|
416
422
|
}
|
|
417
423
|
case 'Element':
|
|
418
424
|
return {
|
|
419
425
|
type: 'Element',
|
|
420
426
|
name: frame.name ?? '',
|
|
427
|
+
attributes: frame.attributes ?? [],
|
|
421
428
|
children: mdz_merge_adjacent_text(frame_children),
|
|
422
429
|
start: frame.start,
|
|
423
|
-
end: frame.end
|
|
430
|
+
end: frame.end
|
|
424
431
|
};
|
|
425
432
|
case 'Component':
|
|
426
433
|
return {
|
|
427
434
|
type: 'Component',
|
|
428
435
|
name: frame.name ?? '',
|
|
436
|
+
attributes: frame.attributes ?? [],
|
|
429
437
|
children: mdz_merge_adjacent_text(frame_children),
|
|
430
438
|
start: frame.start,
|
|
431
|
-
end: frame.end
|
|
439
|
+
end: frame.end
|
|
432
440
|
};
|
|
433
441
|
default:
|
|
434
442
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_stream_parser.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mdz_stream_parser.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiFlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,eAAe;;IAG3B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,YAAY,IAAI,KAAK,CAAC,SAAS,CAAC;CAKhC"}
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
*
|
|
35
35
|
* @module
|
|
36
36
|
*/
|
|
37
|
-
import { BACKTICK, ASTERISK, UNDERSCORE, TILDE, NEWLINE, HYPHEN, HASH, PIPE, LEFT_ANGLE, RIGHT_ANGLE, SLASH, LEFT_BRACKET, RIGHT_BRACKET, H_LOWER, H_UPPER, PERIOD, SPACE, ZERO, NINE, is_word_char, is_line_whitespace, mdz_match_blockquote_prefix, mdz_blockquote_line_has_content, mdz_blockquote_strip_width, mdz_remap_segments
|
|
38
|
-
import { accumulate_text, alloc_id, close_all_list_levels, close_codeblock_at_eof, close_heading, close_paragraph, create_state, emit, find_open, flush_text, handle_paragraph_break, offset, pop_stack_entry, push_stack_entry, revert_failed_close
|
|
39
|
-
import { process_codeblock, process_codeblock_forced, process_codeblock_in_item, try_codeblock_open, try_heading, try_hr
|
|
37
|
+
import { BACKTICK, ASTERISK, UNDERSCORE, TILDE, NEWLINE, HYPHEN, HASH, PIPE, LEFT_ANGLE, RIGHT_ANGLE, SLASH, LEFT_BRACKET, RIGHT_BRACKET, H_LOWER, H_UPPER, PERIOD, SPACE, ZERO, NINE, is_word_char, is_line_whitespace, mdz_match_blockquote_prefix, mdz_blockquote_line_has_content, mdz_blockquote_strip_width, mdz_remap_segments } from './mdz_helpers.js';
|
|
38
|
+
import { accumulate_text, alloc_id, close_all_list_levels, close_codeblock_at_eof, close_heading, close_paragraph, create_state, emit, find_open, flush_text, handle_paragraph_break, offset, pop_stack_entry, push_stack_entry, revert_failed_close } from './mdz_stream_parser_state.js';
|
|
39
|
+
import { process_codeblock, process_codeblock_forced, process_codeblock_in_item, try_codeblock_open, try_heading, try_hr } from './mdz_stream_parser_block.js';
|
|
40
40
|
import { process_list_line, try_list_start } from './mdz_stream_parser_list.js';
|
|
41
41
|
import { close_table, process_table_line, try_table_start } from './mdz_stream_parser_table.js';
|
|
42
|
-
import { check_close_word_boundary, close_delimiter, process_code_content, try_code, try_double_delimiter, try_italic
|
|
43
|
-
import { try_close_tag, try_complete_link, try_link_open, try_tag_open
|
|
44
|
-
import { complete_pending_url, process_url_content, start_speculative_url, try_auto_path_absolute, try_auto_path_relative, try_auto_url_forced
|
|
42
|
+
import { check_close_word_boundary, close_delimiter, process_code_content, try_code, try_double_delimiter, try_italic } from './mdz_stream_parser_inline.js';
|
|
43
|
+
import { try_close_tag, try_complete_link, try_link_open, try_tag_open } from './mdz_stream_parser_link.js';
|
|
44
|
+
import { complete_pending_url, process_url_content, start_speculative_url, try_auto_path_absolute, try_auto_path_relative, try_auto_url_forced } from './mdz_stream_parser_url.js';
|
|
45
45
|
import { consume_delimiter_as_text, consume_text_run } from './mdz_stream_parser_text.js';
|
|
46
46
|
/**
|
|
47
47
|
* Streaming opcode parser for mdz content.
|
|
@@ -207,7 +207,7 @@ const open_blockquote = (state, item_indent) => {
|
|
|
207
207
|
segments: [{ inner_start: 0, source_start: offset(state, strip) }],
|
|
208
208
|
inner_len: 0,
|
|
209
209
|
text_inner_ends: new Map(),
|
|
210
|
-
item_indent
|
|
210
|
+
item_indent
|
|
211
211
|
};
|
|
212
212
|
state.pos = strip;
|
|
213
213
|
state.prev_char = SPACE;
|
|
@@ -361,7 +361,7 @@ const process_blockquote = (state, forced) => {
|
|
|
361
361
|
const strip = first + mdz_blockquote_strip_width(buffer, first);
|
|
362
362
|
blockquote.segments.push({
|
|
363
363
|
inner_start: blockquote.inner_len,
|
|
364
|
-
source_start: offset(state, strip)
|
|
364
|
+
source_start: offset(state, strip)
|
|
365
365
|
});
|
|
366
366
|
state.pos = strip;
|
|
367
367
|
state.column = strip - line_start;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import { BACKTICK, HASH, HR_HYPHEN_COUNT, HYPHEN, MAX_HEADING_LEVEL, MIN_CODEBLOCK_BACKTICKS, NEWLINE, SPACE, is_line_whitespace
|
|
10
|
-
import { alloc_id, close_paragraph, emit, flush_text, offset, push_stack_entry
|
|
9
|
+
import { BACKTICK, HASH, HR_HYPHEN_COUNT, HYPHEN, MAX_HEADING_LEVEL, MIN_CODEBLOCK_BACKTICKS, NEWLINE, SPACE, is_line_whitespace } from './mdz_helpers.js';
|
|
10
|
+
import { alloc_id, close_paragraph, emit, flush_text, offset, push_stack_entry } from './mdz_stream_parser_state.js';
|
|
11
11
|
/**
|
|
12
12
|
* Try to parse a heading at column 0.
|
|
13
13
|
*
|
|
@@ -55,7 +55,7 @@ export const try_heading = (state) => {
|
|
|
55
55
|
id,
|
|
56
56
|
node_type: 'Heading',
|
|
57
57
|
start: heading_start,
|
|
58
|
-
level: hash_count
|
|
58
|
+
level: hash_count
|
|
59
59
|
});
|
|
60
60
|
push_stack_entry(state, id, 'Heading', heading_start);
|
|
61
61
|
state.in_heading = true;
|
|
@@ -103,7 +103,7 @@ export const try_hr = (state, forced = false) => {
|
|
|
103
103
|
id,
|
|
104
104
|
node_type: 'Hr',
|
|
105
105
|
start: offset(state, start),
|
|
106
|
-
end: offset(state, i)
|
|
106
|
+
end: offset(state, i)
|
|
107
107
|
});
|
|
108
108
|
// `i` sits at the line's newline, or at the buffer end — in forced mode
|
|
109
109
|
// always the buffer end (a newline would have resolved this line during
|
|
@@ -193,7 +193,7 @@ export const emit_codeblock_text = (state, cb, content, content_start) => {
|
|
|
193
193
|
content,
|
|
194
194
|
text_type: 'Text',
|
|
195
195
|
start: text_start,
|
|
196
|
-
end: text_start + content.length
|
|
196
|
+
end: text_start + content.length
|
|
197
197
|
});
|
|
198
198
|
cb.text_id = id;
|
|
199
199
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import { BACKTICK, NEWLINE, RIGHT_ANGLE, UNDERSCORE, is_line_whitespace, is_word_char, mdz_blockquote_line_has_content, mdz_match_blockquote_prefix
|
|
8
|
-
import { accumulate_text, alloc_id, buffer_index_of, emit, ensure_paragraph, flush_text, is_run_boundary, offset, pop_stack_entry, push_stack_entry, revert_above
|
|
7
|
+
import { BACKTICK, NEWLINE, RIGHT_ANGLE, UNDERSCORE, is_line_whitespace, is_word_char, mdz_blockquote_line_has_content, mdz_match_blockquote_prefix } from './mdz_helpers.js';
|
|
8
|
+
import { accumulate_text, alloc_id, buffer_index_of, emit, ensure_paragraph, flush_text, is_run_boundary, offset, pop_stack_entry, push_stack_entry, revert_above } from './mdz_stream_parser_state.js';
|
|
9
9
|
import { match_fence_opener, match_list_marker } from './mdz_stream_parser_list.js';
|
|
10
10
|
import { consume_delimiter_as_text } from './mdz_stream_parser_text.js';
|
|
11
11
|
/**
|
|
@@ -236,7 +236,7 @@ export const close_delimiter = (state, stack_idx) => {
|
|
|
236
236
|
type: 'revert',
|
|
237
237
|
id: entry.id,
|
|
238
238
|
replacement_text: delimiter,
|
|
239
|
-
start: entry.start
|
|
239
|
+
start: entry.start
|
|
240
240
|
});
|
|
241
241
|
accumulate_text(state, delimiter, offset(state));
|
|
242
242
|
}
|
|
@@ -325,7 +325,7 @@ export const try_code = (state, forced = false) => {
|
|
|
325
325
|
content,
|
|
326
326
|
text_type: 'Code',
|
|
327
327
|
start: offset(state, start),
|
|
328
|
-
end: offset(state, terminator + 1)
|
|
328
|
+
end: offset(state, terminator + 1)
|
|
329
329
|
});
|
|
330
330
|
state.active_text_id = null;
|
|
331
331
|
state.pos = terminator + 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdz_stream_parser_link.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_parser_link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"mdz_stream_parser_link.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_parser_link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwBH,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,SAAS,EAYd,MAAM,8BAA8B,CAAC;AAMtC,cAAc;AACd,eAAO,MAAM,aAAa,GAAI,OAAO,oBAAoB,KAAG,OAoB3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC9B,OAAO,oBAAoB,EAC3B,gBAAgB,MAAM,EACtB,aAAa,MAAM,KACjB,IAUF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,oBAAoB,EAAE,gBAAgB,MAAM,KAAG,OA4EvF,CAAC;AAIF,cAAc;AACd,eAAO,MAAM,YAAY,GAAI,OAAO,oBAAoB,KAAG,SAuJ1D,CAAC;AAEF,cAAc;AACd,eAAO,MAAM,aAAa,GAAI,OAAO,oBAAoB,KAAG,SAiD3D,CAAC"}
|