@markdoc/markdoc 0.3.1 → 0.3.2
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.js +4 -2
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +2 -2
- package/dist/src/transformer.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/transformer.ts +1 -0
- package/src/validator.test.ts +28 -1
- package/src/validator.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAMV,MAAM,EACN,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,aAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,gBAG9B,CAAC;;AAEF,
|
|
1
|
+
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAMV,MAAM,EACN,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,aAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,gBAG9B,CAAC;;AAEF,wBAmEiB"}
|
package/package.json
CHANGED
package/src/transformer.ts
CHANGED
|
@@ -49,6 +49,7 @@ export default {
|
|
|
49
49
|
|
|
50
50
|
if (schema.slots) {
|
|
51
51
|
for (const [key, slot] of Object.entries(schema.slots)) {
|
|
52
|
+
if (slot.render === false) continue;
|
|
52
53
|
const name = typeof slot.render === 'string' ? slot.render : key;
|
|
53
54
|
if (node.slots[key]) output[name] = this.node(node.slots[key], config);
|
|
54
55
|
}
|
package/src/validator.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Markdoc, { nodes } from '../index';
|
|
2
|
-
import type { ValidationError } from './types';
|
|
2
|
+
import type { Config, ValidationError } from './types';
|
|
3
3
|
|
|
4
4
|
function validate(string, config) {
|
|
5
5
|
return Markdoc.validate(Markdoc.parse(string), config);
|
|
@@ -680,5 +680,32 @@ bar
|
|
|
680
680
|
const errors2 = validate(doc2, config);
|
|
681
681
|
expect(errors2.length).toEqual(0);
|
|
682
682
|
});
|
|
683
|
+
|
|
684
|
+
it('with function validation enabled', () => {
|
|
685
|
+
const doc = `{% foo %}{% bar %}this is a test{% /bar %}{% /foo %}`;
|
|
686
|
+
|
|
687
|
+
const config: Config = {
|
|
688
|
+
validation: {
|
|
689
|
+
validateFunctions: true,
|
|
690
|
+
},
|
|
691
|
+
tags: {
|
|
692
|
+
foo: {},
|
|
693
|
+
bar: {
|
|
694
|
+
validate(node, config) {
|
|
695
|
+
const parents = config?.validation?.parents?.map((p) => p.type);
|
|
696
|
+
expect(parents).toDeepEqual([
|
|
697
|
+
'document',
|
|
698
|
+
'paragraph',
|
|
699
|
+
'inline',
|
|
700
|
+
'tag',
|
|
701
|
+
]);
|
|
702
|
+
return [];
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
validate(doc, config);
|
|
709
|
+
});
|
|
683
710
|
});
|
|
684
711
|
});
|
package/src/validator.ts
CHANGED
|
@@ -307,8 +307,8 @@ export function validateTree(content: Node, config: Config) {
|
|
|
307
307
|
const output = [...walkWithParents(content)].map(([node, parents]) => {
|
|
308
308
|
const { type, lines, location } = node;
|
|
309
309
|
const updatedConfig = {
|
|
310
|
-
validation: { ...config.validation, parents },
|
|
311
310
|
...config,
|
|
311
|
+
validation: { ...config.validation, parents },
|
|
312
312
|
};
|
|
313
313
|
const errors = validator(node, updatedConfig);
|
|
314
314
|
|