@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.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export default class Markdoc {
|
|
|
43
43
|
validation?: {
|
|
44
44
|
parents?: Node[] | undefined;
|
|
45
45
|
validateFunctions?: boolean | undefined;
|
|
46
|
+
environment?: string | undefined;
|
|
46
47
|
} | undefined;
|
|
47
48
|
}>>, string>;
|
|
48
49
|
if: import("./src/types").Schema<Readonly<Partial<{
|
|
@@ -54,6 +55,7 @@ export default class Markdoc {
|
|
|
54
55
|
validation?: {
|
|
55
56
|
parents?: Node[] | undefined;
|
|
56
57
|
validateFunctions?: boolean | undefined;
|
|
58
|
+
environment?: string | undefined;
|
|
57
59
|
} | undefined;
|
|
58
60
|
}>>, string>;
|
|
59
61
|
partial: import("./src/types").Schema<Readonly<Partial<{
|
|
@@ -65,6 +67,7 @@ export default class Markdoc {
|
|
|
65
67
|
validation?: {
|
|
66
68
|
parents?: Node[] | undefined;
|
|
67
69
|
validateFunctions?: boolean | undefined;
|
|
70
|
+
environment?: string | undefined;
|
|
68
71
|
} | undefined;
|
|
69
72
|
}>>, string>;
|
|
70
73
|
slot: import("./src/types").Schema<Readonly<Partial<{
|
|
@@ -76,6 +79,7 @@ export default class Markdoc {
|
|
|
76
79
|
validation?: {
|
|
77
80
|
parents?: Node[] | undefined;
|
|
78
81
|
validateFunctions?: boolean | undefined;
|
|
82
|
+
environment?: string | undefined;
|
|
79
83
|
} | undefined;
|
|
80
84
|
}>>, string>;
|
|
81
85
|
table: import("./src/types").Schema<Readonly<Partial<{
|
|
@@ -87,6 +91,7 @@ export default class Markdoc {
|
|
|
87
91
|
validation?: {
|
|
88
92
|
parents?: Node[] | undefined;
|
|
89
93
|
validateFunctions?: boolean | undefined;
|
|
94
|
+
environment?: string | undefined;
|
|
90
95
|
} | undefined;
|
|
91
96
|
}>>, string>;
|
|
92
97
|
};
|
|
@@ -120,6 +125,7 @@ export default class Markdoc {
|
|
|
120
125
|
validation?: {
|
|
121
126
|
parents?: Node[] | undefined;
|
|
122
127
|
validateFunctions?: boolean | undefined;
|
|
128
|
+
environment?: string | undefined;
|
|
123
129
|
} | undefined;
|
|
124
130
|
}>>): any;
|
|
125
131
|
Function: typeof import("./src/ast/function").default;
|
|
@@ -146,6 +152,7 @@ export default class Markdoc {
|
|
|
146
152
|
validation?: {
|
|
147
153
|
parents?: Node[] | undefined;
|
|
148
154
|
validateFunctions?: boolean | undefined;
|
|
155
|
+
environment?: string | undefined;
|
|
149
156
|
} | undefined;
|
|
150
157
|
}>>;
|
|
151
158
|
constructor(config: Config);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,SAAS,MAAM,iBAAiB,CA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AAG,EACH,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,MAAM,EACN,MAAM,GACP,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,KAAK,eAAS;IACrB,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAQ;IACnB,MAAM,CAAC,SAAS;;;;;;;MAAa;IAC7B,MAAM,CAAC,gBAAgB,oEAAoB;IAC3C,MAAM,CAAC,SAAS;;;;MAAa;IAC7B,MAAM,CAAC,UAAU,oDAAc;IAC/B,MAAM,CAAC,GAAG;;;;;;;;;;;;;;;;;;;;;MAAO;IACjB,MAAM,CAAC,GAAG,aAAO;IACjB,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,WAAW,oCAAe;IACjC,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,KAAK,eAAS;IACrB,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,QAAQ,kBAAY;IAC3B,MAAM,CAAC,aAAa,uBAAiB;IACrC,MAAM,CAAC,MAAM,gBAAU;IACvB,MAAM,CAAC,MAAM,gBAAU;IAEvB,MAAM;;;;;;;;;;;QAAC;gBACK,MAAM,EAAE,MAAM;IAI1B,KAAK,eAAS;IACd,OAAO,YAAa,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,YACjB;IAChC,SAAS,YAAa,WAAW,gBAAgB,CAAC,CAAC,CAAC,CAAC,0BACnB;IAClC,QAAQ,YAAa,WAAW,eAAe,CAAC,CAAC,CAAC,CAAC,qBAClB;CAClC"}
|
package/dist/index.js
CHANGED
|
@@ -6894,6 +6894,8 @@ var transformer_default = {
|
|
|
6894
6894
|
}
|
|
6895
6895
|
if (schema.slots) {
|
|
6896
6896
|
for (const [key, slot2] of Object.entries(schema.slots)) {
|
|
6897
|
+
if (slot2.render === false)
|
|
6898
|
+
continue;
|
|
6897
6899
|
const name = typeof slot2.render === "string" ? slot2.render : key;
|
|
6898
6900
|
if (node2.slots[key])
|
|
6899
6901
|
output[name] = this.node(node2.slots[key], config);
|
|
@@ -7584,7 +7586,7 @@ function handleAttrs(token, type) {
|
|
|
7584
7586
|
return {};
|
|
7585
7587
|
}
|
|
7586
7588
|
}
|
|
7587
|
-
function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
7589
|
+
function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent) {
|
|
7588
7590
|
if (token.type === "frontmatter") {
|
|
7589
7591
|
nodes[0].attributes.frontmatter = token.content;
|
|
7590
7592
|
return;
|
|
@@ -7626,18 +7628,20 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7626
7628
|
const node2 = new Node(typeName, attrs, void 0, tag || void 0);
|
|
7627
7629
|
const { position = {} } = token;
|
|
7628
7630
|
node2.errors = errors;
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7631
|
+
if (addLocation !== false) {
|
|
7632
|
+
node2.lines = token.map || parent.lines || [];
|
|
7633
|
+
node2.location = {
|
|
7634
|
+
file,
|
|
7635
|
+
start: {
|
|
7636
|
+
line: node2.lines[0],
|
|
7637
|
+
character: position.start
|
|
7638
|
+
},
|
|
7639
|
+
end: {
|
|
7640
|
+
line: node2.lines[1],
|
|
7641
|
+
character: position.end
|
|
7642
|
+
}
|
|
7643
|
+
};
|
|
7644
|
+
}
|
|
7641
7645
|
if (inlineParent)
|
|
7642
7646
|
node2.inline = true;
|
|
7643
7647
|
if (attributes && ["tag", "fence", "image"].includes(typeName))
|
|
@@ -7656,7 +7660,7 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
|
|
|
7656
7660
|
const isLeafNode = typeName === "image";
|
|
7657
7661
|
if (!isLeafNode) {
|
|
7658
7662
|
for (const child of token.children)
|
|
7659
|
-
handleToken(child, nodes, file, handleSlots, inlineParent);
|
|
7663
|
+
handleToken(child, nodes, file, handleSlots, addLocation, inlineParent);
|
|
7660
7664
|
}
|
|
7661
7665
|
nodes.pop();
|
|
7662
7666
|
}
|
|
@@ -7666,7 +7670,7 @@ function parser(tokens, args) {
|
|
|
7666
7670
|
if (typeof args === "string")
|
|
7667
7671
|
args = { file: args };
|
|
7668
7672
|
for (const token of tokens)
|
|
7669
|
-
handleToken(token, nodes, args?.file, args?.slots);
|
|
7673
|
+
handleToken(token, nodes, args?.file, args?.slots, args?.location);
|
|
7670
7674
|
if (nodes.length > 1)
|
|
7671
7675
|
for (const node2 of nodes.slice(1))
|
|
7672
7676
|
node2.errors.push({
|
|
@@ -8537,8 +8541,8 @@ function validateTree(content, config) {
|
|
|
8537
8541
|
const output = [...walkWithParents(content)].map(([node2, parents]) => {
|
|
8538
8542
|
const { type, lines, location } = node2;
|
|
8539
8543
|
const updatedConfig = {
|
|
8540
|
-
|
|
8541
|
-
...config
|
|
8544
|
+
...config,
|
|
8545
|
+
validation: { ...config.validation, parents }
|
|
8542
8546
|
};
|
|
8543
8547
|
const errors = validator(node2, updatedConfig);
|
|
8544
8548
|
if (isPromise(errors)) {
|