@podlite/markdown 0.0.25 → 0.0.27
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/CHANGELOG.podlite +47 -0
- package/lib/index.cjs +43 -25
- package/lib/index.cjs.map +4 -4
- package/lib/index.esm.js +378 -41
- package/lib/index.esm.js.map +4 -4
- package/package.json +2 -2
- package/src/tools.ts +14 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +0 -47
package/lib/index.esm.js
CHANGED
|
@@ -1716,9 +1716,9 @@ var require_iterate = __commonJS({
|
|
|
1716
1716
|
}
|
|
1717
1717
|
}
|
|
1718
1718
|
function checkKeywordTypes(it, ts) {
|
|
1719
|
-
const
|
|
1720
|
-
for (const keyword in
|
|
1721
|
-
const rule =
|
|
1719
|
+
const rules3 = it.self.RULES.all;
|
|
1720
|
+
for (const keyword in rules3) {
|
|
1721
|
+
const rule = rules3[keyword];
|
|
1722
1722
|
if (typeof rule == "object" && applicability_1.shouldUseRule(it.schema, rule)) {
|
|
1723
1723
|
const { type } = rule.definition;
|
|
1724
1724
|
if (type.length && !type.some((t) => hasApplicableType(ts, t))) {
|
|
@@ -3248,18 +3248,18 @@ var require_util = __commonJS({
|
|
|
3248
3248
|
return;
|
|
3249
3249
|
if (typeof schema === "boolean")
|
|
3250
3250
|
return;
|
|
3251
|
-
const
|
|
3251
|
+
const rules3 = self.RULES.keywords;
|
|
3252
3252
|
for (const key in schema) {
|
|
3253
|
-
if (!
|
|
3253
|
+
if (!rules3[key])
|
|
3254
3254
|
validate_1.checkStrictMode(it, `unknown keyword: "${key}"`);
|
|
3255
3255
|
}
|
|
3256
3256
|
}
|
|
3257
3257
|
exports.checkUnknownRules = checkUnknownRules;
|
|
3258
|
-
function schemaHasRules(schema,
|
|
3258
|
+
function schemaHasRules(schema, rules3) {
|
|
3259
3259
|
if (typeof schema == "boolean")
|
|
3260
3260
|
return !schema;
|
|
3261
3261
|
for (const key in schema)
|
|
3262
|
-
if (
|
|
3262
|
+
if (rules3[key])
|
|
3263
3263
|
return true;
|
|
3264
3264
|
return false;
|
|
3265
3265
|
}
|
|
@@ -4405,15 +4405,15 @@ var require_core = __commonJS({
|
|
|
4405
4405
|
return errors.map((e) => `${dataVar}${e.dataPath} ${e.message}`).reduce((text4, msg) => text4 + separator + msg);
|
|
4406
4406
|
}
|
|
4407
4407
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
4408
|
-
const
|
|
4408
|
+
const rules3 = this.RULES.all;
|
|
4409
4409
|
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
|
4410
4410
|
for (const jsonPointer of keywordsJsonPointers) {
|
|
4411
4411
|
const segments = jsonPointer.split("/").slice(1);
|
|
4412
4412
|
let keywords = metaSchema;
|
|
4413
4413
|
for (const seg of segments)
|
|
4414
4414
|
keywords = keywords[seg];
|
|
4415
|
-
for (const key in
|
|
4416
|
-
const rule =
|
|
4415
|
+
for (const key in rules3) {
|
|
4416
|
+
const rule = rules3[key];
|
|
4417
4417
|
if (typeof rule != "object")
|
|
4418
4418
|
continue;
|
|
4419
4419
|
const { $data } = rule.definition;
|
|
@@ -8295,6 +8295,9 @@ var require_AstTree = __commonJS({
|
|
|
8295
8295
|
"number"
|
|
8296
8296
|
]
|
|
8297
8297
|
},
|
|
8298
|
+
checked: {
|
|
8299
|
+
type: "boolean"
|
|
8300
|
+
},
|
|
8298
8301
|
type: {
|
|
8299
8302
|
type: "string",
|
|
8300
8303
|
enum: [
|
|
@@ -11057,6 +11060,9 @@ var require_PodliteDocument = __commonJS({
|
|
|
11057
11060
|
"number"
|
|
11058
11061
|
]
|
|
11059
11062
|
},
|
|
11063
|
+
checked: {
|
|
11064
|
+
type: "boolean"
|
|
11065
|
+
},
|
|
11060
11066
|
type: {
|
|
11061
11067
|
type: "string",
|
|
11062
11068
|
enum: [
|
|
@@ -12778,7 +12784,7 @@ var require_grammar = __commonJS({
|
|
|
12778
12784
|
config,
|
|
12779
12785
|
location: location()
|
|
12780
12786
|
};
|
|
12781
|
-
}, peg$c125 = /^[
|
|
12787
|
+
}, peg$c125 = /^[\-+=_|]/, peg$c126 = peg$classExpectation(["-", "+", "=", "_", "|"], false, false), peg$c127 = function() {
|
|
12782
12788
|
return { type: "separator", text: text4() };
|
|
12783
12789
|
}, peg$c128 = function() {
|
|
12784
12790
|
return options.isDelimited;
|
|
@@ -25081,7 +25087,7 @@ var require_package = __commonJS({
|
|
|
25081
25087
|
"../podlite-schema/package.json"(exports, module) {
|
|
25082
25088
|
module.exports = {
|
|
25083
25089
|
name: "@podlite/schema",
|
|
25084
|
-
version: "0.0.
|
|
25090
|
+
version: "0.0.34",
|
|
25085
25091
|
description: "AST tools for Podlite markup language",
|
|
25086
25092
|
main: "./src/index.ts",
|
|
25087
25093
|
license: "MIT",
|
|
@@ -25112,9 +25118,9 @@ var require_package = __commonJS({
|
|
|
25112
25118
|
build: "run-s build:pegjs build_lib build:ast ",
|
|
25113
25119
|
build_lib: "yarn g:build",
|
|
25114
25120
|
"build:ast": "ts-node scripts/make-ast-scheme.ts",
|
|
25115
|
-
"build:pegjs": "
|
|
25121
|
+
"build:pegjs": "pegmill -o src/grammar.js src/grammar.pegjs && pegmill -o src/grammarfc.js src/grammarfc.pegjs",
|
|
25116
25122
|
watch: "npx nodemon -e js,ts --exec 'yarn' build",
|
|
25117
|
-
"watch:pegjs": "npx nodemon -e
|
|
25123
|
+
"watch:pegjs": "npx nodemon -e pegmill --exec 'yarn' build:pegjs",
|
|
25118
25124
|
test: "yarn g:jest --passWithNoTests"
|
|
25119
25125
|
},
|
|
25120
25126
|
keywords: [
|
|
@@ -25134,7 +25140,7 @@ var require_package = __commonJS({
|
|
|
25134
25140
|
"@types/node": "^17.0.7",
|
|
25135
25141
|
glob: "^7.2.0",
|
|
25136
25142
|
"npm-run-all": "^4.1.5",
|
|
25137
|
-
|
|
25143
|
+
pegmill: "0.1.0",
|
|
25138
25144
|
"ts-node": "^9.1.1",
|
|
25139
25145
|
typescript: "4.5.5",
|
|
25140
25146
|
"typescript-json-schema": "0.53.0"
|
|
@@ -25342,13 +25348,13 @@ var makeRulesArray = (key, fn) => {
|
|
|
25342
25348
|
}, []);
|
|
25343
25349
|
}
|
|
25344
25350
|
if (key instanceof Object) {
|
|
25345
|
-
let
|
|
25351
|
+
let rules3 = [];
|
|
25346
25352
|
for (var prop in key) {
|
|
25347
25353
|
if (key.hasOwnProperty(prop)) {
|
|
25348
|
-
|
|
25354
|
+
rules3.push(makeRule(makePlug(prop), key[prop]));
|
|
25349
25355
|
}
|
|
25350
25356
|
}
|
|
25351
|
-
return
|
|
25357
|
+
return rules3;
|
|
25352
25358
|
}
|
|
25353
25359
|
return [makeRule(makePlug(key), fn)];
|
|
25354
25360
|
};
|
|
@@ -25490,7 +25496,7 @@ function flattenDeep(arr) {
|
|
|
25490
25496
|
}
|
|
25491
25497
|
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);
|
|
25492
25498
|
}
|
|
25493
|
-
function thisFunc(
|
|
25499
|
+
function thisFunc(rules3) {
|
|
25494
25500
|
function interator(node, context) {
|
|
25495
25501
|
if (node == null) {
|
|
25496
25502
|
return node;
|
|
@@ -25501,7 +25507,7 @@ function thisFunc(rules2) {
|
|
|
25501
25507
|
if ("string" === typeof node) {
|
|
25502
25508
|
return interator({ type: "text", value: node }, context);
|
|
25503
25509
|
}
|
|
25504
|
-
const reversed =
|
|
25510
|
+
const reversed = rules3.slice();
|
|
25505
25511
|
reversed.reverse();
|
|
25506
25512
|
const ruleIndex = reversed.findIndex((rule) => rule.isFor(node));
|
|
25507
25513
|
if (ruleIndex !== -1) {
|
|
@@ -25526,7 +25532,7 @@ function thisFunc(rules2) {
|
|
|
25526
25532
|
}
|
|
25527
25533
|
}
|
|
25528
25534
|
}
|
|
25529
|
-
interator.rules =
|
|
25535
|
+
interator.rules = rules3;
|
|
25530
25536
|
return interator;
|
|
25531
25537
|
}
|
|
25532
25538
|
var makeInterator_default = thisFunc;
|
|
@@ -25550,8 +25556,8 @@ var setFn = (check) => (writer, processor) => {
|
|
|
25550
25556
|
return check(node, ctx)(writer, processor)(node, ctx, interator);
|
|
25551
25557
|
};
|
|
25552
25558
|
};
|
|
25553
|
-
var subUse = (
|
|
25554
|
-
const newFns = makeRulesArray(
|
|
25559
|
+
var subUse = (rules3, processNode) => {
|
|
25560
|
+
const newFns = makeRulesArray(rules3).reverse();
|
|
25555
25561
|
return (writer, processor) => {
|
|
25556
25562
|
const inited = newFns.map((item) => makeRule(item.rule, item.fn(writer, processor))).reverse();
|
|
25557
25563
|
const processNodeInited = processNode(writer, processor);
|
|
@@ -25587,7 +25593,7 @@ function flattenDeep2(arr) {
|
|
|
25587
25593
|
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep2(val)) : acc.concat(val), []);
|
|
25588
25594
|
}
|
|
25589
25595
|
var makeTransformer = (rule) => {
|
|
25590
|
-
let
|
|
25596
|
+
let rules3 = [];
|
|
25591
25597
|
function use(key, fn) {
|
|
25592
25598
|
if (key instanceof Array) {
|
|
25593
25599
|
console.warn(`[podlite] Unsupported param for ${key}`);
|
|
@@ -25600,7 +25606,7 @@ var makeTransformer = (rule) => {
|
|
|
25600
25606
|
}
|
|
25601
25607
|
return [];
|
|
25602
25608
|
}
|
|
25603
|
-
|
|
25609
|
+
rules3.push(makeRule(makePlug(key), fn));
|
|
25604
25610
|
}
|
|
25605
25611
|
function visiter(node, context = {}) {
|
|
25606
25612
|
if (node == null) {
|
|
@@ -25612,7 +25618,7 @@ var makeTransformer = (rule) => {
|
|
|
25612
25618
|
if ("string" === typeof node) {
|
|
25613
25619
|
return node;
|
|
25614
25620
|
}
|
|
25615
|
-
const reversed =
|
|
25621
|
+
const reversed = rules3.slice();
|
|
25616
25622
|
reversed.reverse();
|
|
25617
25623
|
const ruleIndex = reversed.findIndex((rule2) => rule2.isFor(node));
|
|
25618
25624
|
if (ruleIndex !== -1) {
|
|
@@ -25626,7 +25632,7 @@ var makeTransformer = (rule) => {
|
|
|
25626
25632
|
}
|
|
25627
25633
|
}
|
|
25628
25634
|
use(rule);
|
|
25629
|
-
visiter.rules =
|
|
25635
|
+
visiter.rules = rules3;
|
|
25630
25636
|
return visiter;
|
|
25631
25637
|
};
|
|
25632
25638
|
var makeTransformer_default = makeTransformer;
|
|
@@ -25769,6 +25775,303 @@ var pluginCleanLocation = () => (tree) => {
|
|
|
25769
25775
|
};
|
|
25770
25776
|
var plugin_clean_location_default = pluginCleanLocation;
|
|
25771
25777
|
|
|
25778
|
+
// ../podlite-schema/src/exportMarkdown.ts
|
|
25779
|
+
var rules = {
|
|
25780
|
+
":text": (writer, processor) => (node, ctx, interator) => {
|
|
25781
|
+
if (node.value) {
|
|
25782
|
+
writer.write(node.value);
|
|
25783
|
+
} else {
|
|
25784
|
+
interator(node.content, ctx);
|
|
25785
|
+
}
|
|
25786
|
+
},
|
|
25787
|
+
"A<>": (writer, processor) => (node, ctx, interator) => {
|
|
25788
|
+
if (!(ctx.alias && ctx.alias.hasOwnProperty(node.content))) {
|
|
25789
|
+
writer.writeRaw(`A<${node.content}>`);
|
|
25790
|
+
} else {
|
|
25791
|
+
const src = ctx.alias[node.content].join("\n");
|
|
25792
|
+
const tree_1 = processor(src);
|
|
25793
|
+
const tree = plugin_clean_location_default()(tree_1);
|
|
25794
|
+
if (tree[0].type === "para") {
|
|
25795
|
+
interator(tree[0].content, ctx);
|
|
25796
|
+
} else {
|
|
25797
|
+
interator(tree, ctx);
|
|
25798
|
+
}
|
|
25799
|
+
}
|
|
25800
|
+
},
|
|
25801
|
+
"C<>": wrapContent("`", "`"),
|
|
25802
|
+
"D<>": (writer, processor) => (node, ctx, interator) => {
|
|
25803
|
+
if (!writer.hasOwnProperty("DEFINITIONS")) {
|
|
25804
|
+
writer.DEFINITIONS = [];
|
|
25805
|
+
}
|
|
25806
|
+
writer.DEFINITIONS.push({ definition: [node.content[0]] });
|
|
25807
|
+
writer.writeRaw("**");
|
|
25808
|
+
interator(node.content, ctx);
|
|
25809
|
+
writer.writeRaw("**");
|
|
25810
|
+
},
|
|
25811
|
+
"B<>": wrapContent("**", "**"),
|
|
25812
|
+
"I<>": wrapContent("*", "*"),
|
|
25813
|
+
"R<>": wrapContent("*", "*"),
|
|
25814
|
+
"K<>": wrapContent("`", "`"),
|
|
25815
|
+
"L<>": setFn((node, ctx) => {
|
|
25816
|
+
let { meta } = node;
|
|
25817
|
+
if (meta === null) {
|
|
25818
|
+
meta = node.content;
|
|
25819
|
+
}
|
|
25820
|
+
return wrapContent(`[`, `](${meta})`);
|
|
25821
|
+
}),
|
|
25822
|
+
"N<>": (writer, processor) => {
|
|
25823
|
+
writer.addListener("end", () => {
|
|
25824
|
+
if (!writer.hasOwnProperty("FOOTNOTES")) {
|
|
25825
|
+
return;
|
|
25826
|
+
}
|
|
25827
|
+
const footnotes = writer.FOOTNOTES;
|
|
25828
|
+
if (footnotes.length < 1) {
|
|
25829
|
+
return;
|
|
25830
|
+
}
|
|
25831
|
+
writer.writeRaw("\n\n---\n\n");
|
|
25832
|
+
footnotes.map((footnote) => {
|
|
25833
|
+
writer.writeRaw(`[^${footnote.gid}]: `);
|
|
25834
|
+
footnote.make();
|
|
25835
|
+
writer.writeRaw("\n");
|
|
25836
|
+
});
|
|
25837
|
+
});
|
|
25838
|
+
return (node, ctx, interator) => {
|
|
25839
|
+
if (node.content.length < 1) {
|
|
25840
|
+
return;
|
|
25841
|
+
}
|
|
25842
|
+
if (!writer.hasOwnProperty("gid")) {
|
|
25843
|
+
writer.gid = 1;
|
|
25844
|
+
}
|
|
25845
|
+
const gid = writer.gid++;
|
|
25846
|
+
writer.writeRaw(`[^${gid}]`);
|
|
25847
|
+
if (!writer.hasOwnProperty("FOOTNOTES")) {
|
|
25848
|
+
writer.FOOTNOTES = [];
|
|
25849
|
+
}
|
|
25850
|
+
writer.FOOTNOTES.push({
|
|
25851
|
+
gid,
|
|
25852
|
+
fnRefId: `fnref:${gid}`,
|
|
25853
|
+
fnId: `fn:${gid}`,
|
|
25854
|
+
make: () => {
|
|
25855
|
+
interator(node.content, ctx);
|
|
25856
|
+
}
|
|
25857
|
+
});
|
|
25858
|
+
};
|
|
25859
|
+
},
|
|
25860
|
+
"S<>": (writer, processor) => (node, ctx, interator) => {
|
|
25861
|
+
const content4 = node.content || "";
|
|
25862
|
+
writer.writeRaw(content4.replace(/ /g, " ").replace(/\n/g, " \n"));
|
|
25863
|
+
},
|
|
25864
|
+
"T<>": wrapContent("`", "`"),
|
|
25865
|
+
"U<>": wrapContent("", ""),
|
|
25866
|
+
"V<>": content,
|
|
25867
|
+
"X<>": (writer, processor) => (node, ctx, interator) => {
|
|
25868
|
+
interator(node.content, ctx);
|
|
25869
|
+
let { entry } = node;
|
|
25870
|
+
if (entry === null && node.content.length > 0) {
|
|
25871
|
+
entry = [node.content[0]];
|
|
25872
|
+
} else {
|
|
25873
|
+
return;
|
|
25874
|
+
}
|
|
25875
|
+
if (!writer.hasOwnProperty("INDEXTERMS")) {
|
|
25876
|
+
writer.INDEXTERMS = [];
|
|
25877
|
+
}
|
|
25878
|
+
writer.INDEXTERMS.push({ entry });
|
|
25879
|
+
},
|
|
25880
|
+
"Z<>": emptyContent,
|
|
25881
|
+
pod: content,
|
|
25882
|
+
":code": (writer, processor) => (node, ctx, interator) => {
|
|
25883
|
+
const conf = config_default(node, ctx);
|
|
25884
|
+
const lang = conf.exists("lang") ? conf.getFirstValue("lang") : "";
|
|
25885
|
+
writer.writeRaw("```" + lang + "\n");
|
|
25886
|
+
if (node.content) {
|
|
25887
|
+
node.content.forEach((child) => {
|
|
25888
|
+
if (typeof child === "string") {
|
|
25889
|
+
writer.writeRaw(child);
|
|
25890
|
+
} else if (child.type === "verbatim") {
|
|
25891
|
+
writer.writeRaw(child.value);
|
|
25892
|
+
} else {
|
|
25893
|
+
interator([child], ctx);
|
|
25894
|
+
}
|
|
25895
|
+
});
|
|
25896
|
+
}
|
|
25897
|
+
writer.writeRaw("```\n");
|
|
25898
|
+
},
|
|
25899
|
+
code: handleNested((writer, processor) => (node, ctx, interator) => {
|
|
25900
|
+
const conf = config_default(node, ctx);
|
|
25901
|
+
const lang = conf.exists("lang") ? conf.getFirstValue("lang") : "";
|
|
25902
|
+
writer.writeRaw("```" + lang + "\n");
|
|
25903
|
+
if (node.content) {
|
|
25904
|
+
node.content.forEach((child) => {
|
|
25905
|
+
if (typeof child === "string") {
|
|
25906
|
+
writer.writeRaw(child);
|
|
25907
|
+
} else if (child.type === "verbatim") {
|
|
25908
|
+
writer.writeRaw(child.value);
|
|
25909
|
+
} else {
|
|
25910
|
+
interator([child], ctx);
|
|
25911
|
+
}
|
|
25912
|
+
});
|
|
25913
|
+
}
|
|
25914
|
+
writer.writeRaw("```\n");
|
|
25915
|
+
}),
|
|
25916
|
+
data: emptyContent,
|
|
25917
|
+
":verbatim": (writer, processor) => (node, ctx, interator) => {
|
|
25918
|
+
if (node.error) {
|
|
25919
|
+
writer.emit("errors", node.location);
|
|
25920
|
+
}
|
|
25921
|
+
writer.writeRaw(node.value);
|
|
25922
|
+
},
|
|
25923
|
+
":blankline": emptyContent,
|
|
25924
|
+
":ambient": emptyContent,
|
|
25925
|
+
":config": setFn((node, ctx) => {
|
|
25926
|
+
if (!ctx.hasOwnProperty("config"))
|
|
25927
|
+
ctx.config = {};
|
|
25928
|
+
ctx.config[node.name] = node.config;
|
|
25929
|
+
return emptyContent;
|
|
25930
|
+
}),
|
|
25931
|
+
":alias": setFn((node, ctx) => {
|
|
25932
|
+
if (!ctx.hasOwnProperty("alias"))
|
|
25933
|
+
ctx.alias = {};
|
|
25934
|
+
ctx.alias[node.name] = node.replacement;
|
|
25935
|
+
return emptyContent;
|
|
25936
|
+
}),
|
|
25937
|
+
para: handleNested(content),
|
|
25938
|
+
":para": (writer, processor) => (node, ctx, interator) => {
|
|
25939
|
+
if (node.content)
|
|
25940
|
+
interator(node.content, ctx);
|
|
25941
|
+
writer.writeRaw("\n");
|
|
25942
|
+
},
|
|
25943
|
+
"head:block": subUse(
|
|
25944
|
+
{
|
|
25945
|
+
":para": content
|
|
25946
|
+
},
|
|
25947
|
+
setFn((node, ctx) => {
|
|
25948
|
+
const { level } = node;
|
|
25949
|
+
const prefix = "#".repeat(level) + " ";
|
|
25950
|
+
return (writer, processor) => (node2, ctx2, interator) => {
|
|
25951
|
+
writer.writeRaw(prefix);
|
|
25952
|
+
if (node2.content)
|
|
25953
|
+
interator(node2.content, ctx2);
|
|
25954
|
+
writer.writeRaw("\n");
|
|
25955
|
+
};
|
|
25956
|
+
})
|
|
25957
|
+
),
|
|
25958
|
+
":list": setFn((node, ctx) => {
|
|
25959
|
+
return (writer, processor) => (node2, ctx2, interator) => {
|
|
25960
|
+
const newCtx = {
|
|
25961
|
+
...ctx2,
|
|
25962
|
+
listType: node2.list,
|
|
25963
|
+
listCounter: { value: 1 },
|
|
25964
|
+
listDepth: (ctx2.listDepth || 0) + 1
|
|
25965
|
+
};
|
|
25966
|
+
if (node2.content)
|
|
25967
|
+
interator(node2.content, newCtx);
|
|
25968
|
+
};
|
|
25969
|
+
}),
|
|
25970
|
+
"item:block": (writer, processor) => (node, ctx, interator) => {
|
|
25971
|
+
const indent2 = " ".repeat(Math.max(0, (ctx.listDepth || 1) - 1));
|
|
25972
|
+
const listType = ctx.listType || "unordered";
|
|
25973
|
+
let prefix;
|
|
25974
|
+
if (listType === "ordered") {
|
|
25975
|
+
const counter = ctx.listCounter || { value: 1 };
|
|
25976
|
+
prefix = `${counter.value}. `;
|
|
25977
|
+
counter.value++;
|
|
25978
|
+
} else if (listType === "variable") {
|
|
25979
|
+
prefix = "- ";
|
|
25980
|
+
} else {
|
|
25981
|
+
prefix = "- ";
|
|
25982
|
+
}
|
|
25983
|
+
writer.writeRaw(indent2 + prefix);
|
|
25984
|
+
if (node.content)
|
|
25985
|
+
interator(node.content, ctx);
|
|
25986
|
+
},
|
|
25987
|
+
"comment:block": emptyContent,
|
|
25988
|
+
defn: (writer, processor) => (node, ctx, interator) => {
|
|
25989
|
+
if (node.content)
|
|
25990
|
+
interator(node.content, ctx);
|
|
25991
|
+
writer.writeRaw("\n");
|
|
25992
|
+
},
|
|
25993
|
+
"term:para": (writer, processor) => (node, ctx, interator) => {
|
|
25994
|
+
writer.writeRaw("**");
|
|
25995
|
+
if (node.content)
|
|
25996
|
+
interator(node.content, ctx);
|
|
25997
|
+
writer.writeRaw(":** ");
|
|
25998
|
+
},
|
|
25999
|
+
nested: handleNested(content, 1),
|
|
26000
|
+
output: handleNested(
|
|
26001
|
+
(writer, processor) => (node, ctx, interator) => {
|
|
26002
|
+
writer.writeRaw("```\n");
|
|
26003
|
+
if (node.content)
|
|
26004
|
+
interator(node.content, ctx);
|
|
26005
|
+
writer.writeRaw("```\n");
|
|
26006
|
+
},
|
|
26007
|
+
1
|
|
26008
|
+
),
|
|
26009
|
+
input: handleNested(
|
|
26010
|
+
(writer, processor) => (node, ctx, interator) => {
|
|
26011
|
+
writer.writeRaw("```\n");
|
|
26012
|
+
if (node.content)
|
|
26013
|
+
interator(node.content, ctx);
|
|
26014
|
+
writer.writeRaw("```\n");
|
|
26015
|
+
},
|
|
26016
|
+
1
|
|
26017
|
+
),
|
|
26018
|
+
"table:block": handleNested((writer, processor) => (node, ctx, interator) => {
|
|
26019
|
+
const conf = config_default(node, ctx);
|
|
26020
|
+
if (conf.exists("caption")) {
|
|
26021
|
+
writer.writeRaw("**");
|
|
26022
|
+
writer.write(conf.getFirstValue("caption"));
|
|
26023
|
+
writer.writeRaw("**\n\n");
|
|
26024
|
+
}
|
|
26025
|
+
const rows = (node.content || []).filter((child) => child.name === "table_row" || child.name === "table_head");
|
|
26026
|
+
if (rows.length === 0)
|
|
26027
|
+
return;
|
|
26028
|
+
const hasHeader = rows[0].name === "table_head";
|
|
26029
|
+
rows.forEach((row, rowIndex) => {
|
|
26030
|
+
const cells = (row.content || []).filter((c) => c.name === "table_cell");
|
|
26031
|
+
writer.writeRaw("|");
|
|
26032
|
+
cells.forEach((cell) => {
|
|
26033
|
+
writer.writeRaw(" ");
|
|
26034
|
+
if (cell.content) {
|
|
26035
|
+
cell.content.forEach((c) => {
|
|
26036
|
+
if (typeof c === "string") {
|
|
26037
|
+
writer.write(c.trim());
|
|
26038
|
+
} else {
|
|
26039
|
+
interator([c], ctx);
|
|
26040
|
+
}
|
|
26041
|
+
});
|
|
26042
|
+
}
|
|
26043
|
+
writer.writeRaw(" |");
|
|
26044
|
+
});
|
|
26045
|
+
writer.writeRaw("\n");
|
|
26046
|
+
if (rowIndex === 0 && hasHeader) {
|
|
26047
|
+
writer.writeRaw("|");
|
|
26048
|
+
cells.forEach(() => {
|
|
26049
|
+
writer.writeRaw(" --- |");
|
|
26050
|
+
});
|
|
26051
|
+
writer.writeRaw("\n");
|
|
26052
|
+
}
|
|
26053
|
+
if (rowIndex === 0 && !hasHeader) {
|
|
26054
|
+
writer.writeRaw("|");
|
|
26055
|
+
cells.forEach(() => {
|
|
26056
|
+
writer.writeRaw(" --- |");
|
|
26057
|
+
});
|
|
26058
|
+
writer.writeRaw("\n");
|
|
26059
|
+
}
|
|
26060
|
+
});
|
|
26061
|
+
writer.writeRaw("\n");
|
|
26062
|
+
}),
|
|
26063
|
+
":separator": emptyContent,
|
|
26064
|
+
table_row: emptyContent,
|
|
26065
|
+
table_cell: emptyContent,
|
|
26066
|
+
table_head: emptyContent,
|
|
26067
|
+
":toc": emptyContent,
|
|
26068
|
+
":toc-list": emptyContent,
|
|
26069
|
+
":toc-item": emptyContent,
|
|
26070
|
+
":image": (writer, processor) => (node, ctx, interator) => {
|
|
26071
|
+
writer.writeRaw(``);
|
|
26072
|
+
}
|
|
26073
|
+
};
|
|
26074
|
+
|
|
25772
26075
|
// ../podlite-schema/src/helpers/ids.ts
|
|
25773
26076
|
var import_slugify = __toESM(require_slugify());
|
|
25774
26077
|
|
|
@@ -25869,9 +26172,30 @@ var plugin_items_default = () => (tree) => {
|
|
|
25869
26172
|
if (matchItem) {
|
|
25870
26173
|
node.name = "item";
|
|
25871
26174
|
node.level = matchItem[1] || 1;
|
|
26175
|
+
const checkedConfig = (node.config || []).find((c) => c.name === "checked");
|
|
26176
|
+
if (checkedConfig) {
|
|
26177
|
+
node.checked = checkedConfig.value !== false && checkedConfig.value !== 0 && checkedConfig.value !== "0";
|
|
26178
|
+
}
|
|
25872
26179
|
if (node.content[0]) {
|
|
25873
26180
|
const startText = node.content[0];
|
|
25874
26181
|
if (startText.text) {
|
|
26182
|
+
if (!checkedConfig) {
|
|
26183
|
+
const checkboxRe = /^\[( |x)\]\s*/;
|
|
26184
|
+
const checkboxMatch = checkboxRe.exec(startText.text);
|
|
26185
|
+
if (checkboxMatch) {
|
|
26186
|
+
node.checked = checkboxMatch[1] === "x";
|
|
26187
|
+
startText.text = startText.text.replace(checkboxRe, "");
|
|
26188
|
+
if (startText.type === "para") {
|
|
26189
|
+
startText.content = [startText.text];
|
|
26190
|
+
}
|
|
26191
|
+
node.config = node.config || [];
|
|
26192
|
+
node.config.push({
|
|
26193
|
+
name: "checked",
|
|
26194
|
+
value: node.checked,
|
|
26195
|
+
type: "boolean"
|
|
26196
|
+
});
|
|
26197
|
+
}
|
|
26198
|
+
}
|
|
25875
26199
|
let re = /^(\s*#\s*)/;
|
|
25876
26200
|
const match = re.exec(startText.text);
|
|
25877
26201
|
if (match) {
|
|
@@ -25984,8 +26308,9 @@ var plugin_group_defn_default = () => (tree) => {
|
|
|
25984
26308
|
|
|
25985
26309
|
// ../podlite-schema/src/plugin-group-items.ts
|
|
25986
26310
|
var plugin_group_items_default = () => (tree) => {
|
|
25987
|
-
const isNodesEqual = (n1, n2) => (n1.name === "item" || n1.name === "defn") && n2.name === n1.name && n1["level"] === n2.level && isNumbered(n1) === isNumbered(n2);
|
|
26311
|
+
const isNodesEqual = (n1, n2) => (n1.name === "item" || n1.name === "defn") && n2.name === n1.name && n1["level"] === n2.level && isNumbered(n1) === isNumbered(n2) && isChecked(n1) === isChecked(n2);
|
|
25988
26312
|
const isNumbered = (node) => Boolean(config_default(node, {}).exists("numbered"));
|
|
26313
|
+
const isChecked = (node) => node.checked !== void 0;
|
|
25989
26314
|
const group = (a, level = 1) => {
|
|
25990
26315
|
const isInListMode = (a2) => {
|
|
25991
26316
|
return a2.length > 0 && a2[a2.length - 1].type === "list";
|
|
@@ -26000,12 +26325,12 @@ var plugin_group_items_default = () => (tree) => {
|
|
|
26000
26325
|
if (i.name === "item" && i.type === "block" && i.level < level) {
|
|
26001
26326
|
return [...a2, i];
|
|
26002
26327
|
}
|
|
26003
|
-
if (i.name === "item" && i.type === "block" && (!isInListMode(a2) || i.level === level && getList(a2).list !== (isNumbered(i) ? "ordered" : "itemized"))) {
|
|
26328
|
+
if (i.name === "item" && i.type === "block" && (!isInListMode(a2) || Number(i.level) === level && getList(a2).list !== (isNumbered(i) ? "ordered" : isChecked(i) ? "task" : "itemized"))) {
|
|
26004
26329
|
a2.push({
|
|
26005
26330
|
type: "list",
|
|
26006
26331
|
level: i.level,
|
|
26007
26332
|
content: [],
|
|
26008
|
-
list: isNumbered(i) ? "ordered" : "itemized"
|
|
26333
|
+
list: isNumbered(i) ? "ordered" : isChecked(i) ? "task" : "itemized"
|
|
26009
26334
|
});
|
|
26010
26335
|
}
|
|
26011
26336
|
if (isInListMode(a2) && isInsertableToList(getList(a2), i)) {
|
|
@@ -26017,7 +26342,7 @@ var plugin_group_items_default = () => (tree) => {
|
|
|
26017
26342
|
}, []);
|
|
26018
26343
|
return result.map((item) => {
|
|
26019
26344
|
if (item.content && item.type !== "fcode") {
|
|
26020
|
-
item.content = group(item.content, item.level + 1);
|
|
26345
|
+
item.content = group(item.content, Number(item.level || 0) + 1);
|
|
26021
26346
|
}
|
|
26022
26347
|
return item;
|
|
26023
26348
|
});
|
|
@@ -26195,7 +26520,7 @@ var plugin_tables_default = () => (tree) => {
|
|
|
26195
26520
|
};
|
|
26196
26521
|
|
|
26197
26522
|
// ../podlite-schema/src/exportHtml.ts
|
|
26198
|
-
var
|
|
26523
|
+
var rules2 = {
|
|
26199
26524
|
":text": (writer, processor) => (node, ctx, interator) => {
|
|
26200
26525
|
if (node.value) {
|
|
26201
26526
|
writer.write(node.value);
|
|
@@ -26348,14 +26673,19 @@ var rules = {
|
|
|
26348
26673
|
})
|
|
26349
26674
|
),
|
|
26350
26675
|
":list": setFn(
|
|
26351
|
-
(node, ctx) => node.list === "ordered" ? wrapContent("<ol>", "</ol>") : node.list === "variable" ? wrapContent("<dl>", "</dl>") : wrapContent("<ul>", "</ul>")
|
|
26676
|
+
(node, ctx) => node.list === "ordered" ? wrapContent("<ol>", "</ol>") : node.list === "variable" ? wrapContent("<dl>", "</dl>") : node.list === "task" ? wrapContent('<ul class="task-list">', "</ul>") : wrapContent("<ul>", "</ul>")
|
|
26352
26677
|
),
|
|
26353
26678
|
"item:block": (writer, processor) => (node, ctx, interator) => {
|
|
26354
26679
|
if (!(node.content instanceof Array)) {
|
|
26355
26680
|
console.error("[pod6] item:block : Error in content of " + JSON.stringify(node));
|
|
26356
26681
|
}
|
|
26357
|
-
const
|
|
26358
|
-
|
|
26682
|
+
const isTask = node.checked !== void 0;
|
|
26683
|
+
if (isTask) {
|
|
26684
|
+
writer.writeRaw('<li class="task-list-item">');
|
|
26685
|
+
writer.writeRaw(node.checked ? '<input type="checkbox" disabled checked> ' : '<input type="checkbox" disabled> ');
|
|
26686
|
+
} else {
|
|
26687
|
+
writer.writeRaw("<li>");
|
|
26688
|
+
}
|
|
26359
26689
|
interator(node.content, ctx);
|
|
26360
26690
|
writer.writeRaw("</li>");
|
|
26361
26691
|
},
|
|
@@ -26456,7 +26786,7 @@ function bail(error) {
|
|
|
26456
26786
|
var import_is_buffer2 = __toESM(require_is_buffer(), 1);
|
|
26457
26787
|
var import_extend = __toESM(require_extend(), 1);
|
|
26458
26788
|
|
|
26459
|
-
// ../../node_modules/
|
|
26789
|
+
// ../../node_modules/is-plain-obj/index.js
|
|
26460
26790
|
function isPlainObject(value) {
|
|
26461
26791
|
if (typeof value !== "object" || value === null) {
|
|
26462
26792
|
return false;
|
|
@@ -35053,11 +35383,18 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
35053
35383
|
},
|
|
35054
35384
|
":listItem": (writer, processor) => (node, ctx, interator) => {
|
|
35055
35385
|
const savedListLevel = ctx["listLevel"] || 0;
|
|
35056
|
-
const { children, position: position2, ...attr } = node;
|
|
35057
|
-
|
|
35058
|
-
|
|
35059
|
-
|
|
35060
|
-
|
|
35386
|
+
const { children, position: position2, checked, ...attr } = node;
|
|
35387
|
+
const blockAttrs = {
|
|
35388
|
+
name: "item",
|
|
35389
|
+
type: "block",
|
|
35390
|
+
level: ctx["listLevel"],
|
|
35391
|
+
location: applyLineOffset(position2)
|
|
35392
|
+
};
|
|
35393
|
+
if (checked !== null && checked !== void 0) {
|
|
35394
|
+
blockAttrs.checked = checked;
|
|
35395
|
+
blockAttrs.config = [{ name: "checked", value: checked, type: "boolean" }];
|
|
35396
|
+
}
|
|
35397
|
+
return mkBlock(blockAttrs, interator(children, { ...ctx, listLevel: savedListLevel, ordered: node.ordered }));
|
|
35061
35398
|
},
|
|
35062
35399
|
":paragraph": (writer, processor) => (node, ctx, interator) => {
|
|
35063
35400
|
const { children, position: position2, ...attr } = node;
|