@podlite/markdown 0.0.26 → 0.0.28
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 +415 -45
- package/lib/index.esm.js.map +4 -4
- package/package.json +20 -5
- 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: [
|
|
@@ -9297,6 +9300,15 @@ var require_AstTree = __commonJS({
|
|
|
9297
9300
|
title: {
|
|
9298
9301
|
type: "string"
|
|
9299
9302
|
},
|
|
9303
|
+
foldedLevels: {
|
|
9304
|
+
type: "object",
|
|
9305
|
+
additionalProperties: false,
|
|
9306
|
+
patternProperties: {
|
|
9307
|
+
"^[0-9]+$": {
|
|
9308
|
+
type: "boolean"
|
|
9309
|
+
}
|
|
9310
|
+
}
|
|
9311
|
+
},
|
|
9300
9312
|
content: {
|
|
9301
9313
|
$ref: "#/definitions/TocList"
|
|
9302
9314
|
}
|
|
@@ -11057,6 +11069,9 @@ var require_PodliteDocument = __commonJS({
|
|
|
11057
11069
|
"number"
|
|
11058
11070
|
]
|
|
11059
11071
|
},
|
|
11072
|
+
checked: {
|
|
11073
|
+
type: "boolean"
|
|
11074
|
+
},
|
|
11060
11075
|
type: {
|
|
11061
11076
|
type: "string",
|
|
11062
11077
|
enum: [
|
|
@@ -12059,6 +12074,15 @@ var require_PodliteDocument = __commonJS({
|
|
|
12059
12074
|
title: {
|
|
12060
12075
|
type: "string"
|
|
12061
12076
|
},
|
|
12077
|
+
foldedLevels: {
|
|
12078
|
+
type: "object",
|
|
12079
|
+
additionalProperties: false,
|
|
12080
|
+
patternProperties: {
|
|
12081
|
+
"^[0-9]+$": {
|
|
12082
|
+
type: "boolean"
|
|
12083
|
+
}
|
|
12084
|
+
}
|
|
12085
|
+
},
|
|
12062
12086
|
content: {
|
|
12063
12087
|
$ref: "#/definitions/TocList"
|
|
12064
12088
|
}
|
|
@@ -12778,7 +12802,7 @@ var require_grammar = __commonJS({
|
|
|
12778
12802
|
config,
|
|
12779
12803
|
location: location()
|
|
12780
12804
|
};
|
|
12781
|
-
}, peg$c125 = /^[
|
|
12805
|
+
}, peg$c125 = /^[\-+=_|]/, peg$c126 = peg$classExpectation(["-", "+", "=", "_", "|"], false, false), peg$c127 = function() {
|
|
12782
12806
|
return { type: "separator", text: text4() };
|
|
12783
12807
|
}, peg$c128 = function() {
|
|
12784
12808
|
return options.isDelimited;
|
|
@@ -25081,9 +25105,18 @@ var require_package = __commonJS({
|
|
|
25081
25105
|
"../podlite-schema/package.json"(exports, module) {
|
|
25082
25106
|
module.exports = {
|
|
25083
25107
|
name: "@podlite/schema",
|
|
25084
|
-
version: "0.0.
|
|
25085
|
-
description: "AST tools for Podlite markup language",
|
|
25108
|
+
version: "0.0.35",
|
|
25109
|
+
description: "AST tools and schema for Podlite markup language \u2014 validate, traverse, and transform document trees",
|
|
25086
25110
|
main: "./src/index.ts",
|
|
25111
|
+
homepage: "https://podlite.org",
|
|
25112
|
+
bugs: {
|
|
25113
|
+
url: "https://github.com/podlite/podlite/issues"
|
|
25114
|
+
},
|
|
25115
|
+
repository: {
|
|
25116
|
+
type: "git",
|
|
25117
|
+
url: "https://github.com/podlite/podlite.git",
|
|
25118
|
+
directory: "packages/podlite-schema"
|
|
25119
|
+
},
|
|
25087
25120
|
license: "MIT",
|
|
25088
25121
|
funding: {
|
|
25089
25122
|
type: "opencollective",
|
|
@@ -25112,16 +25145,22 @@ var require_package = __commonJS({
|
|
|
25112
25145
|
build: "run-s build:pegjs build_lib build:ast ",
|
|
25113
25146
|
build_lib: "yarn g:build",
|
|
25114
25147
|
"build:ast": "ts-node scripts/make-ast-scheme.ts",
|
|
25115
|
-
"build:pegjs": "
|
|
25148
|
+
"build:pegjs": "pegmill -o src/grammar.js src/grammar.pegjs && pegmill -o src/grammarfc.js src/grammarfc.pegjs",
|
|
25116
25149
|
watch: "npx nodemon -e js,ts --exec 'yarn' build",
|
|
25117
|
-
"watch:pegjs": "npx nodemon -e
|
|
25150
|
+
"watch:pegjs": "npx nodemon -e pegmill --exec 'yarn' build:pegjs",
|
|
25118
25151
|
test: "yarn g:jest --passWithNoTests"
|
|
25119
25152
|
},
|
|
25120
25153
|
keywords: [
|
|
25121
|
-
"markdown",
|
|
25122
25154
|
"podlite",
|
|
25123
|
-
"
|
|
25124
|
-
"
|
|
25155
|
+
"schema",
|
|
25156
|
+
"ast",
|
|
25157
|
+
"syntax-tree",
|
|
25158
|
+
"markup-language",
|
|
25159
|
+
"transform",
|
|
25160
|
+
"visitor",
|
|
25161
|
+
"parser",
|
|
25162
|
+
"markdown",
|
|
25163
|
+
"tree"
|
|
25125
25164
|
],
|
|
25126
25165
|
dependencies: {
|
|
25127
25166
|
ajv: "^7.2.3",
|
|
@@ -25134,7 +25173,7 @@ var require_package = __commonJS({
|
|
|
25134
25173
|
"@types/node": "^17.0.7",
|
|
25135
25174
|
glob: "^7.2.0",
|
|
25136
25175
|
"npm-run-all": "^4.1.5",
|
|
25137
|
-
|
|
25176
|
+
pegmill: "0.1.0",
|
|
25138
25177
|
"ts-node": "^9.1.1",
|
|
25139
25178
|
typescript: "4.5.5",
|
|
25140
25179
|
"typescript-json-schema": "0.53.0"
|
|
@@ -25342,13 +25381,13 @@ var makeRulesArray = (key, fn) => {
|
|
|
25342
25381
|
}, []);
|
|
25343
25382
|
}
|
|
25344
25383
|
if (key instanceof Object) {
|
|
25345
|
-
let
|
|
25384
|
+
let rules3 = [];
|
|
25346
25385
|
for (var prop in key) {
|
|
25347
25386
|
if (key.hasOwnProperty(prop)) {
|
|
25348
|
-
|
|
25387
|
+
rules3.push(makeRule(makePlug(prop), key[prop]));
|
|
25349
25388
|
}
|
|
25350
25389
|
}
|
|
25351
|
-
return
|
|
25390
|
+
return rules3;
|
|
25352
25391
|
}
|
|
25353
25392
|
return [makeRule(makePlug(key), fn)];
|
|
25354
25393
|
};
|
|
@@ -25490,7 +25529,7 @@ function flattenDeep(arr) {
|
|
|
25490
25529
|
}
|
|
25491
25530
|
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);
|
|
25492
25531
|
}
|
|
25493
|
-
function thisFunc(
|
|
25532
|
+
function thisFunc(rules3) {
|
|
25494
25533
|
function interator(node, context) {
|
|
25495
25534
|
if (node == null) {
|
|
25496
25535
|
return node;
|
|
@@ -25501,7 +25540,7 @@ function thisFunc(rules2) {
|
|
|
25501
25540
|
if ("string" === typeof node) {
|
|
25502
25541
|
return interator({ type: "text", value: node }, context);
|
|
25503
25542
|
}
|
|
25504
|
-
const reversed =
|
|
25543
|
+
const reversed = rules3.slice();
|
|
25505
25544
|
reversed.reverse();
|
|
25506
25545
|
const ruleIndex = reversed.findIndex((rule) => rule.isFor(node));
|
|
25507
25546
|
if (ruleIndex !== -1) {
|
|
@@ -25526,7 +25565,7 @@ function thisFunc(rules2) {
|
|
|
25526
25565
|
}
|
|
25527
25566
|
}
|
|
25528
25567
|
}
|
|
25529
|
-
interator.rules =
|
|
25568
|
+
interator.rules = rules3;
|
|
25530
25569
|
return interator;
|
|
25531
25570
|
}
|
|
25532
25571
|
var makeInterator_default = thisFunc;
|
|
@@ -25550,8 +25589,8 @@ var setFn = (check) => (writer, processor) => {
|
|
|
25550
25589
|
return check(node, ctx)(writer, processor)(node, ctx, interator);
|
|
25551
25590
|
};
|
|
25552
25591
|
};
|
|
25553
|
-
var subUse = (
|
|
25554
|
-
const newFns = makeRulesArray(
|
|
25592
|
+
var subUse = (rules3, processNode) => {
|
|
25593
|
+
const newFns = makeRulesArray(rules3).reverse();
|
|
25555
25594
|
return (writer, processor) => {
|
|
25556
25595
|
const inited = newFns.map((item) => makeRule(item.rule, item.fn(writer, processor))).reverse();
|
|
25557
25596
|
const processNodeInited = processNode(writer, processor);
|
|
@@ -25587,7 +25626,7 @@ function flattenDeep2(arr) {
|
|
|
25587
25626
|
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep2(val)) : acc.concat(val), []);
|
|
25588
25627
|
}
|
|
25589
25628
|
var makeTransformer = (rule) => {
|
|
25590
|
-
let
|
|
25629
|
+
let rules3 = [];
|
|
25591
25630
|
function use(key, fn) {
|
|
25592
25631
|
if (key instanceof Array) {
|
|
25593
25632
|
console.warn(`[podlite] Unsupported param for ${key}`);
|
|
@@ -25600,7 +25639,7 @@ var makeTransformer = (rule) => {
|
|
|
25600
25639
|
}
|
|
25601
25640
|
return [];
|
|
25602
25641
|
}
|
|
25603
|
-
|
|
25642
|
+
rules3.push(makeRule(makePlug(key), fn));
|
|
25604
25643
|
}
|
|
25605
25644
|
function visiter(node, context = {}) {
|
|
25606
25645
|
if (node == null) {
|
|
@@ -25612,7 +25651,7 @@ var makeTransformer = (rule) => {
|
|
|
25612
25651
|
if ("string" === typeof node) {
|
|
25613
25652
|
return node;
|
|
25614
25653
|
}
|
|
25615
|
-
const reversed =
|
|
25654
|
+
const reversed = rules3.slice();
|
|
25616
25655
|
reversed.reverse();
|
|
25617
25656
|
const ruleIndex = reversed.findIndex((rule2) => rule2.isFor(node));
|
|
25618
25657
|
if (ruleIndex !== -1) {
|
|
@@ -25626,7 +25665,7 @@ var makeTransformer = (rule) => {
|
|
|
25626
25665
|
}
|
|
25627
25666
|
}
|
|
25628
25667
|
use(rule);
|
|
25629
|
-
visiter.rules =
|
|
25668
|
+
visiter.rules = rules3;
|
|
25630
25669
|
return visiter;
|
|
25631
25670
|
};
|
|
25632
25671
|
var makeTransformer_default = makeTransformer;
|
|
@@ -25769,6 +25808,303 @@ var pluginCleanLocation = () => (tree) => {
|
|
|
25769
25808
|
};
|
|
25770
25809
|
var plugin_clean_location_default = pluginCleanLocation;
|
|
25771
25810
|
|
|
25811
|
+
// ../podlite-schema/src/exportMarkdown.ts
|
|
25812
|
+
var rules = {
|
|
25813
|
+
":text": (writer, processor) => (node, ctx, interator) => {
|
|
25814
|
+
if (node.value) {
|
|
25815
|
+
writer.write(node.value);
|
|
25816
|
+
} else {
|
|
25817
|
+
interator(node.content, ctx);
|
|
25818
|
+
}
|
|
25819
|
+
},
|
|
25820
|
+
"A<>": (writer, processor) => (node, ctx, interator) => {
|
|
25821
|
+
if (!(ctx.alias && ctx.alias.hasOwnProperty(node.content))) {
|
|
25822
|
+
writer.writeRaw(`A<${node.content}>`);
|
|
25823
|
+
} else {
|
|
25824
|
+
const src = ctx.alias[node.content].join("\n");
|
|
25825
|
+
const tree_1 = processor(src);
|
|
25826
|
+
const tree = plugin_clean_location_default()(tree_1);
|
|
25827
|
+
if (tree[0].type === "para") {
|
|
25828
|
+
interator(tree[0].content, ctx);
|
|
25829
|
+
} else {
|
|
25830
|
+
interator(tree, ctx);
|
|
25831
|
+
}
|
|
25832
|
+
}
|
|
25833
|
+
},
|
|
25834
|
+
"C<>": wrapContent("`", "`"),
|
|
25835
|
+
"D<>": (writer, processor) => (node, ctx, interator) => {
|
|
25836
|
+
if (!writer.hasOwnProperty("DEFINITIONS")) {
|
|
25837
|
+
writer.DEFINITIONS = [];
|
|
25838
|
+
}
|
|
25839
|
+
writer.DEFINITIONS.push({ definition: [node.content[0]] });
|
|
25840
|
+
writer.writeRaw("**");
|
|
25841
|
+
interator(node.content, ctx);
|
|
25842
|
+
writer.writeRaw("**");
|
|
25843
|
+
},
|
|
25844
|
+
"B<>": wrapContent("**", "**"),
|
|
25845
|
+
"I<>": wrapContent("*", "*"),
|
|
25846
|
+
"R<>": wrapContent("*", "*"),
|
|
25847
|
+
"K<>": wrapContent("`", "`"),
|
|
25848
|
+
"L<>": setFn((node, ctx) => {
|
|
25849
|
+
let { meta } = node;
|
|
25850
|
+
if (meta === null) {
|
|
25851
|
+
meta = node.content;
|
|
25852
|
+
}
|
|
25853
|
+
return wrapContent(`[`, `](${meta})`);
|
|
25854
|
+
}),
|
|
25855
|
+
"N<>": (writer, processor) => {
|
|
25856
|
+
writer.addListener("end", () => {
|
|
25857
|
+
if (!writer.hasOwnProperty("FOOTNOTES")) {
|
|
25858
|
+
return;
|
|
25859
|
+
}
|
|
25860
|
+
const footnotes = writer.FOOTNOTES;
|
|
25861
|
+
if (footnotes.length < 1) {
|
|
25862
|
+
return;
|
|
25863
|
+
}
|
|
25864
|
+
writer.writeRaw("\n\n---\n\n");
|
|
25865
|
+
footnotes.map((footnote) => {
|
|
25866
|
+
writer.writeRaw(`[^${footnote.gid}]: `);
|
|
25867
|
+
footnote.make();
|
|
25868
|
+
writer.writeRaw("\n");
|
|
25869
|
+
});
|
|
25870
|
+
});
|
|
25871
|
+
return (node, ctx, interator) => {
|
|
25872
|
+
if (node.content.length < 1) {
|
|
25873
|
+
return;
|
|
25874
|
+
}
|
|
25875
|
+
if (!writer.hasOwnProperty("gid")) {
|
|
25876
|
+
writer.gid = 1;
|
|
25877
|
+
}
|
|
25878
|
+
const gid = writer.gid++;
|
|
25879
|
+
writer.writeRaw(`[^${gid}]`);
|
|
25880
|
+
if (!writer.hasOwnProperty("FOOTNOTES")) {
|
|
25881
|
+
writer.FOOTNOTES = [];
|
|
25882
|
+
}
|
|
25883
|
+
writer.FOOTNOTES.push({
|
|
25884
|
+
gid,
|
|
25885
|
+
fnRefId: `fnref:${gid}`,
|
|
25886
|
+
fnId: `fn:${gid}`,
|
|
25887
|
+
make: () => {
|
|
25888
|
+
interator(node.content, ctx);
|
|
25889
|
+
}
|
|
25890
|
+
});
|
|
25891
|
+
};
|
|
25892
|
+
},
|
|
25893
|
+
"S<>": (writer, processor) => (node, ctx, interator) => {
|
|
25894
|
+
const content4 = node.content || "";
|
|
25895
|
+
writer.writeRaw(content4.replace(/ /g, " ").replace(/\n/g, " \n"));
|
|
25896
|
+
},
|
|
25897
|
+
"T<>": wrapContent("`", "`"),
|
|
25898
|
+
"U<>": wrapContent("", ""),
|
|
25899
|
+
"V<>": content,
|
|
25900
|
+
"X<>": (writer, processor) => (node, ctx, interator) => {
|
|
25901
|
+
interator(node.content, ctx);
|
|
25902
|
+
let { entry } = node;
|
|
25903
|
+
if (entry === null && node.content.length > 0) {
|
|
25904
|
+
entry = [node.content[0]];
|
|
25905
|
+
} else {
|
|
25906
|
+
return;
|
|
25907
|
+
}
|
|
25908
|
+
if (!writer.hasOwnProperty("INDEXTERMS")) {
|
|
25909
|
+
writer.INDEXTERMS = [];
|
|
25910
|
+
}
|
|
25911
|
+
writer.INDEXTERMS.push({ entry });
|
|
25912
|
+
},
|
|
25913
|
+
"Z<>": emptyContent,
|
|
25914
|
+
pod: content,
|
|
25915
|
+
":code": (writer, processor) => (node, ctx, interator) => {
|
|
25916
|
+
const conf = config_default(node, ctx);
|
|
25917
|
+
const lang = conf.exists("lang") ? conf.getFirstValue("lang") : "";
|
|
25918
|
+
writer.writeRaw("```" + lang + "\n");
|
|
25919
|
+
if (node.content) {
|
|
25920
|
+
node.content.forEach((child) => {
|
|
25921
|
+
if (typeof child === "string") {
|
|
25922
|
+
writer.writeRaw(child);
|
|
25923
|
+
} else if (child.type === "verbatim") {
|
|
25924
|
+
writer.writeRaw(child.value);
|
|
25925
|
+
} else {
|
|
25926
|
+
interator([child], ctx);
|
|
25927
|
+
}
|
|
25928
|
+
});
|
|
25929
|
+
}
|
|
25930
|
+
writer.writeRaw("```\n");
|
|
25931
|
+
},
|
|
25932
|
+
code: handleNested((writer, processor) => (node, ctx, interator) => {
|
|
25933
|
+
const conf = config_default(node, ctx);
|
|
25934
|
+
const lang = conf.exists("lang") ? conf.getFirstValue("lang") : "";
|
|
25935
|
+
writer.writeRaw("```" + lang + "\n");
|
|
25936
|
+
if (node.content) {
|
|
25937
|
+
node.content.forEach((child) => {
|
|
25938
|
+
if (typeof child === "string") {
|
|
25939
|
+
writer.writeRaw(child);
|
|
25940
|
+
} else if (child.type === "verbatim") {
|
|
25941
|
+
writer.writeRaw(child.value);
|
|
25942
|
+
} else {
|
|
25943
|
+
interator([child], ctx);
|
|
25944
|
+
}
|
|
25945
|
+
});
|
|
25946
|
+
}
|
|
25947
|
+
writer.writeRaw("```\n");
|
|
25948
|
+
}),
|
|
25949
|
+
data: emptyContent,
|
|
25950
|
+
":verbatim": (writer, processor) => (node, ctx, interator) => {
|
|
25951
|
+
if (node.error) {
|
|
25952
|
+
writer.emit("errors", node.location);
|
|
25953
|
+
}
|
|
25954
|
+
writer.writeRaw(node.value);
|
|
25955
|
+
},
|
|
25956
|
+
":blankline": emptyContent,
|
|
25957
|
+
":ambient": emptyContent,
|
|
25958
|
+
":config": setFn((node, ctx) => {
|
|
25959
|
+
if (!ctx.hasOwnProperty("config"))
|
|
25960
|
+
ctx.config = {};
|
|
25961
|
+
ctx.config[node.name] = node.config;
|
|
25962
|
+
return emptyContent;
|
|
25963
|
+
}),
|
|
25964
|
+
":alias": setFn((node, ctx) => {
|
|
25965
|
+
if (!ctx.hasOwnProperty("alias"))
|
|
25966
|
+
ctx.alias = {};
|
|
25967
|
+
ctx.alias[node.name] = node.replacement;
|
|
25968
|
+
return emptyContent;
|
|
25969
|
+
}),
|
|
25970
|
+
para: handleNested(content),
|
|
25971
|
+
":para": (writer, processor) => (node, ctx, interator) => {
|
|
25972
|
+
if (node.content)
|
|
25973
|
+
interator(node.content, ctx);
|
|
25974
|
+
writer.writeRaw("\n");
|
|
25975
|
+
},
|
|
25976
|
+
"head:block": subUse(
|
|
25977
|
+
{
|
|
25978
|
+
":para": content
|
|
25979
|
+
},
|
|
25980
|
+
setFn((node, ctx) => {
|
|
25981
|
+
const { level } = node;
|
|
25982
|
+
const prefix = "#".repeat(level) + " ";
|
|
25983
|
+
return (writer, processor) => (node2, ctx2, interator) => {
|
|
25984
|
+
writer.writeRaw(prefix);
|
|
25985
|
+
if (node2.content)
|
|
25986
|
+
interator(node2.content, ctx2);
|
|
25987
|
+
writer.writeRaw("\n");
|
|
25988
|
+
};
|
|
25989
|
+
})
|
|
25990
|
+
),
|
|
25991
|
+
":list": setFn((node, ctx) => {
|
|
25992
|
+
return (writer, processor) => (node2, ctx2, interator) => {
|
|
25993
|
+
const newCtx = {
|
|
25994
|
+
...ctx2,
|
|
25995
|
+
listType: node2.list,
|
|
25996
|
+
listCounter: { value: 1 },
|
|
25997
|
+
listDepth: (ctx2.listDepth || 0) + 1
|
|
25998
|
+
};
|
|
25999
|
+
if (node2.content)
|
|
26000
|
+
interator(node2.content, newCtx);
|
|
26001
|
+
};
|
|
26002
|
+
}),
|
|
26003
|
+
"item:block": (writer, processor) => (node, ctx, interator) => {
|
|
26004
|
+
const indent2 = " ".repeat(Math.max(0, (ctx.listDepth || 1) - 1));
|
|
26005
|
+
const listType = ctx.listType || "unordered";
|
|
26006
|
+
let prefix;
|
|
26007
|
+
if (listType === "ordered") {
|
|
26008
|
+
const counter = ctx.listCounter || { value: 1 };
|
|
26009
|
+
prefix = `${counter.value}. `;
|
|
26010
|
+
counter.value++;
|
|
26011
|
+
} else if (listType === "variable") {
|
|
26012
|
+
prefix = "- ";
|
|
26013
|
+
} else {
|
|
26014
|
+
prefix = "- ";
|
|
26015
|
+
}
|
|
26016
|
+
writer.writeRaw(indent2 + prefix);
|
|
26017
|
+
if (node.content)
|
|
26018
|
+
interator(node.content, ctx);
|
|
26019
|
+
},
|
|
26020
|
+
"comment:block": emptyContent,
|
|
26021
|
+
defn: (writer, processor) => (node, ctx, interator) => {
|
|
26022
|
+
if (node.content)
|
|
26023
|
+
interator(node.content, ctx);
|
|
26024
|
+
writer.writeRaw("\n");
|
|
26025
|
+
},
|
|
26026
|
+
"term:para": (writer, processor) => (node, ctx, interator) => {
|
|
26027
|
+
writer.writeRaw("**");
|
|
26028
|
+
if (node.content)
|
|
26029
|
+
interator(node.content, ctx);
|
|
26030
|
+
writer.writeRaw(":** ");
|
|
26031
|
+
},
|
|
26032
|
+
nested: handleNested(content, 1),
|
|
26033
|
+
output: handleNested(
|
|
26034
|
+
(writer, processor) => (node, ctx, interator) => {
|
|
26035
|
+
writer.writeRaw("```\n");
|
|
26036
|
+
if (node.content)
|
|
26037
|
+
interator(node.content, ctx);
|
|
26038
|
+
writer.writeRaw("```\n");
|
|
26039
|
+
},
|
|
26040
|
+
1
|
|
26041
|
+
),
|
|
26042
|
+
input: handleNested(
|
|
26043
|
+
(writer, processor) => (node, ctx, interator) => {
|
|
26044
|
+
writer.writeRaw("```\n");
|
|
26045
|
+
if (node.content)
|
|
26046
|
+
interator(node.content, ctx);
|
|
26047
|
+
writer.writeRaw("```\n");
|
|
26048
|
+
},
|
|
26049
|
+
1
|
|
26050
|
+
),
|
|
26051
|
+
"table:block": handleNested((writer, processor) => (node, ctx, interator) => {
|
|
26052
|
+
const conf = config_default(node, ctx);
|
|
26053
|
+
if (conf.exists("caption")) {
|
|
26054
|
+
writer.writeRaw("**");
|
|
26055
|
+
writer.write(conf.getFirstValue("caption"));
|
|
26056
|
+
writer.writeRaw("**\n\n");
|
|
26057
|
+
}
|
|
26058
|
+
const rows = (node.content || []).filter((child) => child.name === "table_row" || child.name === "table_head");
|
|
26059
|
+
if (rows.length === 0)
|
|
26060
|
+
return;
|
|
26061
|
+
const hasHeader = rows[0].name === "table_head";
|
|
26062
|
+
rows.forEach((row, rowIndex) => {
|
|
26063
|
+
const cells = (row.content || []).filter((c) => c.name === "table_cell");
|
|
26064
|
+
writer.writeRaw("|");
|
|
26065
|
+
cells.forEach((cell) => {
|
|
26066
|
+
writer.writeRaw(" ");
|
|
26067
|
+
if (cell.content) {
|
|
26068
|
+
cell.content.forEach((c) => {
|
|
26069
|
+
if (typeof c === "string") {
|
|
26070
|
+
writer.write(c.trim());
|
|
26071
|
+
} else {
|
|
26072
|
+
interator([c], ctx);
|
|
26073
|
+
}
|
|
26074
|
+
});
|
|
26075
|
+
}
|
|
26076
|
+
writer.writeRaw(" |");
|
|
26077
|
+
});
|
|
26078
|
+
writer.writeRaw("\n");
|
|
26079
|
+
if (rowIndex === 0 && hasHeader) {
|
|
26080
|
+
writer.writeRaw("|");
|
|
26081
|
+
cells.forEach(() => {
|
|
26082
|
+
writer.writeRaw(" --- |");
|
|
26083
|
+
});
|
|
26084
|
+
writer.writeRaw("\n");
|
|
26085
|
+
}
|
|
26086
|
+
if (rowIndex === 0 && !hasHeader) {
|
|
26087
|
+
writer.writeRaw("|");
|
|
26088
|
+
cells.forEach(() => {
|
|
26089
|
+
writer.writeRaw(" --- |");
|
|
26090
|
+
});
|
|
26091
|
+
writer.writeRaw("\n");
|
|
26092
|
+
}
|
|
26093
|
+
});
|
|
26094
|
+
writer.writeRaw("\n");
|
|
26095
|
+
}),
|
|
26096
|
+
":separator": emptyContent,
|
|
26097
|
+
table_row: emptyContent,
|
|
26098
|
+
table_cell: emptyContent,
|
|
26099
|
+
table_head: emptyContent,
|
|
26100
|
+
":toc": emptyContent,
|
|
26101
|
+
":toc-list": emptyContent,
|
|
26102
|
+
":toc-item": emptyContent,
|
|
26103
|
+
":image": (writer, processor) => (node, ctx, interator) => {
|
|
26104
|
+
writer.writeRaw(``);
|
|
26105
|
+
}
|
|
26106
|
+
};
|
|
26107
|
+
|
|
25772
26108
|
// ../podlite-schema/src/helpers/ids.ts
|
|
25773
26109
|
var import_slugify = __toESM(require_slugify());
|
|
25774
26110
|
|
|
@@ -25869,9 +26205,30 @@ var plugin_items_default = () => (tree) => {
|
|
|
25869
26205
|
if (matchItem) {
|
|
25870
26206
|
node.name = "item";
|
|
25871
26207
|
node.level = matchItem[1] || 1;
|
|
26208
|
+
const checkedConfig = (node.config || []).find((c) => c.name === "checked");
|
|
26209
|
+
if (checkedConfig) {
|
|
26210
|
+
node.checked = checkedConfig.value !== false && checkedConfig.value !== 0 && checkedConfig.value !== "0";
|
|
26211
|
+
}
|
|
25872
26212
|
if (node.content[0]) {
|
|
25873
26213
|
const startText = node.content[0];
|
|
25874
26214
|
if (startText.text) {
|
|
26215
|
+
if (!checkedConfig) {
|
|
26216
|
+
const checkboxRe = /^\[( |x)\]\s*/;
|
|
26217
|
+
const checkboxMatch = checkboxRe.exec(startText.text);
|
|
26218
|
+
if (checkboxMatch) {
|
|
26219
|
+
node.checked = checkboxMatch[1] === "x";
|
|
26220
|
+
startText.text = startText.text.replace(checkboxRe, "");
|
|
26221
|
+
if (startText.type === "para") {
|
|
26222
|
+
startText.content = [startText.text];
|
|
26223
|
+
}
|
|
26224
|
+
node.config = node.config || [];
|
|
26225
|
+
node.config.push({
|
|
26226
|
+
name: "checked",
|
|
26227
|
+
value: node.checked,
|
|
26228
|
+
type: "boolean"
|
|
26229
|
+
});
|
|
26230
|
+
}
|
|
26231
|
+
}
|
|
25875
26232
|
let re = /^(\s*#\s*)/;
|
|
25876
26233
|
const match = re.exec(startText.text);
|
|
25877
26234
|
if (match) {
|
|
@@ -25984,8 +26341,9 @@ var plugin_group_defn_default = () => (tree) => {
|
|
|
25984
26341
|
|
|
25985
26342
|
// ../podlite-schema/src/plugin-group-items.ts
|
|
25986
26343
|
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);
|
|
26344
|
+
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
26345
|
const isNumbered = (node) => Boolean(config_default(node, {}).exists("numbered"));
|
|
26346
|
+
const isChecked = (node) => node.checked !== void 0;
|
|
25989
26347
|
const group = (a, level = 1) => {
|
|
25990
26348
|
const isInListMode = (a2) => {
|
|
25991
26349
|
return a2.length > 0 && a2[a2.length - 1].type === "list";
|
|
@@ -26000,12 +26358,12 @@ var plugin_group_items_default = () => (tree) => {
|
|
|
26000
26358
|
if (i.name === "item" && i.type === "block" && i.level < level) {
|
|
26001
26359
|
return [...a2, i];
|
|
26002
26360
|
}
|
|
26003
|
-
if (i.name === "item" && i.type === "block" && (!isInListMode(a2) || i.level === level && getList(a2).list !== (isNumbered(i) ? "ordered" : "itemized"))) {
|
|
26361
|
+
if (i.name === "item" && i.type === "block" && (!isInListMode(a2) || Number(i.level) === level && getList(a2).list !== (isNumbered(i) ? "ordered" : isChecked(i) ? "task" : "itemized"))) {
|
|
26004
26362
|
a2.push({
|
|
26005
26363
|
type: "list",
|
|
26006
26364
|
level: i.level,
|
|
26007
26365
|
content: [],
|
|
26008
|
-
list: isNumbered(i) ? "ordered" : "itemized"
|
|
26366
|
+
list: isNumbered(i) ? "ordered" : isChecked(i) ? "task" : "itemized"
|
|
26009
26367
|
});
|
|
26010
26368
|
}
|
|
26011
26369
|
if (isInListMode(a2) && isInsertableToList(getList(a2), i)) {
|
|
@@ -26017,7 +26375,7 @@ var plugin_group_items_default = () => (tree) => {
|
|
|
26017
26375
|
}, []);
|
|
26018
26376
|
return result.map((item) => {
|
|
26019
26377
|
if (item.content && item.type !== "fcode") {
|
|
26020
|
-
item.content = group(item.content, item.level + 1);
|
|
26378
|
+
item.content = group(item.content, Number(item.level || 0) + 1);
|
|
26021
26379
|
}
|
|
26022
26380
|
return item;
|
|
26023
26381
|
});
|
|
@@ -26195,7 +26553,7 @@ var plugin_tables_default = () => (tree) => {
|
|
|
26195
26553
|
};
|
|
26196
26554
|
|
|
26197
26555
|
// ../podlite-schema/src/exportHtml.ts
|
|
26198
|
-
var
|
|
26556
|
+
var rules2 = {
|
|
26199
26557
|
":text": (writer, processor) => (node, ctx, interator) => {
|
|
26200
26558
|
if (node.value) {
|
|
26201
26559
|
writer.write(node.value);
|
|
@@ -26348,14 +26706,19 @@ var rules = {
|
|
|
26348
26706
|
})
|
|
26349
26707
|
),
|
|
26350
26708
|
":list": setFn(
|
|
26351
|
-
(node, ctx) => node.list === "ordered" ? wrapContent("<ol>", "</ol>") : node.list === "variable" ? wrapContent("<dl>", "</dl>") : wrapContent("<ul>", "</ul>")
|
|
26709
|
+
(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
26710
|
),
|
|
26353
26711
|
"item:block": (writer, processor) => (node, ctx, interator) => {
|
|
26354
26712
|
if (!(node.content instanceof Array)) {
|
|
26355
26713
|
console.error("[pod6] item:block : Error in content of " + JSON.stringify(node));
|
|
26356
26714
|
}
|
|
26357
|
-
const
|
|
26358
|
-
|
|
26715
|
+
const isTask = node.checked !== void 0;
|
|
26716
|
+
if (isTask) {
|
|
26717
|
+
writer.writeRaw('<li class="task-list-item">');
|
|
26718
|
+
writer.writeRaw(node.checked ? '<input type="checkbox" disabled checked> ' : '<input type="checkbox" disabled> ');
|
|
26719
|
+
} else {
|
|
26720
|
+
writer.writeRaw("<li>");
|
|
26721
|
+
}
|
|
26359
26722
|
interator(node.content, ctx);
|
|
26360
26723
|
writer.writeRaw("</li>");
|
|
26361
26724
|
},
|
|
@@ -26456,7 +26819,7 @@ function bail(error) {
|
|
|
26456
26819
|
var import_is_buffer2 = __toESM(require_is_buffer(), 1);
|
|
26457
26820
|
var import_extend = __toESM(require_extend(), 1);
|
|
26458
26821
|
|
|
26459
|
-
// ../../node_modules/
|
|
26822
|
+
// ../../node_modules/is-plain-obj/index.js
|
|
26460
26823
|
function isPlainObject(value) {
|
|
26461
26824
|
if (typeof value !== "object" || value === null) {
|
|
26462
26825
|
return false;
|
|
@@ -35053,11 +35416,18 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
35053
35416
|
},
|
|
35054
35417
|
":listItem": (writer, processor) => (node, ctx, interator) => {
|
|
35055
35418
|
const savedListLevel = ctx["listLevel"] || 0;
|
|
35056
|
-
const { children, position: position2, ...attr } = node;
|
|
35057
|
-
|
|
35058
|
-
|
|
35059
|
-
|
|
35060
|
-
|
|
35419
|
+
const { children, position: position2, checked, ...attr } = node;
|
|
35420
|
+
const blockAttrs = {
|
|
35421
|
+
name: "item",
|
|
35422
|
+
type: "block",
|
|
35423
|
+
level: ctx["listLevel"],
|
|
35424
|
+
location: applyLineOffset(position2)
|
|
35425
|
+
};
|
|
35426
|
+
if (checked !== null && checked !== void 0) {
|
|
35427
|
+
blockAttrs.checked = checked;
|
|
35428
|
+
blockAttrs.config = [{ name: "checked", value: checked, type: "boolean" }];
|
|
35429
|
+
}
|
|
35430
|
+
return mkBlock(blockAttrs, interator(children, { ...ctx, listLevel: savedListLevel, ordered: node.ordered }));
|
|
35061
35431
|
},
|
|
35062
35432
|
":paragraph": (writer, processor) => (node, ctx, interator) => {
|
|
35063
35433
|
const { children, position: position2, ...attr } = node;
|