@markdoc/markdoc 0.3.1 → 0.3.3
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.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +2 -2
- package/dist/src/ast/index.d.ts +1 -0
- package/dist/src/ast/index.d.ts.map +1 -1
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/tags/index.d.ts +5 -0
- package/dist/src/tags/index.d.ts.map +1 -1
- package/dist/src/transformer.d.ts.map +1 -1
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/parser.test.ts +20 -0
- package/src/parser.ts +17 -14
- package/src/transformer.ts +1 -0
- package/src/types.ts +2 -0
- package/src/validator.test.ts +28 -1
- package/src/validator.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6870,6 +6870,8 @@ var transformer_default = {
|
|
|
6870
6870
|
}
|
|
6871
6871
|
if (schema.slots) {
|
|
6872
6872
|
for (const [key, slot2] of Object.entries(schema.slots)) {
|
|
6873
|
+
if (slot2.render === false)
|
|
6874
|
+
continue;
|
|
6873
6875
|
const name = typeof slot2.render === "string" ? slot2.render : key;
|
|
6874
6876
|
if (node2.slots[key])
|
|
6875
6877
|
output[name] = this.node(node2.slots[key], config);
|
|
@@ -7560,7 +7562,7 @@ function handleAttrs(token, type) {
|
|
|
7560
7562
|
return {};
|
|
7561
7563
|
}
|
|
7562
7564
|
}
|
|
7563
|
-
function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
7565
|
+
function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent) {
|
|
7564
7566
|
if (token.type === "frontmatter") {
|
|
7565
7567
|
nodes[0].attributes.frontmatter = token.content;
|
|
7566
7568
|
return;
|
|
@@ -7602,18 +7604,20 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7602
7604
|
const node2 = new Node(typeName, attrs, void 0, tag || void 0);
|
|
7603
7605
|
const { position = {} } = token;
|
|
7604
7606
|
node2.errors = errors;
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7607
|
+
if (addLocation !== false) {
|
|
7608
|
+
node2.lines = token.map || parent.lines || [];
|
|
7609
|
+
node2.location = {
|
|
7610
|
+
file,
|
|
7611
|
+
start: {
|
|
7612
|
+
line: node2.lines[0],
|
|
7613
|
+
character: position.start
|
|
7614
|
+
},
|
|
7615
|
+
end: {
|
|
7616
|
+
line: node2.lines[1],
|
|
7617
|
+
character: position.end
|
|
7618
|
+
}
|
|
7619
|
+
};
|
|
7620
|
+
}
|
|
7617
7621
|
if (inlineParent)
|
|
7618
7622
|
node2.inline = true;
|
|
7619
7623
|
if (attributes && ["tag", "fence", "image"].includes(typeName))
|
|
@@ -7632,7 +7636,7 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7632
7636
|
const isLeafNode = typeName === "image";
|
|
7633
7637
|
if (!isLeafNode) {
|
|
7634
7638
|
for (const child of token.children)
|
|
7635
|
-
handleToken(child, nodes, file, handleSlots, inlineParent);
|
|
7639
|
+
handleToken(child, nodes, file, handleSlots, addLocation, inlineParent);
|
|
7636
7640
|
}
|
|
7637
7641
|
nodes.pop();
|
|
7638
7642
|
}
|
|
@@ -7642,7 +7646,7 @@ function parser(tokens, args) {
|
|
|
7642
7646
|
if (typeof args === "string")
|
|
7643
7647
|
args = { file: args };
|
|
7644
7648
|
for (const token of tokens)
|
|
7645
|
-
handleToken(token, nodes, args?.file, args?.slots);
|
|
7649
|
+
handleToken(token, nodes, args?.file, args?.slots, args?.location);
|
|
7646
7650
|
if (nodes.length > 1)
|
|
7647
7651
|
for (const node2 of nodes.slice(1))
|
|
7648
7652
|
node2.errors.push({
|
|
@@ -8513,8 +8517,8 @@ function validateTree(content, config) {
|
|
|
8513
8517
|
const output = [...walkWithParents(content)].map(([node2, parents]) => {
|
|
8514
8518
|
const { type, lines, location } = node2;
|
|
8515
8519
|
const updatedConfig = {
|
|
8516
|
-
|
|
8517
|
-
...config
|
|
8520
|
+
...config,
|
|
8521
|
+
validation: { ...config.validation, parents }
|
|
8518
8522
|
};
|
|
8519
8523
|
const errors = validator(node2, updatedConfig);
|
|
8520
8524
|
if (isPromise(errors)) {
|