@markdoc/markdoc 0.3.2 → 0.3.4
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 +22 -16
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +22 -16
- 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/ast/node.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/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ast/node.ts +6 -0
- package/src/parser.test.ts +20 -0
- package/src/parser.ts +17 -14
- package/src/types.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -6927,7 +6927,11 @@ var Node = class {
|
|
|
6927
6927
|
resolve(config = {}) {
|
|
6928
6928
|
return Object.assign(new Node(), this, {
|
|
6929
6929
|
children: this.children.map((child) => child.resolve(config)),
|
|
6930
|
-
attributes: resolve(this.attributes, config)
|
|
6930
|
+
attributes: resolve(this.attributes, config),
|
|
6931
|
+
slots: Object.fromEntries(Object.entries(this.slots).map(([name, slot2]) => [
|
|
6932
|
+
name,
|
|
6933
|
+
slot2.resolve(config)
|
|
6934
|
+
]))
|
|
6931
6935
|
});
|
|
6932
6936
|
}
|
|
6933
6937
|
findSchema(config = {}) {
|
|
@@ -7562,7 +7566,7 @@ function handleAttrs(token, type) {
|
|
|
7562
7566
|
return {};
|
|
7563
7567
|
}
|
|
7564
7568
|
}
|
|
7565
|
-
function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
7569
|
+
function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent) {
|
|
7566
7570
|
if (token.type === "frontmatter") {
|
|
7567
7571
|
nodes[0].attributes.frontmatter = token.content;
|
|
7568
7572
|
return;
|
|
@@ -7604,18 +7608,20 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7604
7608
|
const node2 = new Node(typeName, attrs, void 0, tag || void 0);
|
|
7605
7609
|
const { position = {} } = token;
|
|
7606
7610
|
node2.errors = errors;
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7611
|
+
if (addLocation !== false) {
|
|
7612
|
+
node2.lines = token.map || parent.lines || [];
|
|
7613
|
+
node2.location = {
|
|
7614
|
+
file,
|
|
7615
|
+
start: {
|
|
7616
|
+
line: node2.lines[0],
|
|
7617
|
+
character: position.start
|
|
7618
|
+
},
|
|
7619
|
+
end: {
|
|
7620
|
+
line: node2.lines[1],
|
|
7621
|
+
character: position.end
|
|
7622
|
+
}
|
|
7623
|
+
};
|
|
7624
|
+
}
|
|
7619
7625
|
if (inlineParent)
|
|
7620
7626
|
node2.inline = true;
|
|
7621
7627
|
if (attributes && ["tag", "fence", "image"].includes(typeName))
|
|
@@ -7634,7 +7640,7 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7634
7640
|
const isLeafNode = typeName === "image";
|
|
7635
7641
|
if (!isLeafNode) {
|
|
7636
7642
|
for (const child of token.children)
|
|
7637
|
-
handleToken(child, nodes, file, handleSlots, inlineParent);
|
|
7643
|
+
handleToken(child, nodes, file, handleSlots, addLocation, inlineParent);
|
|
7638
7644
|
}
|
|
7639
7645
|
nodes.pop();
|
|
7640
7646
|
}
|
|
@@ -7644,7 +7650,7 @@ function parser(tokens, args) {
|
|
|
7644
7650
|
if (typeof args === "string")
|
|
7645
7651
|
args = { file: args };
|
|
7646
7652
|
for (const token of tokens)
|
|
7647
|
-
handleToken(token, nodes, args?.file, args?.slots);
|
|
7653
|
+
handleToken(token, nodes, args?.file, args?.slots, args?.location);
|
|
7648
7654
|
if (nodes.length > 1)
|
|
7649
7655
|
for (const node2 of nodes.slice(1))
|
|
7650
7656
|
node2.errors.push({
|