@markdoc/markdoc 0.1.4 → 0.1.7
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 +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6787 -6409
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +6787 -6409
- package/dist/index.mjs.map +3 -3
- package/dist/src/ast/base.d.ts +2 -1
- package/dist/src/ast/base.d.ts.map +1 -1
- 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 +4 -4
- package/dist/src/ast/node.d.ts.map +1 -1
- package/dist/src/formatter.d.ts +10 -0
- package/dist/src/formatter.d.ts.map +1 -0
- package/dist/src/schema.d.ts +1 -0
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/tag.d.ts +9 -0
- package/dist/src/tag.d.ts.map +1 -0
- package/dist/src/tags/conditional.d.ts.map +1 -1
- package/dist/src/transformer.d.ts.map +1 -1
- package/dist/src/transforms/table.d.ts.map +1 -1
- package/dist/src/types.d.ts +7 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/validator.d.ts.map +1 -1
- package/index.ts +12 -9
- package/package.json +2 -1
- package/src/ast/base.ts +5 -0
- package/src/ast/node.test.ts +21 -21
- package/src/ast/node.ts +6 -4
- package/src/formatter.test.ts +475 -0
- package/src/formatter.ts +391 -0
- package/src/schema.ts +3 -2
- package/src/tag.ts +22 -0
- package/src/tags/conditional.ts +10 -3
- package/src/transformer.ts +2 -5
- package/src/transforms/table.ts +2 -2
- package/src/types.ts +25 -20
- package/src/utils.ts +4 -0
- package/src/validator.test.ts +80 -18
- package/src/validator.ts +22 -3
- package/dist/src/ast/tag.d.ts +0 -9
- package/dist/src/ast/tag.d.ts.map +0 -1
- package/src/ast/tag.ts +0 -19
package/dist/src/ast/base.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/src/ast/index.d.ts
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/src/ast/node.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { AstType, AttributeValue, Location,
|
|
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:
|
|
8
|
+
type: NodeType;
|
|
9
9
|
tag?: string;
|
|
10
10
|
annotations: AttributeValue[];
|
|
11
11
|
inline: boolean;
|
|
12
12
|
location?: Location;
|
|
13
|
-
constructor(type?:
|
|
13
|
+
constructor(type?: NodeType, attributes?: Record<string, any>, children?: Node[], tag?: string);
|
|
14
14
|
walk(): Generator<Node, void, unknown>;
|
|
15
15
|
push(node: Node): void;
|
|
16
16
|
resolve(config?: Config): Node;
|
|
17
17
|
findSchema(config?: Config): Schema | undefined;
|
|
18
18
|
transformAttributes(config?: Config): Record<string, any>;
|
|
19
19
|
transformChildren(config: Config): RenderableTreeNode[];
|
|
20
|
-
transform(config: Config): RenderableTreeNodes
|
|
20
|
+
transform(config: Config): MaybePromise<RenderableTreeNodes>;
|
|
21
21
|
}
|
|
22
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,cAAc,EACd,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACN,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,OAAO;IAC1C,QAAQ,CAAC,QAAQ,UAAU;IAE3B,UAAU,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,10 @@
|
|
|
1
|
+
import type { Node, Value } from './types';
|
|
2
|
+
declare type Options = {
|
|
3
|
+
allowIndentation?: boolean;
|
|
4
|
+
maxTagOpeningWidth?: number;
|
|
5
|
+
parent?: Node;
|
|
6
|
+
indent?: number;
|
|
7
|
+
};
|
|
8
|
+
export default function format(v: Value, options?: Options): string;
|
|
9
|
+
export {};
|
|
10
|
+
//# 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,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,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":"
|
|
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":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"
|
|
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,
|
|
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"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type Func from './ast/function';
|
|
2
2
|
import type Node from './ast/node';
|
|
3
|
-
import type
|
|
4
|
-
|
|
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 = '
|
|
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 = {
|
|
@@ -72,7 +74,7 @@ export declare type SchemaAttribute = {
|
|
|
72
74
|
export declare type SchemaMatches = RegExp | string[] | null;
|
|
73
75
|
export interface Transformer {
|
|
74
76
|
findSchema(node: Node, config: Config): Schema | undefined;
|
|
75
|
-
node(node: Node, config: Config): RenderableTreeNodes
|
|
77
|
+
node(node: Node, config: Config): MaybePromise<RenderableTreeNodes>;
|
|
76
78
|
attributes(node: Node, config: Config): Record<string, any>;
|
|
77
79
|
children(node: Node, config: Config): RenderableTreeNode[];
|
|
78
80
|
}
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -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,
|
|
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,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAE7B,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACpC,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEpC,oBAAY,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,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,MA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b,OAAO,KAAK,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;AAEZ,oBAAY,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -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
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
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
|
|
10
|
-
import renderers from './src/renderers/index';
|
|
10
|
+
import Tokenizer from './src/tokenizer';
|
|
11
11
|
import transformer, { globalAttributes } from './src/transformer';
|
|
12
|
-
import
|
|
12
|
+
import transforms from './src/transforms';
|
|
13
13
|
import { parseTags } from './src/utils';
|
|
14
|
-
import
|
|
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
|
|
|
@@ -120,6 +121,7 @@ export {
|
|
|
120
121
|
transformer,
|
|
121
122
|
validator,
|
|
122
123
|
truthy,
|
|
124
|
+
__EXPERIMENTAL__format,
|
|
123
125
|
};
|
|
124
126
|
|
|
125
127
|
export default class Markdoc {
|
|
@@ -140,6 +142,7 @@ export default class Markdoc {
|
|
|
140
142
|
static validate = validate;
|
|
141
143
|
static createElement = createElement;
|
|
142
144
|
static truthy = truthy;
|
|
145
|
+
static __EXPERIMENTAL__format = __EXPERIMENTAL__format;
|
|
143
146
|
|
|
144
147
|
config;
|
|
145
148
|
constructor(config: Config) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdoc/markdoc",
|
|
3
3
|
"author": "Ryan Paul",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
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",
|
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
|
|
package/src/ast/node.test.ts
CHANGED
|
@@ -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 '../
|
|
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('
|
|
34
|
-
function
|
|
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 =
|
|
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 =
|
|
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('
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
252
|
+
const output = transform(example, {
|
|
253
253
|
nodes: { foo },
|
|
254
254
|
variables: { a: { b: { c: 'example' } } },
|
|
255
255
|
});
|
|
@@ -298,7 +298,7 @@ describe('processor rendering', function () {
|
|
|
298
298
|
},
|
|
299
299
|
};
|
|
300
300
|
|
|
301
|
-
const output =
|
|
301
|
+
const output = transform(example, config) as Tag;
|
|
302
302
|
expect(output.attributes.bar).toEqual(test.expectedValue);
|
|
303
303
|
});
|
|
304
304
|
});
|
package/src/ast/node.ts
CHANGED
|
@@ -3,8 +3,10 @@ import transformer from '../transformer';
|
|
|
3
3
|
import type {
|
|
4
4
|
AstType,
|
|
5
5
|
AttributeValue,
|
|
6
|
-
Location,
|
|
7
6
|
Config,
|
|
7
|
+
Location,
|
|
8
|
+
MaybePromise,
|
|
9
|
+
NodeType,
|
|
8
10
|
RenderableTreeNode,
|
|
9
11
|
RenderableTreeNodes,
|
|
10
12
|
Schema,
|
|
@@ -18,7 +20,7 @@ export default class Node implements AstType {
|
|
|
18
20
|
children: Node[];
|
|
19
21
|
errors: ValidationError[] = [];
|
|
20
22
|
lines: number[] = [];
|
|
21
|
-
type:
|
|
23
|
+
type: NodeType;
|
|
22
24
|
tag?: string;
|
|
23
25
|
annotations: AttributeValue[];
|
|
24
26
|
|
|
@@ -26,7 +28,7 @@ export default class Node implements AstType {
|
|
|
26
28
|
location?: Location;
|
|
27
29
|
|
|
28
30
|
constructor(
|
|
29
|
-
type = 'node',
|
|
31
|
+
type: NodeType = 'node',
|
|
30
32
|
attributes: Record<string, any> = {},
|
|
31
33
|
children: Node[] = [],
|
|
32
34
|
tag?: string
|
|
@@ -68,7 +70,7 @@ export default class Node implements AstType {
|
|
|
68
70
|
return transformer.children(this, config);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
transform(config: Config): RenderableTreeNodes {
|
|
73
|
+
transform(config: Config): MaybePromise<RenderableTreeNodes> {
|
|
72
74
|
return transformer.node(this, config);
|
|
73
75
|
}
|
|
74
76
|
}
|