@markdoc/markdoc 0.1.3 → 0.1.6

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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +48 -30
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +6744 -6329
  5. package/dist/index.js.map +3 -3
  6. package/dist/index.mjs +6827 -6412
  7. package/dist/index.mjs.map +3 -3
  8. package/dist/src/ast/base.d.ts +2 -1
  9. package/dist/src/ast/base.d.ts.map +1 -1
  10. package/dist/src/ast/index.d.ts +1 -0
  11. package/dist/src/ast/index.d.ts.map +1 -1
  12. package/dist/src/ast/node.d.ts +5 -4
  13. package/dist/src/ast/node.d.ts.map +1 -1
  14. package/dist/src/formatter.d.ts +9 -0
  15. package/dist/src/formatter.d.ts.map +1 -0
  16. package/dist/src/parser.d.ts.map +1 -1
  17. package/dist/src/schema.d.ts +1 -0
  18. package/dist/src/schema.d.ts.map +1 -1
  19. package/dist/src/tag.d.ts +9 -0
  20. package/dist/src/tag.d.ts.map +1 -0
  21. package/dist/src/tags/conditional.d.ts.map +1 -1
  22. package/dist/src/tags/partial.d.ts.map +1 -1
  23. package/dist/src/tokenizer/index.d.ts.map +1 -1
  24. package/dist/src/transformer.d.ts +1 -7
  25. package/dist/src/transformer.d.ts.map +1 -1
  26. package/dist/src/transforms/table.d.ts.map +1 -1
  27. package/dist/src/types.d.ts +12 -4
  28. package/dist/src/types.d.ts.map +1 -1
  29. package/dist/src/utils.d.ts +1 -0
  30. package/dist/src/utils.d.ts.map +1 -1
  31. package/dist/src/validator.d.ts.map +1 -1
  32. package/index.ts +47 -29
  33. package/package.json +3 -2
  34. package/src/ast/base.ts +5 -0
  35. package/src/ast/node.test.ts +73 -21
  36. package/src/ast/node.ts +9 -4
  37. package/src/formatter.test.ts +404 -0
  38. package/src/formatter.ts +373 -0
  39. package/src/parser.ts +5 -1
  40. package/src/schema.ts +2 -1
  41. package/src/tag.ts +22 -0
  42. package/src/tags/conditional.ts +10 -3
  43. package/src/tags/partial.ts +20 -3
  44. package/src/tokenizer/index.ts +5 -1
  45. package/src/transformer.ts +15 -17
  46. package/src/transforms/table.ts +2 -2
  47. package/src/types.ts +31 -19
  48. package/src/utils.ts +4 -0
  49. package/src/validator.test.ts +60 -0
  50. package/src/validator.ts +20 -1
  51. package/dist/src/ast/tag.d.ts +0 -9
  52. package/dist/src/ast/tag.d.ts.map +0 -1
  53. package/src/ast/tag.ts +0 -19
@@ -1,6 +1,7 @@
1
- import type { AstType, Config, Function as AstFunction } from '../types';
1
+ import type { AstType, Config, Function as AstFunction, Variable as AstVariable } from '../types';
2
2
  export declare function isAst(value?: any): value is AstType;
3
3
  export declare function isFunction(value?: any): value is AstFunction;
4
+ export declare function isVariable(value?: any): value is AstVariable;
4
5
  export declare function getAstValues(value: any): Generator<AstType, void, unknown>;
5
6
  export declare function resolve(value: any, config?: Config): any;
6
7
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ast/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,QAAQ,IAAI,WAAW,EAExB,MAAM,UAAU,CAAC;AAElB,wBAAgB,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAEnD;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW,CAE5D;AAED,wBAAiB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAU3E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAW,GAAG,GAAG,CAa5D"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ast/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,QAAQ,IAAI,WAAW,EAEvB,QAAQ,IAAI,WAAW,EACxB,MAAM,UAAU,CAAC;AAElB,wBAAgB,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAEnD;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW,CAE5D;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW,CAE5D;AAED,wBAAiB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAU3E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAW,GAAG,GAAG,CAa5D"}
@@ -7,6 +7,7 @@ declare const _default: {
7
7
  fromJSON: typeof fromJSON;
8
8
  isAst(value?: any): value is AstType;
9
9
  isFunction(value?: any): value is Function;
10
+ isVariable(value?: any): value is Variable;
10
11
  getAstValues(value: any): Generator<AstType, void, unknown>;
11
12
  resolve(value: any, config?: Readonly<Partial<{
12
13
  nodes: Partial<Record<import("../types").NodeType, import("../types").Schema<Readonly<Partial<any>>, string>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAcxC,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,EAAE,CAE7C;;;;;;;;;;;;;;;;;;;;AAED,wBAIE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAcxC,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,EAAE,CAE7C;;;;;;;;;;;;;;;;;;;;;AAED,wBAIE"}
@@ -1,21 +1,22 @@
1
- import type { AstType, Location, Config, RenderableTreeNode, RenderableTreeNodes, Schema, ValidationError } from '../types';
1
+ import type { AstType, AttributeValue, Config, Location, MaybePromise, NodeType, RenderableTreeNode, RenderableTreeNodes, Schema, ValidationError } from '../types';
2
2
  export default class Node implements AstType {
3
3
  readonly $$mdtype = "Node";
4
4
  attributes: Record<string, any>;
5
5
  children: Node[];
6
6
  errors: ValidationError[];
7
7
  lines: number[];
8
- type: string;
8
+ type: NodeType;
9
9
  tag?: string;
10
+ annotations: AttributeValue[];
10
11
  inline: boolean;
11
12
  location?: Location;
12
- constructor(type?: string, attributes?: Record<string, any>, children?: Node[], tag?: string);
13
+ constructor(type?: NodeType, attributes?: Record<string, any>, children?: Node[], tag?: string);
13
14
  walk(): Generator<Node, void, unknown>;
14
15
  push(node: Node): void;
15
16
  resolve(config?: Config): Node;
16
17
  findSchema(config?: Config): Schema | undefined;
17
18
  transformAttributes(config?: Config): Record<string, any>;
18
19
  transformChildren(config: Config): RenderableTreeNode[];
19
- transform(config: Config): RenderableTreeNodes;
20
+ transform(config: Config): MaybePromise<RenderableTreeNodes>;
20
21
  }
21
22
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACN,eA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AAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,MAAM,EAAE,eAAe,EAAE,CAAM;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,cAAc,EAAE,CAAC;IAE9B,MAAM,UAAS;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAGlB,IAAI,GAAE,QAAiB,EACvB,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,QAAQ,GAAE,IAAI,EAAO,EACrB,GAAG,CAAC,EAAE,MAAM;IASb,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;IAOvC,IAAI,CAAC,IAAI,EAAE,IAAI;IAIf,OAAO,CAAC,MAAM,GAAE,MAAW,GAAG,IAAI;IAOlC,UAAU,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,GAAG,SAAS;IAInD,mBAAmB,CAAC,MAAM,GAAE,MAAW;IAIvC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAIvD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC;CAG7D"}
@@ -0,0 +1,9 @@
1
+ import type { Node, Value } from './types';
2
+ declare type Options = {
3
+ allowIndentation?: boolean;
4
+ parent?: Node;
5
+ indent?: number;
6
+ };
7
+ export default function format(v: Value, options?: Options): string;
8
+ export {};
9
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,IAAI,EAAE,KAAK,EAAY,MAAM,SAAS,CAAC;AAE/E,aAAK,OAAO,GAAG;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAwWF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAIlE"}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAC;AAK9B,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAiK/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,QAiB5D"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAC;AAK9B,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAqK/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,QAiB5D"}
@@ -24,4 +24,5 @@ export declare const text: Schema;
24
24
  export declare const hardbreak: Schema;
25
25
  export declare const softbreak: Schema;
26
26
  export declare const error: {};
27
+ export declare const node: {};
27
28
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,eAAO,MAAM,QAAQ,EAAE,MAgBtB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAYrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAGvB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAQnB,CAAC;AAEF,eAAO,MAAM,KAAK,EA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,UAAU,EAAE,MAaxB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAclB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAYlB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAEhB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAEnB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAmBhB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAMhB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAGhB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAGnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAGnB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAGpB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAGhB,CAAC;AAEF,eAAO,MAAM,CAAC,EAAE,MAGf,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAapB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAOlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MASlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAOlB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAEvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAIvB,CAAC;AAEF,eAAO,MAAM,KAAK,IAAK,CAAC;AACxB,eAAO,MAAM,IAAI,IAAK,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RenderableTreeNode } from './types';
2
+ export default class Tag<N extends string = string, A extends Record<string, any> = Record<string, any>> {
3
+ readonly $$mdtype: "Tag";
4
+ name: N;
5
+ attributes: A;
6
+ children: RenderableTreeNode[];
7
+ constructor(name?: N, attributes?: A, children?: RenderableTreeNode[]);
8
+ }
9
+ //# sourceMappingURL=tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,GAAG,CACtB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAEnD,QAAQ,CAAC,QAAQ,QAAkB;IAEnC,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,CAAC,CAAC;IACd,QAAQ,EAAE,kBAAkB,EAAE,CAAC;gBAG7B,IAAI,IAAa,EACjB,UAAU,IAAU,EACpB,QAAQ,GAAE,kBAAkB,EAAO;CAMtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../src/tags/conditional.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAS,MAAM,UAAU,CAAC;AAIpD,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,WAEhC;AAmBD,eAAO,MAAM,KAAK,EAAE,MAYnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAKrB,CAAC"}
1
+ {"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../src/tags/conditional.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,MAAM,EAAS,MAAM,UAAU,CAAC;AAIxE,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,WAEhC;AAmBD,eAAO,MAAM,KAAK,EAAE,MAiBnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAKrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../src/tags/partial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,UAAU,CAAC;AAErD,eAAO,MAAM,OAAO,EAAE,MA8BrB,CAAC"}
1
+ {"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../src/tags/partial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,MAAM,EAAmB,MAAM,UAAU,CAAC;AAoBtE,eAAO,MAAM,OAAO,EAAE,MA6BrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAGzC,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,CAAC,MAAM,CAAa;gBAGzB,MAAM,GAAE,UAAU,CAAC,OAAO,GAAG;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO;IAQlE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE;CAGnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAGzC,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,CAAC,MAAM,CAAa;gBAGzB,MAAM,GAAE,UAAU,CAAC,OAAO,GAAG;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO;IAYlE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE;CAGnC"}
@@ -1,12 +1,6 @@
1
- import type { Config, Node, Schema, RenderableTreeNode, RenderableTreeNodes } from './types';
1
+ import type { Schema, Transformer } from './types';
2
2
  declare type AttributesSchema = Schema['attributes'];
3
3
  export declare const globalAttributes: AttributesSchema;
4
- export interface Transformer {
5
- findSchema(node: Node, config: Config): Schema | undefined;
6
- node(node: Node, config: Config): RenderableTreeNodes;
7
- attributes(node: Node, config: Config): Record<string, any>;
8
- children(node: Node, config: Config): RenderableTreeNode[];
9
- }
10
4
  declare const _default: Transformer;
11
5
  export default _default;
12
6
  //# sourceMappingURL=transformer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,IAAI,EAEJ,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,aAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,gBAG9B,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3D,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACtD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAAC;CAC5D;;AAED,wBA8CiB"}
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA0B,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3E,aAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,gBAG9B,CAAC;;AAEF,wBAyDiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/transforms/table.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAWrC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,IAAI,QAqC/C"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/transforms/table.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,UAAU,CAAC;AAW/C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,IAAI,QAqC/C"}
@@ -1,8 +1,10 @@
1
1
  import type Func from './ast/function';
2
2
  import type Node from './ast/node';
3
- import type Tag from './ast/tag';
4
- export type { Node, Tag };
3
+ import type Variable from './ast/variable';
4
+ import type Tag from './tag';
5
+ export type { Node, Tag, Variable };
5
6
  export declare type Function = Func;
7
+ export declare type MaybePromise<T> = T | Promise<T>;
6
8
  export interface AstType {
7
9
  readonly $$mdtype: 'Function' | 'Node' | 'Variable';
8
10
  resolve(config: Config): any;
@@ -46,7 +48,7 @@ export declare type LocationEdge = {
46
48
  line: number;
47
49
  character?: number;
48
50
  };
49
- export declare type NodeType = 'document' | 'heading' | 'paragraph' | 'blockquote' | 'hr' | 'image' | 'fence' | 'tag' | 'list' | 'item' | 'table' | 'thead' | 'tbody' | 'tr' | 'td' | 'th' | 'inline' | 'strong' | 'em' | 's' | 'link' | 'code' | 'text' | 'hardbreak' | 'softbreak';
51
+ export declare type NodeType = 'blockquote' | 'code' | 'document' | 'em' | 'error' | 'fence' | 'hardbreak' | 'heading' | 'hr' | 'image' | 'inline' | 'item' | 'link' | 'list' | 'node' | 'paragraph' | 's' | 'softbreak' | 'strong' | 'table' | 'tag' | 'tbody' | 'td' | 'text' | 'th' | 'thead' | 'tr';
50
52
  export declare type Primitive = null | boolean | number | string;
51
53
  export declare type RenderableTreeNode = Tag | string | null;
52
54
  export declare type RenderableTreeNodes = RenderableTreeNode | RenderableTreeNode[];
@@ -58,7 +60,7 @@ export declare type Schema<C extends Config = Config, R = string> = {
58
60
  children?: string[];
59
61
  attributes?: Record<string, SchemaAttribute>;
60
62
  selfClosing?: boolean;
61
- transform?(node: Node, config: C): RenderableTreeNodes;
63
+ transform?(node: Node, config: C): MaybePromise<RenderableTreeNodes>;
62
64
  validate?(node: Node, config: C): ValidationError[];
63
65
  };
64
66
  export declare type SchemaAttribute = {
@@ -70,6 +72,12 @@ export declare type SchemaAttribute = {
70
72
  errorLevel?: ValidationError['level'];
71
73
  };
72
74
  export declare type SchemaMatches = RegExp | string[] | null;
75
+ export interface Transformer {
76
+ findSchema(node: Node, config: Config): Schema | undefined;
77
+ node(node: Node, config: Config): MaybePromise<RenderableTreeNodes>;
78
+ attributes(node: Node, config: Config): Record<string, any>;
79
+ children(node: Node, config: Config): RenderableTreeNode[];
80
+ }
73
81
  export declare type ValidationError = {
74
82
  id: string;
75
83
  level: 'debug' | 'info' | 'warning' | 'error' | 'critical';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAC1B,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEpC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;IACpD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC;CAC9B;AAED,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,oBAAY,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAE1C,oBAAY,UAAU,GAAG,OAAO,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC,M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5D,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAAC;CAC5D;AAED,oBAAY,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAEF,oBAAY,cAAc,GACtB,mBAAmB,GACnB,OAAO,MAAM,GACb,OAAO,MAAM,GACb,OAAO,OAAO,GACd,OAAO,MAAM,GACb,OAAO,KAAK,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;AAEZ,oBAAY,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type Token from 'markdown-it/lib/token';
2
2
  export declare const OPEN = "{%";
3
3
  export declare const CLOSE = "%}";
4
+ export declare function isPromise(a: any): a is Promise<any>;
4
5
  export declare function findTagEnd(content: string, start?: number): number | null;
5
6
  export declare function parseTags(content: string, firstLine?: number): Token[];
6
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAQ/C,eAAO,MAAM,IAAI,OAAO,CAAC;AACzB,eAAO,MAAM,KAAK,OAAO,CAAC;AAE1B,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,iBA0BpD;AAoBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,KAAK,EAAE,CA+DjE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAQ/C,eAAO,MAAM,IAAI,OAAO,CAAC;AACzB,eAAO,MAAM,KAAK,OAAO,CAAC;AAE1B,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAEnD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,iBA0BpD;AAoBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,KAAK,EAAE,CA+DjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,IAAI,EAEJ,MAAM,EACN,eAAe,EACf,eAAe,EACf,KAAK,EACN,MAAM,SAAS,CAAC;AAUjB,aAAK,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,GAAG,eAAe,EAAE,CA2B7B;AAqED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,qBA8G1D"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,IAAI,EAEJ,MAAM,EACN,eAAe,EACf,eAAe,EACf,KAAK,EACN,MAAM,SAAS,CAAC;AAUjB,aAAK,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,GAAG,eAAe,EAAE,CA2B7B;AAqED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,qBAiI1D"}
package/index.ts CHANGED
@@ -1,18 +1,19 @@
1
- import Tokenizer from './src/tokenizer';
1
+ import Ast from './src/ast';
2
+ import __EXPERIMENTAL__format from './src/formatter';
3
+ import functions from './src/functions';
2
4
  import parser from './src/parser';
3
- import Node from './src/ast/node';
4
- import Tag from './src/ast/tag';
5
- import Ast from './src/ast/index';
6
5
  import * as nodes from './src/schema';
7
- import tags from './src/tags/index';
6
+ import renderers from './src/renderers';
7
+ import Tag from './src/tag';
8
+ import tags from './src/tags';
8
9
  import { truthy } from './src/tags/conditional';
9
- import functions from './src/functions/index';
10
- import renderers from './src/renderers/index';
11
- import transformer from './src/transformer';
12
- import validator from './src/validator';
10
+ import Tokenizer from './src/tokenizer';
11
+ import transformer, { globalAttributes } from './src/transformer';
12
+ import transforms from './src/transforms';
13
13
  import { parseTags } from './src/utils';
14
- import transforms from './src/transforms/index';
14
+ import validator from './src/validator';
15
15
 
16
+ import type { Node } from './src/types';
16
17
  import type Token from 'markdown-it/lib/token';
17
18
  import type { Config, RenderableTreeNode, ValidateError } from './src/types';
18
19
 
@@ -106,29 +107,11 @@ export function createElement(
106
107
  return { name, attributes, children };
107
108
  }
108
109
 
109
- export default {
110
- nodes,
111
- tags,
112
- functions,
113
- renderers,
114
- transforms,
115
- Ast,
116
- Tag,
117
- Tokenizer,
118
- parseTags,
119
- transformer,
120
- validator,
121
- parse,
122
- transform,
123
- validate,
124
- createElement,
125
- truthy,
126
- };
127
-
128
110
  export {
129
111
  nodes,
130
112
  tags,
131
113
  functions,
114
+ globalAttributes,
132
115
  transforms,
133
116
  renderers,
134
117
  Ast,
@@ -138,4 +121,39 @@ export {
138
121
  transformer,
139
122
  validator,
140
123
  truthy,
124
+ __EXPERIMENTAL__format,
141
125
  };
126
+
127
+ export default class Markdoc {
128
+ static nodes = nodes;
129
+ static tags = tags;
130
+ static functions = functions;
131
+ static globalAttributes = globalAttributes;
132
+ static renderers = renderers;
133
+ static transforms = transforms;
134
+ static Ast = Ast;
135
+ static Tag = Tag;
136
+ static Tokenizer = Tokenizer;
137
+ static parseTags = parseTags;
138
+ static transformer = transformer;
139
+ static validator = validator;
140
+ static parse = parse;
141
+ static transform = transform;
142
+ static validate = validate;
143
+ static createElement = createElement;
144
+ static truthy = truthy;
145
+ static __EXPERIMENTAL__format = __EXPERIMENTAL__format;
146
+
147
+ config;
148
+ constructor(config: Config) {
149
+ this.config = config;
150
+ }
151
+
152
+ parse = parse;
153
+ resolve = (content: Parameters<typeof resolve>[0]) =>
154
+ resolve(content, this.config);
155
+ transform = (content: Parameters<typeof transform>[0]) =>
156
+ transform(content, this.config);
157
+ validate = (content: Parameters<typeof validate>[0]) =>
158
+ validate(content, this.config);
159
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markdoc/markdoc",
3
3
  "author": "Ryan Paul",
4
- "version": "0.1.3",
4
+ "version": "0.1.6",
5
5
  "description": "A text markup language for documentation",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -44,6 +44,7 @@
44
44
  "esbuild": "0.13.3",
45
45
  "eslint": "^8.9.0",
46
46
  "jasmine": "3.5.0",
47
+ "jest-diff": "^28.1.3",
47
48
  "markdown-it": "12.3.2",
48
49
  "patch-package": "^6.4.7",
49
50
  "pegjs": "0.11.0-master.b7b87ea",
@@ -60,5 +61,5 @@
60
61
  "bugs": {
61
62
  "url": "https://github.com/markdoc/markdoc/issues"
62
63
  },
63
- "homepage": "https://markdoc.io"
64
+ "homepage": "https://markdoc.dev"
64
65
  }
package/src/ast/base.ts CHANGED
@@ -3,6 +3,7 @@ import type {
3
3
  Config,
4
4
  Function as AstFunction,
5
5
  Scalar,
6
+ Variable as AstVariable,
6
7
  } from '../types';
7
8
 
8
9
  export function isAst(value?: any): value is AstType {
@@ -13,6 +14,10 @@ export function isFunction(value?: any): value is AstFunction {
13
14
  return !!(value?.$$mdtype === 'Function');
14
15
  }
15
16
 
17
+ export function isVariable(value?: any): value is AstVariable {
18
+ return !!(value?.$$mdtype === 'Variable');
19
+ }
20
+
16
21
  export function* getAstValues(value: any): Generator<AstType, void, unknown> {
17
22
  if (value == null || typeof value !== 'object') return;
18
23
 
@@ -3,7 +3,7 @@ import markdoc from '../../index';
3
3
  import Node from './node';
4
4
  import Variable from './variable';
5
5
 
6
- import Tag from '../ast/tag';
6
+ import Tag from '../tag';
7
7
 
8
8
  describe('Node object', function () {
9
9
  describe('traversal', function () {
@@ -30,8 +30,8 @@ describe('Node object', function () {
30
30
  });
31
31
  });
32
32
 
33
- describe('processor rendering', function () {
34
- function process(content, config = {}) {
33
+ describe('transform', function () {
34
+ function transform(content, config = {}) {
35
35
  return markdoc.transform(content, config);
36
36
  }
37
37
 
@@ -43,7 +43,7 @@ describe('processor rendering', function () {
43
43
  ]),
44
44
  ]);
45
45
 
46
- const output = process(example);
46
+ const output = transform(example);
47
47
  expect(output).toDeepEqual(new Tag('h1', {}, ['This is a heading']));
48
48
  });
49
49
 
@@ -53,7 +53,7 @@ describe('processor rendering', function () {
53
53
  language: 'ruby',
54
54
  content: 'test',
55
55
  });
56
- const output = process(example);
56
+ const output = transform(example);
57
57
  expect(output).toDeepEqual(
58
58
  new Tag('pre', { 'data-language': 'ruby' }, ['test'])
59
59
  );
@@ -61,7 +61,7 @@ describe('processor rendering', function () {
61
61
  });
62
62
  });
63
63
 
64
- describe('render functions', function () {
64
+ describe('transform functions', function () {
65
65
  it('with a simple render function', function () {
66
66
  const example = new Node('foo', {});
67
67
 
@@ -71,7 +71,7 @@ describe('processor rendering', function () {
71
71
  },
72
72
  };
73
73
 
74
- const output = process(example, { nodes: { foo } });
74
+ const output = transform(example, { nodes: { foo } });
75
75
  expect(output).toDeepEqual(new Tag('foo', {}, []));
76
76
  });
77
77
 
@@ -90,7 +90,7 @@ describe('processor rendering', function () {
90
90
  },
91
91
  };
92
92
 
93
- const output = process(example, { nodes: { foo } });
93
+ const output = transform(example, { nodes: { foo } });
94
94
  expect(output).toDeepEqual({
95
95
  name: 'foo',
96
96
  attributes: { bar: 'baz', example: 100 },
@@ -116,7 +116,7 @@ describe('processor rendering', function () {
116
116
  'foo'
117
117
  );
118
118
 
119
- const output = process(example, { tags });
119
+ const output = transform(example, { tags });
120
120
  expect(output).toDeepEqual(new Tag('foo', { bar: 'baz' }, ['test']));
121
121
  });
122
122
 
@@ -127,7 +127,7 @@ describe('processor rendering', function () {
127
127
 
128
128
  // @ts-ignore test mutating node in userland
129
129
  example.container = 'bar';
130
- const output = process(example, { tags });
130
+ const output = transform(example, { tags });
131
131
  expect(output).toDeepEqual(['test']);
132
132
  });
133
133
  });
@@ -137,14 +137,14 @@ describe('processor rendering', function () {
137
137
  const example = new Node('foo', {});
138
138
  const foo = { render: 'foo' };
139
139
 
140
- const output = process(example, { nodes: { foo } }) as Tag;
140
+ const output = transform(example, { nodes: { foo } }) as Tag;
141
141
  expect(output.name).toEqual('foo');
142
142
  });
143
143
 
144
144
  it('with no value', function () {
145
145
  const example = new Node('foo', {}, [new Node('bar', {})]);
146
146
 
147
- const output = process(example, {
147
+ const output = transform(example, {
148
148
  nodes: { foo: {}, bar: { render: 'bar' } },
149
149
  });
150
150
  expect(output).toDeepEqual([new Tag('bar', {}, [])]);
@@ -154,7 +154,7 @@ describe('processor rendering', function () {
154
154
  describe('attributes', function () {
155
155
  it('with an id', function () {
156
156
  const example = new Node('paragraph', { id: 'bar' });
157
- const output = process(example);
157
+ const output = transform(example);
158
158
  expect(output).toDeepEqualSubset({
159
159
  name: 'p',
160
160
  attributes: { id: 'bar' },
@@ -165,7 +165,7 @@ describe('processor rendering', function () {
165
165
  const example = new Node('paragraph', {
166
166
  class: { foo: true, bar: false },
167
167
  });
168
- const output = process(example);
168
+ const output = transform(example);
169
169
  expect(output).toDeepEqual(new Tag('p', { class: 'foo' }, []));
170
170
  });
171
171
 
@@ -179,7 +179,7 @@ describe('processor rendering', function () {
179
179
  },
180
180
  };
181
181
 
182
- const output = process(example, { nodes: { foo } });
182
+ const output = transform(example, { nodes: { foo } });
183
183
  expect(output).toDeepEqual(new Tag('foo', { bar: 1, baz: 'test' }));
184
184
  });
185
185
 
@@ -193,7 +193,7 @@ describe('processor rendering', function () {
193
193
  },
194
194
  };
195
195
 
196
- const output = process(example, { nodes: { foo } });
196
+ const output = transform(example, { nodes: { foo } });
197
197
  expect(output).toDeepEqual(
198
198
  new Tag('foo', { 'data-bar': 1, 'data-baz': 'test' })
199
199
  );
@@ -208,7 +208,7 @@ describe('processor rendering', function () {
208
208
  },
209
209
  };
210
210
 
211
- const output = process(example, { nodes: { foo } }) as Tag;
211
+ const output = transform(example, { nodes: { foo } }) as Tag;
212
212
  expect(Object.keys(output.attributes).includes('baz')).toBeFalse();
213
213
  expect(output).toDeepEqual(new Tag('foo', { bar: 1 }, []));
214
214
  });
@@ -222,7 +222,7 @@ describe('processor rendering', function () {
222
222
  },
223
223
  };
224
224
 
225
- const output = process(example, { nodes: { foo } }) as Tag;
225
+ const output = transform(example, { nodes: { foo } }) as Tag;
226
226
  expect(output.attributes.bar).toEqual(10);
227
227
  });
228
228
 
@@ -235,7 +235,7 @@ describe('processor rendering', function () {
235
235
  },
236
236
  };
237
237
 
238
- const output = process(example, { nodes: { foo } }) as Tag;
238
+ const output = transform(example, { nodes: { foo } }) as Tag;
239
239
  expect(output.attributes.bar).toEqual(1);
240
240
  });
241
241
 
@@ -249,7 +249,7 @@ describe('processor rendering', function () {
249
249
  },
250
250
  };
251
251
 
252
- const output = process(example, {
252
+ const output = transform(example, {
253
253
  nodes: { foo },
254
254
  variables: { a: { b: { c: 'example' } } },
255
255
  });
@@ -298,10 +298,62 @@ describe('processor rendering', function () {
298
298
  },
299
299
  };
300
300
 
301
- const output = process(example, config) as Tag;
301
+ const output = transform(example, config) as Tag;
302
302
  expect(output.attributes.bar).toEqual(test.expectedValue);
303
303
  });
304
304
  });
305
305
  });
306
306
  });
307
+
308
+ describe('annotations', () => {
309
+ it('multiple values should be ordered correctly', () => {
310
+ const example = markdoc.parse(
311
+ `\`\`\`js {% z=true .class y=2 x="1" #id %} \nContent\n\`\`\``
312
+ );
313
+
314
+ const fence = example.children[0];
315
+
316
+ const { attributes, annotations } = fence;
317
+
318
+ expect(attributes).toEqual({
319
+ content: 'Content\n',
320
+ language: 'js',
321
+ id: 'id',
322
+ class: { class: true },
323
+ z: true,
324
+ y: 2,
325
+ x: '1',
326
+ });
327
+ expect(annotations).toDeepEqual([
328
+ { type: 'attribute', name: 'z', value: true },
329
+ { type: 'class', name: 'class', value: true },
330
+ { type: 'attribute', name: 'y', value: 2 },
331
+ { type: 'attribute', name: 'x', value: '1' },
332
+ { type: 'attribute', name: 'id', value: 'id' },
333
+ ]);
334
+ });
335
+ });
336
+
337
+ describe('async support', () => {
338
+ it('should allow for injecting an async transformer', async () => {
339
+ const doc = `![img](/src)`;
340
+
341
+ const config = {
342
+ nodes: {
343
+ image: {
344
+ async transform() {
345
+ const value = await new Promise((res) => res('1'));
346
+ return value;
347
+ },
348
+ },
349
+ },
350
+ };
351
+
352
+ // @ts-expect-error
353
+ const content = await markdoc.transform(markdoc.parse(doc), config);
354
+
355
+ // @ts-expect-error
356
+ expect(content.children[0].children[0]).toEqual(['1']);
357
+ });
358
+ });
307
359
  });