@the_dissidents/libemmm 0.0.7 → 0.0.8
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/dist/index.d.mts +58 -32
- package/dist/index.d.ts +58 -32
- package/dist/index.js +332 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +331 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
SystemModifierDefinition: () => SystemModifierDefinition,
|
|
42
42
|
debugPrint: () => debugPrint,
|
|
43
43
|
emmmVersion: () => emmmVersion,
|
|
44
|
+
helper: () => modifier_helper_exports,
|
|
44
45
|
messages: () => messages_exports,
|
|
45
46
|
parse: () => parse,
|
|
46
47
|
setDebugLevel: () => setDebugLevel
|
|
@@ -78,6 +79,9 @@ var ModifierBase = class {
|
|
|
78
79
|
this.slotType = slotType;
|
|
79
80
|
if (args) Object.assign(this, args);
|
|
80
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Common values: heading, emphasis, keyword, highlight, commentary, comment, link, quote
|
|
84
|
+
*/
|
|
81
85
|
roleHint;
|
|
82
86
|
/**
|
|
83
87
|
* If true, any modifier encountered inside it will *not* be expanded *during parse-content*,
|
|
@@ -87,7 +91,7 @@ var ModifierBase = class {
|
|
|
87
91
|
delayContentExpansion = false;
|
|
88
92
|
/**
|
|
89
93
|
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
90
|
-
* contained in a modifier with `delayContentExpansion`. In the vast majority of cases,
|
|
94
|
+
* it is contained in a modifier with `delayContentExpansion`. In the vast majority of cases,
|
|
91
95
|
* you shouldn't be using this.
|
|
92
96
|
*/
|
|
93
97
|
alwaysTryExpand = false;
|
|
@@ -341,14 +345,14 @@ var StringSource = class {
|
|
|
341
345
|
}
|
|
342
346
|
return [line, pos - linepos];
|
|
343
347
|
}
|
|
344
|
-
|
|
348
|
+
getRowStart(n) {
|
|
345
349
|
assert(n >= 0);
|
|
346
350
|
if (n >= this.lineMap.length) return Infinity;
|
|
347
351
|
return this.lineMap[n];
|
|
348
352
|
}
|
|
349
|
-
|
|
350
|
-
const start = this.
|
|
351
|
-
const end = this.
|
|
353
|
+
getRow(n) {
|
|
354
|
+
const start = this.getRowStart(n);
|
|
355
|
+
const end = this.getRowStart(n + 1);
|
|
352
356
|
if (start === Infinity) return void 0;
|
|
353
357
|
return this.src.substring(start, end - 1);
|
|
354
358
|
}
|
|
@@ -482,7 +486,7 @@ function debugPrintRange(loc, context = 1) {
|
|
|
482
486
|
const endLine = Math.min(loc.source.nLines - 1, er + context);
|
|
483
487
|
let lines = [];
|
|
484
488
|
for (let i = startLine; i <= endLine; i++) {
|
|
485
|
-
const line = loc.source.
|
|
489
|
+
const line = loc.source.getRow(i);
|
|
486
490
|
lines.push((i + 1).toString().padStart(rowWidth) + " | " + line);
|
|
487
491
|
if (i >= sr && i <= er) {
|
|
488
492
|
const startPos = i == sr ? sc : 0;
|
|
@@ -1021,6 +1025,7 @@ var Parser = class {
|
|
|
1021
1025
|
end: to ?? this.scanner.position()
|
|
1022
1026
|
};
|
|
1023
1027
|
}
|
|
1028
|
+
/* istanbul ignore next -- @preserve */
|
|
1024
1029
|
#defs(type) {
|
|
1025
1030
|
switch (type) {
|
|
1026
1031
|
case 5 /* SystemModifier */:
|
|
@@ -1554,9 +1559,9 @@ function parse(scanner, cxt) {
|
|
|
1554
1559
|
|
|
1555
1560
|
// src/renderer.ts
|
|
1556
1561
|
var RenderContext = class {
|
|
1557
|
-
constructor(config2,
|
|
1562
|
+
constructor(config2, parsedDocument, state) {
|
|
1558
1563
|
this.config = config2;
|
|
1559
|
-
this.
|
|
1564
|
+
this.parsedDocument = parsedDocument;
|
|
1560
1565
|
this.state = state;
|
|
1561
1566
|
}
|
|
1562
1567
|
renderEntity(node) {
|
|
@@ -1594,7 +1599,7 @@ var RenderConfiguration = class _RenderConfiguration {
|
|
|
1594
1599
|
blockRenderers = /* @__PURE__ */ new Map();
|
|
1595
1600
|
inlineRenderers = /* @__PURE__ */ new Map();
|
|
1596
1601
|
render(doc, state) {
|
|
1597
|
-
let cxt = new RenderContext(this, doc
|
|
1602
|
+
let cxt = new RenderContext(this, doc, state);
|
|
1598
1603
|
let results = doc.toStripped().root.content.map((x) => cxt.renderEntity(x)).filter((x) => x !== void 0);
|
|
1599
1604
|
return this.postprocessor(results, cxt);
|
|
1600
1605
|
}
|
|
@@ -1617,6 +1622,14 @@ var RenderConfiguration = class _RenderConfiguration {
|
|
|
1617
1622
|
};
|
|
1618
1623
|
|
|
1619
1624
|
// src/modifier-helper.ts
|
|
1625
|
+
var modifier_helper_exports = {};
|
|
1626
|
+
__export(modifier_helper_exports, {
|
|
1627
|
+
checkArgumentLength: () => checkArgumentLength,
|
|
1628
|
+
checkArguments: () => checkArguments,
|
|
1629
|
+
onlyPermitPlaintextParagraph: () => onlyPermitPlaintextParagraph,
|
|
1630
|
+
onlyPermitSimpleParagraphs: () => onlyPermitSimpleParagraphs,
|
|
1631
|
+
onlyPermitSingleBlock: () => onlyPermitSingleBlock
|
|
1632
|
+
});
|
|
1620
1633
|
function checkArgumentLength(node, min, max = min) {
|
|
1621
1634
|
if (min !== void 0 && node.arguments.length < min || max !== void 0 && node.arguments.length > max) {
|
|
1622
1635
|
return [new ArgumentCountMismatchMessage({
|
|
@@ -2439,44 +2452,23 @@ function resolveId(id, cxt) {
|
|
|
2439
2452
|
value = cxt.variables.get(id);
|
|
2440
2453
|
return value;
|
|
2441
2454
|
}
|
|
2442
|
-
var
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
},
|
|
2456
|
-
expand(node) {
|
|
2457
|
-
return node.state == x ? node.content : [];
|
|
2458
|
-
}
|
|
2459
|
-
}
|
|
2460
|
-
);
|
|
2461
|
-
var ifdefInline = (name, x) => new InlineModifierDefinition(
|
|
2462
|
-
name,
|
|
2463
|
-
0 /* Normal */,
|
|
2464
|
-
{
|
|
2465
|
-
prepareExpand(node, cxt) {
|
|
2466
|
-
const check = checkArguments(node, 1);
|
|
2467
|
-
if (check) return check;
|
|
2468
|
-
const arg = node.arguments[0];
|
|
2469
|
-
const id = arg.expansion;
|
|
2470
|
-
if (id == "") return [new InvalidArgumentMessage(arg.location)];
|
|
2471
|
-
const value = resolveId(id, cxt);
|
|
2472
|
-
node.state = value !== void 0;
|
|
2473
|
-
return [];
|
|
2474
|
-
},
|
|
2475
|
-
expand(node) {
|
|
2476
|
-
return node.state == x ? node.content : [];
|
|
2477
|
-
}
|
|
2455
|
+
var ifdefBody = (x) => ({
|
|
2456
|
+
prepareExpand(node, cxt) {
|
|
2457
|
+
const check = checkArguments(node, 1);
|
|
2458
|
+
if (check) return check;
|
|
2459
|
+
const arg = node.arguments[0];
|
|
2460
|
+
const id = arg.expansion;
|
|
2461
|
+
if (id == "") return [new InvalidArgumentMessage(arg.location)];
|
|
2462
|
+
const value = resolveId(id, cxt);
|
|
2463
|
+
node.state = value !== void 0;
|
|
2464
|
+
return [];
|
|
2465
|
+
},
|
|
2466
|
+
expand(node) {
|
|
2467
|
+
return node.state == x ? node.content : [];
|
|
2478
2468
|
}
|
|
2479
|
-
);
|
|
2469
|
+
});
|
|
2470
|
+
var ifdefBlock = (name, x) => new BlockModifierDefinition(name, 0 /* Normal */, ifdefBody(x));
|
|
2471
|
+
var ifdefInline = (name, x) => new InlineModifierDefinition(name, 0 /* Normal */, ifdefBody(x));
|
|
2480
2472
|
var IfdefBlockMod = ifdefBlock("ifdef", true);
|
|
2481
2473
|
var IfndefBlockMod = ifdefBlock("ifndef", false);
|
|
2482
2474
|
var IfdefInlineMod = ifdefInline("ifdef", true);
|
|
@@ -2593,7 +2585,8 @@ builtin.inlineModifiers.add(
|
|
|
2593
2585
|
builtin.argumentInterpolators.add(GetVarInterpolator);
|
|
2594
2586
|
var BuiltinConfiguration = Object.freeze(builtin);
|
|
2595
2587
|
|
|
2596
|
-
// src/default/bullets.
|
|
2588
|
+
// src/default/bullets.tsx
|
|
2589
|
+
var import_jsx_runtime = require("minimal-jsx-runtime/jsx-runtime");
|
|
2597
2590
|
var bulletItemBlock = new BlockModifierDefinition(
|
|
2598
2591
|
"bullet-item",
|
|
2599
2592
|
0 /* Normal */,
|
|
@@ -2624,20 +2617,22 @@ var subItemBlock = new BlockModifierDefinition(
|
|
|
2624
2617
|
);
|
|
2625
2618
|
var BulletBlocks = [bulletItemBlock, orderedListItemBlock, subItemBlock];
|
|
2626
2619
|
var BulletBlockRenderersHTML = [
|
|
2627
|
-
[
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2620
|
+
[
|
|
2621
|
+
bulletItemBlock,
|
|
2622
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: cxt.state.render(node.content, cxt) })
|
|
2623
|
+
],
|
|
2624
|
+
[
|
|
2625
|
+
subItemBlock,
|
|
2626
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { class: "subitem", children: cxt.state.render(node.content, cxt) })
|
|
2627
|
+
],
|
|
2628
|
+
[
|
|
2629
|
+
orderedListItemBlock,
|
|
2630
|
+
(node, cxt) => node.state === void 0 ? cxt.state.invalidBlock(node, "bad format") : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { value: node.state, children: cxt.state.render(node.content, cxt) })
|
|
2631
|
+
]
|
|
2638
2632
|
];
|
|
2639
2633
|
|
|
2640
|
-
// src/default/headings.
|
|
2634
|
+
// src/default/headings.tsx
|
|
2635
|
+
var import_jsx_runtime2 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2641
2636
|
var headings = Symbol();
|
|
2642
2637
|
function initHeadings(cxt) {
|
|
2643
2638
|
cxt.init(headings, {
|
|
@@ -2743,37 +2738,103 @@ var HeadingBlocks = [headingBlock, implicitHeadingBlock, numberedHeadingBlock];
|
|
|
2743
2738
|
var HeadingBlockRenderersHTML = [
|
|
2744
2739
|
[headingBlock, (node, cxt) => {
|
|
2745
2740
|
if (node.state !== void 0) {
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2741
|
+
const tag = "h" + node.state.level;
|
|
2742
|
+
const para = node.content[0];
|
|
2743
|
+
const element = document.createElement(tag);
|
|
2744
|
+
element.appendChild(cxt.state.render(para.content, cxt));
|
|
2745
|
+
return element;
|
|
2749
2746
|
}
|
|
2750
2747
|
return cxt.state.invalidBlock(node, "Bad format");
|
|
2751
2748
|
}],
|
|
2752
2749
|
[implicitHeadingBlock, (node, cxt) => {
|
|
2753
2750
|
if (node.state !== void 0) {
|
|
2754
|
-
|
|
2755
|
-
|
|
2751
|
+
const tag = "h" + node.state.level;
|
|
2752
|
+
const element = document.createElement(tag);
|
|
2753
|
+
element.className = "implicit";
|
|
2754
|
+
return element;
|
|
2756
2755
|
}
|
|
2757
2756
|
return cxt.state.invalidBlock(node, "Bad format");
|
|
2758
2757
|
}],
|
|
2759
2758
|
[numberedHeadingBlock, (node, cxt) => {
|
|
2760
2759
|
if (node.state !== void 0) {
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2760
|
+
const tag = "h" + node.state.level;
|
|
2761
|
+
const para = node.content[0];
|
|
2762
|
+
const element = document.createElement(tag);
|
|
2763
|
+
element.appendChild(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { class: "heading-number", children: node.state.name }));
|
|
2764
|
+
element.appendChild(cxt.state.render(para.content, cxt));
|
|
2765
|
+
return element;
|
|
2764
2766
|
}
|
|
2765
2767
|
return cxt.state.invalidBlock(node, "Bad format");
|
|
2766
2768
|
}]
|
|
2767
2769
|
];
|
|
2768
2770
|
|
|
2769
|
-
// src/default/notes.
|
|
2771
|
+
// src/default/notes.tsx
|
|
2772
|
+
var import_jsx_runtime3 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2770
2773
|
var notes = Symbol();
|
|
2771
2774
|
function initNotes(cxt) {
|
|
2772
2775
|
cxt.init(notes, {
|
|
2773
2776
|
systems: /* @__PURE__ */ new Map(),
|
|
2774
|
-
|
|
2777
|
+
defaultSystem: {
|
|
2778
|
+
position: "preserve",
|
|
2779
|
+
autonumber: false
|
|
2780
|
+
},
|
|
2781
|
+
definitions: [],
|
|
2782
|
+
currentId: 0
|
|
2775
2783
|
});
|
|
2776
2784
|
}
|
|
2785
|
+
function getSystem(cxt, name) {
|
|
2786
|
+
const defs = cxt.get(notes);
|
|
2787
|
+
let system;
|
|
2788
|
+
if (name) {
|
|
2789
|
+
if (!defs.systems.has(name)) {
|
|
2790
|
+
system = { ...defs.defaultSystem };
|
|
2791
|
+
defs.systems.set(name, system);
|
|
2792
|
+
} else {
|
|
2793
|
+
system = defs.systems.get(name);
|
|
2794
|
+
}
|
|
2795
|
+
} else {
|
|
2796
|
+
system = defs.defaultSystem;
|
|
2797
|
+
}
|
|
2798
|
+
return system;
|
|
2799
|
+
}
|
|
2800
|
+
var notePositionSystem = new SystemModifierDefinition(
|
|
2801
|
+
"note-position",
|
|
2802
|
+
2 /* None */,
|
|
2803
|
+
{
|
|
2804
|
+
prepareExpand(node, cxt, immediate) {
|
|
2805
|
+
let msgs = checkArguments(node, 1, 2);
|
|
2806
|
+
if (msgs) return msgs;
|
|
2807
|
+
const type = node.arguments[0].expansion.trim();
|
|
2808
|
+
if (type != "global" && type != "preserve")
|
|
2809
|
+
return [new InvalidArgumentMessage(
|
|
2810
|
+
node.arguments[0].location,
|
|
2811
|
+
"should be `preserve` or `global`"
|
|
2812
|
+
)];
|
|
2813
|
+
const name = node.arguments.at(1)?.expansion.trim();
|
|
2814
|
+
getSystem(cxt, name).position = type;
|
|
2815
|
+
return [];
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
);
|
|
2819
|
+
var noteRenumberingSystem = new SystemModifierDefinition(
|
|
2820
|
+
"note-renumbering",
|
|
2821
|
+
2 /* None */,
|
|
2822
|
+
{
|
|
2823
|
+
prepareExpand(node, cxt, immediate) {
|
|
2824
|
+
let msgs = checkArguments(node, 1, 2);
|
|
2825
|
+
if (msgs) return msgs;
|
|
2826
|
+
const type = node.arguments[0].expansion.trim();
|
|
2827
|
+
if (type != "on" && type != "off")
|
|
2828
|
+
return [new InvalidArgumentMessage(
|
|
2829
|
+
node.arguments[0].location,
|
|
2830
|
+
"should be `preserve` or `global`"
|
|
2831
|
+
)];
|
|
2832
|
+
const name = node.arguments.at(1)?.expansion.trim();
|
|
2833
|
+
getSystem(cxt, name).autonumber = type == "on";
|
|
2834
|
+
return [];
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
);
|
|
2777
2838
|
var noteMarkerInline = new InlineModifierDefinition(
|
|
2778
2839
|
"note",
|
|
2779
2840
|
2 /* None */,
|
|
@@ -2795,13 +2856,15 @@ var noteInline = new InlineModifierDefinition(
|
|
|
2795
2856
|
prepareExpand(node) {
|
|
2796
2857
|
let msgs = checkArguments(node, 0, 1);
|
|
2797
2858
|
if (msgs) return msgs;
|
|
2798
|
-
node.state = node.arguments.at(0)?.expansion ?? "";
|
|
2859
|
+
node.state = node.arguments.at(0)?.expansion?.trim() ?? "";
|
|
2799
2860
|
return [];
|
|
2800
2861
|
},
|
|
2801
2862
|
afterProcessExpansion(node, cxt) {
|
|
2802
2863
|
if (node.state !== void 0) {
|
|
2803
|
-
cxt.get(notes)
|
|
2864
|
+
const defs = cxt.get(notes);
|
|
2865
|
+
defs.definitions.push({
|
|
2804
2866
|
system: "",
|
|
2867
|
+
id: defs.currentId,
|
|
2805
2868
|
name: node.state,
|
|
2806
2869
|
location: node.location,
|
|
2807
2870
|
content: [{
|
|
@@ -2814,6 +2877,7 @@ var noteInline = new InlineModifierDefinition(
|
|
|
2814
2877
|
content: node.content
|
|
2815
2878
|
}]
|
|
2816
2879
|
});
|
|
2880
|
+
defs.currentId++;
|
|
2817
2881
|
}
|
|
2818
2882
|
return [];
|
|
2819
2883
|
}
|
|
@@ -2824,58 +2888,73 @@ var noteBlock = new BlockModifierDefinition(
|
|
|
2824
2888
|
0 /* Normal */,
|
|
2825
2889
|
{
|
|
2826
2890
|
roleHint: "quote",
|
|
2827
|
-
prepareExpand(node) {
|
|
2828
|
-
let msgs = checkArguments(node, 1);
|
|
2891
|
+
prepareExpand(node, cxt) {
|
|
2892
|
+
let msgs = checkArguments(node, 1, 2);
|
|
2829
2893
|
if (msgs) return msgs;
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
let content = stripNode(...node.content);
|
|
2836
|
-
debug.trace(`add note: system=<${""}> name=${node.state} @${node.location.start}`);
|
|
2837
|
-
debug.trace(`-->
|
|
2894
|
+
const name = node.arguments[0].expansion.trim();
|
|
2895
|
+
const system = node.arguments.at(1)?.expansion.trim() ?? "";
|
|
2896
|
+
const content = stripNode(...node.content);
|
|
2897
|
+
debug.trace(`add note: system=<${""}> name=${node.state} @${node.location.start}`);
|
|
2898
|
+
debug.trace(`-->
|
|
2838
2899
|
`, debugPrint.node(...content));
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2900
|
+
const defs = cxt.get(notes);
|
|
2901
|
+
const entry = {
|
|
2902
|
+
id: defs.currentId,
|
|
2903
|
+
system,
|
|
2904
|
+
name,
|
|
2905
|
+
location: node.location,
|
|
2906
|
+
content
|
|
2907
|
+
};
|
|
2908
|
+
defs.currentId++;
|
|
2909
|
+
defs.definitions.push(entry);
|
|
2910
|
+
node.state = entry;
|
|
2847
2911
|
return [];
|
|
2848
2912
|
}
|
|
2849
2913
|
}
|
|
2850
2914
|
);
|
|
2851
2915
|
var NoteBlocks = [noteBlock];
|
|
2852
2916
|
var NoteInlines = [noteInline, noteMarkerInline];
|
|
2917
|
+
var NoteSystems = [notePositionSystem, noteRenumberingSystem];
|
|
2918
|
+
function makeNoteHTML(def, cxt) {
|
|
2919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { class: "note", id: `note-id-${def.id}`, children: [
|
|
2920
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { class: "note-name", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: `#notemarker-id-${def.id}`, children: def.name }) }) }),
|
|
2921
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { class: "note-content", children: cxt.state.render(def.content, cxt) })
|
|
2922
|
+
] });
|
|
2923
|
+
}
|
|
2853
2924
|
var NoteInlineRenderersHTML = [
|
|
2854
2925
|
[noteMarkerInline, (node, cxt) => {
|
|
2855
2926
|
if (node.state === void 0)
|
|
2856
2927
|
return cxt.state.invalidInline(node, "bad format");
|
|
2857
|
-
const defs = cxt.
|
|
2928
|
+
const defs = cxt.parsedDocument.context.get(notes).definitions;
|
|
2858
2929
|
const note = defs.findIndex((x) => (
|
|
2859
2930
|
/*x.position >= node.start &&*/
|
|
2860
2931
|
x.name == node.state
|
|
2861
2932
|
));
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("sup", { class: "note", id: `notemarker-id-${note}`, children: note < 0 ? `Not found: ${node.state}` : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: `#note-id-${note}`, children: node.state }) });
|
|
2934
|
+
}]
|
|
2935
|
+
];
|
|
2936
|
+
var NoteBlockRenderersHTML = [
|
|
2937
|
+
[noteBlock, (node, cxt) => {
|
|
2938
|
+
if (node.state === void 0)
|
|
2939
|
+
return cxt.state.invalidBlock(node, "bad format");
|
|
2940
|
+
const defs = cxt.parsedDocument.context.get(notes);
|
|
2941
|
+
const system = defs.systems.get(node.state.system) ?? defs.defaultSystem;
|
|
2942
|
+
if (system.position != "preserve") return [];
|
|
2943
|
+
return makeNoteHTML(node.state, cxt);
|
|
2865
2944
|
}]
|
|
2866
2945
|
];
|
|
2867
2946
|
var NotesFooterPlugin = (cxt) => {
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
return
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
</section>`;
|
|
2947
|
+
const defs = cxt.parsedDocument.context.get(notes);
|
|
2948
|
+
const items = cxt.parsedDocument.context.get(notes).definitions.filter((x) => (defs.systems.get(x.system) ?? defs.defaultSystem).position == "global");
|
|
2949
|
+
if (items.length == 0) return void 0;
|
|
2950
|
+
return [
|
|
2951
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("hr", {}),
|
|
2952
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("section", { class: "notes-global", children: items.map((x) => makeNoteHTML(x, cxt)) })
|
|
2953
|
+
];
|
|
2876
2954
|
};
|
|
2877
2955
|
|
|
2878
|
-
// src/default/code.
|
|
2956
|
+
// src/default/code.tsx
|
|
2957
|
+
var import_jsx_runtime4 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2879
2958
|
var CodeBlock = new BlockModifierDefinition(
|
|
2880
2959
|
"code",
|
|
2881
2960
|
1 /* Preformatted */,
|
|
@@ -2886,14 +2965,17 @@ var CodeInline = new InlineModifierDefinition(
|
|
|
2886
2965
|
1 /* Preformatted */,
|
|
2887
2966
|
{ roleHint: "code" }
|
|
2888
2967
|
);
|
|
2889
|
-
var CodeBlockRendererHTML = [
|
|
2890
|
-
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2968
|
+
var CodeBlockRendererHTML = [
|
|
2969
|
+
CodeBlock,
|
|
2970
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: cxt.state.render(node.content, cxt) }) })
|
|
2971
|
+
];
|
|
2972
|
+
var CodeInlineRendererHTML = [
|
|
2973
|
+
CodeInline,
|
|
2974
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: cxt.state.render(node.content, cxt) }) })
|
|
2975
|
+
];
|
|
2895
2976
|
|
|
2896
|
-
// src/default/quotes.
|
|
2977
|
+
// src/default/quotes.tsx
|
|
2978
|
+
var import_jsx_runtime5 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2897
2979
|
var quoteBlock = new BlockModifierDefinition(
|
|
2898
2980
|
"quote",
|
|
2899
2981
|
0 /* Normal */,
|
|
@@ -2904,6 +2986,16 @@ var epitaphBlock = new BlockModifierDefinition(
|
|
|
2904
2986
|
0 /* Normal */,
|
|
2905
2987
|
{ roleHint: "quote" }
|
|
2906
2988
|
);
|
|
2989
|
+
var calloutBlock = new BlockModifierDefinition(
|
|
2990
|
+
"callout",
|
|
2991
|
+
0 /* Normal */,
|
|
2992
|
+
{ roleHint: "quote" }
|
|
2993
|
+
);
|
|
2994
|
+
var detailBlock = new BlockModifierDefinition(
|
|
2995
|
+
"detail",
|
|
2996
|
+
0 /* Normal */,
|
|
2997
|
+
{ roleHint: "quote" }
|
|
2998
|
+
);
|
|
2907
2999
|
var attributionBlock = new BlockModifierDefinition(
|
|
2908
3000
|
"by",
|
|
2909
3001
|
0 /* Normal */,
|
|
@@ -2919,23 +3011,34 @@ var attributionBlock = new BlockModifierDefinition(
|
|
|
2919
3011
|
}
|
|
2920
3012
|
}
|
|
2921
3013
|
);
|
|
2922
|
-
var QuoteBlocks = [quoteBlock, epitaphBlock, attributionBlock];
|
|
3014
|
+
var QuoteBlocks = [quoteBlock, epitaphBlock, calloutBlock, detailBlock, attributionBlock];
|
|
2923
3015
|
var QuoteBlockRenderersHTML = [
|
|
2924
|
-
[
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3016
|
+
[
|
|
3017
|
+
quoteBlock,
|
|
3018
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("blockquote", { children: cxt.state.render(node.content, cxt) })
|
|
3019
|
+
],
|
|
3020
|
+
[
|
|
3021
|
+
epitaphBlock,
|
|
3022
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("blockquote", { class: "epitaph", children: cxt.state.render(node.content, cxt) })
|
|
3023
|
+
],
|
|
3024
|
+
[
|
|
3025
|
+
detailBlock,
|
|
3026
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { class: "detail", children: cxt.state.render(node.content, cxt) })
|
|
3027
|
+
],
|
|
3028
|
+
[
|
|
3029
|
+
calloutBlock,
|
|
3030
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("aside", { children: cxt.state.render(node.content, cxt) })
|
|
3031
|
+
],
|
|
2930
3032
|
[attributionBlock, (node, cxt) => {
|
|
2931
3033
|
if (!node.state)
|
|
2932
3034
|
return cxt.state.invalidBlock(node, "bad format");
|
|
2933
3035
|
let para = node.content[0];
|
|
2934
|
-
return
|
|
3036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { class: "attribution", children: cxt.state.render(para.content, cxt) });
|
|
2935
3037
|
}]
|
|
2936
3038
|
];
|
|
2937
3039
|
|
|
2938
|
-
// src/default/inline-styles.
|
|
3040
|
+
// src/default/inline-styles.tsx
|
|
3041
|
+
var import_jsx_runtime6 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2939
3042
|
var emphasisInline = new InlineModifierDefinition(
|
|
2940
3043
|
"emphasis",
|
|
2941
3044
|
0 /* Normal */,
|
|
@@ -2956,23 +3059,37 @@ var commentaryInline = new InlineModifierDefinition(
|
|
|
2956
3059
|
0 /* Normal */,
|
|
2957
3060
|
{ roleHint: "commentary" }
|
|
2958
3061
|
);
|
|
2959
|
-
var
|
|
3062
|
+
var sequenceInline = new InlineModifierDefinition(
|
|
3063
|
+
"seq",
|
|
3064
|
+
0 /* Normal */,
|
|
3065
|
+
{ roleHint: "commentary" }
|
|
3066
|
+
);
|
|
3067
|
+
var InlineStyles = [emphasisInline, keywordInline, highlightInline, commentaryInline, sequenceInline];
|
|
2960
3068
|
var InlineStyleRenderersHTML = [
|
|
2961
|
-
[
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
3069
|
+
[
|
|
3070
|
+
emphasisInline,
|
|
3071
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: cxt.state.render(node.content, cxt) })
|
|
3072
|
+
],
|
|
3073
|
+
[
|
|
3074
|
+
keywordInline,
|
|
3075
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: cxt.state.render(node.content, cxt) })
|
|
3076
|
+
],
|
|
3077
|
+
[
|
|
3078
|
+
highlightInline,
|
|
3079
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("mark", { children: cxt.state.render(node.content, cxt) })
|
|
3080
|
+
],
|
|
3081
|
+
[
|
|
3082
|
+
commentaryInline,
|
|
3083
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { class: "commentary", children: cxt.state.render(node.content, cxt) })
|
|
3084
|
+
],
|
|
3085
|
+
[
|
|
3086
|
+
sequenceInline,
|
|
3087
|
+
(node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { class: "seq", children: cxt.state.render(node.content, cxt) })
|
|
3088
|
+
]
|
|
2973
3089
|
];
|
|
2974
3090
|
|
|
2975
|
-
// src/default/misc.
|
|
3091
|
+
// src/default/misc.tsx
|
|
3092
|
+
var import_jsx_runtime7 = require("minimal-jsx-runtime/jsx-runtime");
|
|
2976
3093
|
var rubyInline = new InlineModifierDefinition(
|
|
2977
3094
|
"ruby",
|
|
2978
3095
|
0 /* Normal */,
|
|
@@ -3048,43 +3165,46 @@ var imageBlock = new BlockModifierDefinition(
|
|
|
3048
3165
|
var MiscInlines = [rubyInline, linkInline];
|
|
3049
3166
|
var MiscBlocks = [styleBlock, breakBlock, linkBlock, imageBlock];
|
|
3050
3167
|
var MiscInlineRenderersHTML = [
|
|
3051
|
-
[
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3168
|
+
[
|
|
3169
|
+
rubyInline,
|
|
3170
|
+
(node, cxt) => node.state === void 0 ? cxt.state.invalidInline(node, "bad format") : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("ruby", { children: [
|
|
3171
|
+
cxt.state.render(node.content, cxt),
|
|
3172
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rt", { children: node.state })
|
|
3173
|
+
] })
|
|
3174
|
+
],
|
|
3175
|
+
[
|
|
3176
|
+
linkInline,
|
|
3177
|
+
(node, cxt) => node.state === void 0 ? cxt.state.invalidInline(node, "bad format") : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: encodeURI(node.state), children: cxt.state.render(node.content, cxt) })
|
|
3178
|
+
]
|
|
3061
3179
|
];
|
|
3062
3180
|
var MiscBlockRenderersHTML = [
|
|
3063
|
-
[
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
}],
|
|
3068
|
-
[
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3181
|
+
[
|
|
3182
|
+
styleBlock,
|
|
3183
|
+
(node, cxt) => node.state === void 0 ? cxt.state.invalidBlock(node, "bad format") : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { class: `emmmstyle-${node.state}`, style: "display:contents", children: cxt.state.render(node.content, cxt) })
|
|
3184
|
+
],
|
|
3185
|
+
[breakBlock, () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("hr", {})],
|
|
3186
|
+
[
|
|
3187
|
+
linkBlock,
|
|
3188
|
+
(node, cxt) => {
|
|
3189
|
+
if (node.state === void 0)
|
|
3190
|
+
return cxt.state.invalidBlock(node, "bad format");
|
|
3191
|
+
const content = cxt.state.render(node.content, cxt);
|
|
3192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: encodeURI(node.state), children: content.childElementCount > 0 ? content : node.state });
|
|
3193
|
+
}
|
|
3194
|
+
],
|
|
3076
3195
|
[imageBlock, (node, cxt) => {
|
|
3077
|
-
let transformed;
|
|
3078
3196
|
if (node.state === void 0)
|
|
3079
3197
|
return cxt.state.invalidBlock(node, "bad format");
|
|
3198
|
+
let transformed;
|
|
3080
3199
|
try {
|
|
3081
3200
|
transformed = cxt.config.options.transformAsset(node.state);
|
|
3082
3201
|
} catch {
|
|
3083
3202
|
return cxt.state.invalidBlock(node, "unable to transform asset");
|
|
3084
3203
|
}
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("figure", { children: [
|
|
3205
|
+
transformed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: transformed, "data-original-src": node.state }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: node.state }),
|
|
3206
|
+
node.content.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("figcaption", { children: cxt.state.render(node.content[0].content, cxt) }) : []
|
|
3207
|
+
] });
|
|
3088
3208
|
}]
|
|
3089
3209
|
];
|
|
3090
3210
|
|
|
@@ -3139,34 +3259,45 @@ config.inlineModifiers.add(
|
|
|
3139
3259
|
...NoteInlines
|
|
3140
3260
|
);
|
|
3141
3261
|
config.systemModifiers.add(
|
|
3142
|
-
...VarWrappers
|
|
3262
|
+
...VarWrappers,
|
|
3263
|
+
...NoteSystems
|
|
3143
3264
|
);
|
|
3144
3265
|
var DefaultConfiguration = Object.freeze(config);
|
|
3145
3266
|
|
|
3146
|
-
// src/default/html-renderer.
|
|
3267
|
+
// src/default/html-renderer.tsx
|
|
3268
|
+
var import_jsx_runtime8 = require("minimal-jsx-runtime/jsx-runtime");
|
|
3147
3269
|
var HTMLRenderState = class {
|
|
3148
3270
|
title = "";
|
|
3149
3271
|
stylesheet = "";
|
|
3150
3272
|
// FIXME: very unsafe!
|
|
3151
3273
|
cssVariables = /* @__PURE__ */ new Map();
|
|
3152
|
-
// https://stackoverflow.com/questions/7381974
|
|
3153
|
-
escape(content) {
|
|
3154
|
-
return content.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("\n", "<br/>");
|
|
3155
|
-
}
|
|
3156
3274
|
invalidBlock(node, msg) {
|
|
3157
3275
|
let name = NodeType[node.type];
|
|
3158
3276
|
if (node.type === 7 /* BlockModifier */)
|
|
3159
3277
|
name += ` (${node.mod.name})`;
|
|
3160
|
-
return
|
|
3278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { class: "invalid", children: [
|
|
3279
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
|
|
3280
|
+
"Invalid ",
|
|
3281
|
+
name
|
|
3282
|
+
] }),
|
|
3283
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { children: msg })
|
|
3284
|
+
] });
|
|
3161
3285
|
}
|
|
3162
3286
|
invalidInline(node, msg) {
|
|
3163
3287
|
let name = NodeType[node.type];
|
|
3164
3288
|
if (node.type === 6 /* InlineModifier */)
|
|
3165
3289
|
name += ` (${node.mod.name})`;
|
|
3166
|
-
return
|
|
3290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { class: "invalid", children: [
|
|
3291
|
+
"Invalid ",
|
|
3292
|
+
name,
|
|
3293
|
+
": ",
|
|
3294
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { children: msg })
|
|
3295
|
+
] });
|
|
3167
3296
|
}
|
|
3168
3297
|
render(elems, cxt) {
|
|
3169
|
-
|
|
3298
|
+
let fragment = new DocumentFragment();
|
|
3299
|
+
elems.map((x) => cxt.renderEntity(x)).filter((x) => x !== void 0).flat().forEach((x) => fragment.appendChild(x));
|
|
3300
|
+
return fragment;
|
|
3170
3301
|
}
|
|
3171
3302
|
};
|
|
3172
3303
|
var htmlConfig = new RenderConfiguration(
|
|
@@ -3174,7 +3305,8 @@ var htmlConfig = new RenderConfiguration(
|
|
|
3174
3305
|
headPlugins: [],
|
|
3175
3306
|
headerPlugins: [],
|
|
3176
3307
|
footerPlugins: [NotesFooterPlugin],
|
|
3177
|
-
|
|
3308
|
+
postprocessPlugins: [],
|
|
3309
|
+
transformAsset: () => void 0
|
|
3178
3310
|
// postprocessPlugins: [],
|
|
3179
3311
|
},
|
|
3180
3312
|
(results, cxt) => {
|
|
@@ -3182,35 +3314,41 @@ var htmlConfig = new RenderConfiguration(
|
|
|
3182
3314
|
/var\(--(.*?)\)/g,
|
|
3183
3315
|
(m, c) => cxt.state.cssVariables.get(c) ?? m
|
|
3184
3316
|
);
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
</body>
|
|
3203
|
-
</html>`;
|
|
3317
|
+
let doc = document.implementation.createHTMLDocument(cxt.state.title);
|
|
3318
|
+
doc.head.append(
|
|
3319
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("meta", { charset: "UTF-8" }),
|
|
3320
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: styles }),
|
|
3321
|
+
...cxt.config.options.headPlugins.map((x) => x(cxt)).filter((x) => x !== void 0).flat()
|
|
3322
|
+
);
|
|
3323
|
+
doc.body.append(
|
|
3324
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { class: "article-container", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { class: "article-body", children: [
|
|
3325
|
+
cxt.config.options.headerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0),
|
|
3326
|
+
results,
|
|
3327
|
+
cxt.config.options.footerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0)
|
|
3328
|
+
] }) })
|
|
3329
|
+
);
|
|
3330
|
+
for (const p of cxt.config.options.postprocessPlugins) {
|
|
3331
|
+
p(cxt, doc);
|
|
3332
|
+
}
|
|
3333
|
+
return doc;
|
|
3204
3334
|
}
|
|
3205
3335
|
);
|
|
3206
|
-
htmlConfig.paragraphRenderer = (node, cxt) =>
|
|
3336
|
+
htmlConfig.paragraphRenderer = (node, cxt) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: node.content.map((x) => cxt.renderEntity(x)).filter((x) => x !== void 0) });
|
|
3207
3337
|
htmlConfig.textRenderer = (node, cxt) => {
|
|
3208
3338
|
switch (node.type) {
|
|
3209
3339
|
case 2 /* Preformatted */:
|
|
3210
|
-
return
|
|
3340
|
+
return new Text(node.content.text);
|
|
3211
3341
|
case 3 /* Text */:
|
|
3212
3342
|
case 4 /* Escaped */:
|
|
3213
|
-
|
|
3343
|
+
const split = node.content.split("\n");
|
|
3344
|
+
const result = [];
|
|
3345
|
+
for (let i = 0; i < split.length; i++) {
|
|
3346
|
+
result.push(new Text(split[i]));
|
|
3347
|
+
if (i < split.length - 1)
|
|
3348
|
+
result.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("br", {}));
|
|
3349
|
+
}
|
|
3350
|
+
console.log(result);
|
|
3351
|
+
return result;
|
|
3214
3352
|
default:
|
|
3215
3353
|
return debug.never(node);
|
|
3216
3354
|
}
|
|
@@ -3226,8 +3364,8 @@ htmlConfig.addBlockRenderer(
|
|
|
3226
3364
|
...BulletBlockRenderersHTML,
|
|
3227
3365
|
CodeBlockRendererHTML,
|
|
3228
3366
|
...QuoteBlockRenderersHTML,
|
|
3229
|
-
...MiscBlockRenderersHTML
|
|
3230
|
-
|
|
3367
|
+
...MiscBlockRenderersHTML,
|
|
3368
|
+
...NoteBlockRenderersHTML
|
|
3231
3369
|
);
|
|
3232
3370
|
htmlConfig.addInlineRenderer(
|
|
3233
3371
|
CodeInlineRendererHTML,
|
|
@@ -3265,6 +3403,7 @@ function setDebugLevel(level) {
|
|
|
3265
3403
|
SystemModifierDefinition,
|
|
3266
3404
|
debugPrint,
|
|
3267
3405
|
emmmVersion,
|
|
3406
|
+
helper,
|
|
3268
3407
|
messages,
|
|
3269
3408
|
parse,
|
|
3270
3409
|
setDebugLevel
|