@markdoc/markdoc 0.1.1 → 0.1.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/README.md +7 -4
- package/dist/index.d.ts +38 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -36
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +108 -36
- package/dist/index.mjs.map +2 -2
- package/dist/src/ast/node.d.ts +2 -1
- package/dist/src/ast/node.d.ts.map +1 -1
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/tags/partial.d.ts.map +1 -1
- package/dist/src/tokenizer/index.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -1
- package/dist/src/transformer.d.ts +1 -7
- package/dist/src/transformer.d.ts.map +1 -1
- package/dist/src/types.d.ts +10 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/global.d.ts +7 -0
- package/index.ts +37 -19
- package/package.json +6 -4
- package/src/ast/node.test.ts +52 -0
- package/src/ast/node.ts +3 -0
- package/src/parser.test.ts +42 -0
- package/src/parser.ts +33 -3
- package/src/schema.ts +1 -0
- package/src/tags/partial.ts +20 -3
- package/src/tokenizer/index.ts +5 -1
- package/src/tokenizer/plugins/annotations.test.ts +60 -0
- package/src/tokenizer/plugins/annotations.ts +4 -0
- package/src/transformer.ts +17 -16
- package/src/transforms/table.ts +1 -1
- package/src/types.ts +11 -5
- package/src/utils.test.ts +15 -2
- package/src/utils.ts +10 -1
- package/src/validator.test.ts +36 -10
- package/src/validator.ts +11 -11
package/dist/src/ast/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AstType, Location, Config, RenderableTreeNode, RenderableTreeNodes, Schema, ValidationError } from '../types';
|
|
1
|
+
import type { AstType, AttributeValue, Location, Config, 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>;
|
|
@@ -7,6 +7,7 @@ export default class Node implements AstType {
|
|
|
7
7
|
lines: number[];
|
|
8
8
|
type: string;
|
|
9
9
|
tag?: string;
|
|
10
|
+
annotations: AttributeValue[];
|
|
10
11
|
inline: boolean;
|
|
11
12
|
location?: Location;
|
|
12
13
|
constructor(type?: string, attributes?: Record<string, any>, children?: Node[], tag?: string);
|
|
@@ -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,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,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
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,MAAM,EACN,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,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,cAAc,EAAE,CAAC;IAE9B,MAAM,UAAS;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAGlB,IAAI,SAAS,EACb,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,mBAAmB;CAG/C"}
|
package/dist/src/parser.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/src/schema.d.ts.map
CHANGED
|
@@ -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,
|
|
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,EAAE,MAenB,CAAC;AAEF,eAAO,MAAM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../src/tags/partial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,MAAM,
|
|
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;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../../src/tokenizer/plugins/annotations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../../src/tokenizer/plugins/annotations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AA4H9C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,UAAU,QAM5C"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
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,
|
|
1
|
+
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA0B,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3E,aAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAM7C,eAAO,MAAM,gBAAgB,EAAE,gBAG9B,CAAC;;AAEF,wBAyDiB"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type Func from './ast/function';
|
|
1
2
|
import type Node from './ast/node';
|
|
2
|
-
import type Function from './ast/function';
|
|
3
3
|
import type Tag from './ast/tag';
|
|
4
|
-
export type {
|
|
5
|
-
export type
|
|
6
|
-
export type { default as Tag } from './ast/tag';
|
|
4
|
+
export type { Node, Tag };
|
|
5
|
+
export declare type Function = Func;
|
|
7
6
|
export interface AstType {
|
|
8
7
|
readonly $$mdtype: 'Function' | 'Node' | 'Variable';
|
|
9
8
|
resolve(config: Config): any;
|
|
@@ -28,7 +27,7 @@ export declare type ConfigFunction = {
|
|
|
28
27
|
returns?: ValidationType | ValidationType[];
|
|
29
28
|
parameters?: Record<string, SchemaAttribute>;
|
|
30
29
|
transform?(parameters: Record<string, any>, config: Config): any;
|
|
31
|
-
validate?(fn:
|
|
30
|
+
validate?(fn: Func, config: Config): ValidationError[];
|
|
32
31
|
};
|
|
33
32
|
export interface CustomAttributeTypeInterface {
|
|
34
33
|
transform?(value: any, config: Config): Scalar;
|
|
@@ -71,6 +70,12 @@ export declare type SchemaAttribute = {
|
|
|
71
70
|
errorLevel?: ValidationError['level'];
|
|
72
71
|
};
|
|
73
72
|
export declare type SchemaMatches = RegExp | string[] | null;
|
|
73
|
+
export interface Transformer {
|
|
74
|
+
findSchema(node: Node, config: Config): Schema | undefined;
|
|
75
|
+
node(node: Node, config: Config): RenderableTreeNodes;
|
|
76
|
+
attributes(node: Node, config: Config): Record<string, any>;
|
|
77
|
+
children(node: Node, config: Config): RenderableTreeNode[];
|
|
78
|
+
}
|
|
74
79
|
export declare type ValidationError = {
|
|
75
80
|
id: string;
|
|
76
81
|
level: 'debug' | 'info' | 'warning' | 'error' | 'critical';
|
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 findTagEnd(content: string, start?: number): number |
|
|
4
|
+
export declare function findTagEnd(content: string, start?: number): number | null;
|
|
5
5
|
export declare function parseTags(content: string, firstLine?: number): Token[];
|
|
6
6
|
//# 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,
|
|
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"}
|
package/global.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Delimiter } from 'markdown-it/lib/rules_inline/state_inline';
|
|
1
2
|
import type { ValidationError } from './src/types';
|
|
2
3
|
|
|
3
4
|
declare module 'markdown-it/lib/token' {
|
|
@@ -9,3 +10,9 @@ declare module 'markdown-it/lib/token' {
|
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
declare module 'markdown-it/lib/rules_block/state_block' {
|
|
15
|
+
export default class Token extends require('markdown-it/lib/rules_block/state_block') {
|
|
16
|
+
delimiters?: Delimiter[];
|
|
17
|
+
}
|
|
18
|
+
}
|
package/index.ts
CHANGED
|
@@ -5,9 +5,10 @@ import Tag from './src/ast/tag';
|
|
|
5
5
|
import Ast from './src/ast/index';
|
|
6
6
|
import * as nodes from './src/schema';
|
|
7
7
|
import tags from './src/tags/index';
|
|
8
|
+
import { truthy } from './src/tags/conditional';
|
|
8
9
|
import functions from './src/functions/index';
|
|
9
10
|
import renderers from './src/renderers/index';
|
|
10
|
-
import transformer from './src/transformer';
|
|
11
|
+
import transformer, { globalAttributes } from './src/transformer';
|
|
11
12
|
import validator from './src/validator';
|
|
12
13
|
import { parseTags } from './src/utils';
|
|
13
14
|
import transforms from './src/transforms/index';
|
|
@@ -105,28 +106,11 @@ export function createElement(
|
|
|
105
106
|
return { name, attributes, children };
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
export default {
|
|
109
|
-
nodes,
|
|
110
|
-
tags,
|
|
111
|
-
functions,
|
|
112
|
-
renderers,
|
|
113
|
-
transforms,
|
|
114
|
-
Ast,
|
|
115
|
-
Tag,
|
|
116
|
-
Tokenizer,
|
|
117
|
-
parseTags,
|
|
118
|
-
transformer,
|
|
119
|
-
validator,
|
|
120
|
-
parse,
|
|
121
|
-
transform,
|
|
122
|
-
validate,
|
|
123
|
-
createElement,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
109
|
export {
|
|
127
110
|
nodes,
|
|
128
111
|
tags,
|
|
129
112
|
functions,
|
|
113
|
+
globalAttributes,
|
|
130
114
|
transforms,
|
|
131
115
|
renderers,
|
|
132
116
|
Ast,
|
|
@@ -135,4 +119,38 @@ export {
|
|
|
135
119
|
parseTags,
|
|
136
120
|
transformer,
|
|
137
121
|
validator,
|
|
122
|
+
truthy,
|
|
138
123
|
};
|
|
124
|
+
|
|
125
|
+
export default class Markdoc {
|
|
126
|
+
static nodes = nodes;
|
|
127
|
+
static tags = tags;
|
|
128
|
+
static functions = functions;
|
|
129
|
+
static globalAttributes = globalAttributes;
|
|
130
|
+
static renderers = renderers;
|
|
131
|
+
static transforms = transforms;
|
|
132
|
+
static Ast = Ast;
|
|
133
|
+
static Tag = Tag;
|
|
134
|
+
static Tokenizer = Tokenizer;
|
|
135
|
+
static parseTags = parseTags;
|
|
136
|
+
static transformer = transformer;
|
|
137
|
+
static validator = validator;
|
|
138
|
+
static parse = parse;
|
|
139
|
+
static transform = transform;
|
|
140
|
+
static validate = validate;
|
|
141
|
+
static createElement = createElement;
|
|
142
|
+
static truthy = truthy;
|
|
143
|
+
|
|
144
|
+
config;
|
|
145
|
+
constructor(config: Config) {
|
|
146
|
+
this.config = config;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
parse = parse;
|
|
150
|
+
resolve = (content: Parameters<typeof resolve>[0]) =>
|
|
151
|
+
resolve(content, this.config);
|
|
152
|
+
transform = (content: Parameters<typeof transform>[0]) =>
|
|
153
|
+
transform(content, this.config);
|
|
154
|
+
validate = (content: Parameters<typeof validate>[0]) =>
|
|
155
|
+
validate(content, this.config);
|
|
156
|
+
}
|
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.4",
|
|
5
5
|
"description": "A text markup language for documentation",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "node -r ts-eager/register ./node_modules/.bin/jasmine",
|
|
19
19
|
"marktest": "node -r ts-eager/register ${INSPECT:+--inspect-brk} spec/marktest/index.ts spec/marktest/tests.yaml",
|
|
20
|
-
"
|
|
20
|
+
"prebuild": "npx patch-package",
|
|
21
|
+
"build": "npm run build:common && npm run build:types",
|
|
21
22
|
"build:common": "node build.js",
|
|
22
23
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
23
24
|
"lint": "eslint .",
|
|
24
|
-
"grammar": "pegjs -o src/grammar/tag.js src/grammar/tag.pegjs
|
|
25
|
+
"grammar": "pegjs -o src/grammar/tag.js src/grammar/tag.pegjs",
|
|
26
|
+
"postgrammar": "prettier --write src/grammar/tag.js",
|
|
25
27
|
"prettier": "prettier --write index.ts src spec",
|
|
26
28
|
"prettier:check": "prettier --check index.ts src spec",
|
|
27
29
|
"type:check": "tsc --noEmit",
|
|
@@ -58,5 +60,5 @@
|
|
|
58
60
|
"bugs": {
|
|
59
61
|
"url": "https://github.com/markdoc/markdoc/issues"
|
|
60
62
|
},
|
|
61
|
-
"homepage": "https://markdoc.
|
|
63
|
+
"homepage": "https://markdoc.dev"
|
|
62
64
|
}
|
package/src/ast/node.test.ts
CHANGED
|
@@ -304,4 +304,56 @@ describe('processor rendering', function () {
|
|
|
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 = ``;
|
|
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
|
});
|
package/src/ast/node.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { resolve } from './base';
|
|
|
2
2
|
import transformer from '../transformer';
|
|
3
3
|
import type {
|
|
4
4
|
AstType,
|
|
5
|
+
AttributeValue,
|
|
5
6
|
Location,
|
|
6
7
|
Config,
|
|
7
8
|
RenderableTreeNode,
|
|
@@ -19,6 +20,7 @@ export default class Node implements AstType {
|
|
|
19
20
|
lines: number[] = [];
|
|
20
21
|
type: string;
|
|
21
22
|
tag?: string;
|
|
23
|
+
annotations: AttributeValue[];
|
|
22
24
|
|
|
23
25
|
inline = false;
|
|
24
26
|
location?: Location;
|
|
@@ -33,6 +35,7 @@ export default class Node implements AstType {
|
|
|
33
35
|
this.children = children;
|
|
34
36
|
this.type = type;
|
|
35
37
|
this.tag = tag;
|
|
38
|
+
this.annotations = [];
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
*walk(): Generator<Node, void, unknown> {
|
package/src/parser.test.ts
CHANGED
|
@@ -86,6 +86,15 @@ describe('Markdown parser', function () {
|
|
|
86
86
|
expect(link.attributes).toDeepEqual({ href: '/bar' });
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
it('for link with one word and a title', function () {
|
|
90
|
+
const document = convert(`
|
|
91
|
+
[foo](/bar "title")
|
|
92
|
+
`);
|
|
93
|
+
|
|
94
|
+
const link = document.children[0].children[0].children[0];
|
|
95
|
+
expect(link.attributes).toDeepEqual({ href: '/bar', title: 'title' });
|
|
96
|
+
});
|
|
97
|
+
|
|
89
98
|
it('for link', function () {
|
|
90
99
|
const document = convert(`
|
|
91
100
|
[this is a test](/bar)
|
|
@@ -137,6 +146,39 @@ describe('Markdown parser', function () {
|
|
|
137
146
|
content: 'This is a test\n',
|
|
138
147
|
});
|
|
139
148
|
});
|
|
149
|
+
|
|
150
|
+
it('for image with no title', function () {
|
|
151
|
+
const document = convert(``);
|
|
152
|
+
const image = document.children[0].children[0].children[0];
|
|
153
|
+
expect(image.attributes.title).toBe(undefined);
|
|
154
|
+
expect(image.attributes.src).toBe('/url');
|
|
155
|
+
expect(image.attributes.alt).toBe('foo');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('for image with a title', function () {
|
|
159
|
+
const document = convert(``);
|
|
160
|
+
const image = document.children[0].children[0].children[0];
|
|
161
|
+
expect(image.attributes.title).toBe('title');
|
|
162
|
+
expect(image.attributes.src).toBe('/url');
|
|
163
|
+
expect(image.attributes.alt).toBe('foo');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('for table with alignments', function () {
|
|
167
|
+
const document = convert(`
|
|
168
|
+
| Left | Center | Right |
|
|
169
|
+
| :--- | :----: | ----: |
|
|
170
|
+
| Left | Center | Right |
|
|
171
|
+
`);
|
|
172
|
+
const [thead, tbody] = document.children[0].children;
|
|
173
|
+
|
|
174
|
+
expect(thead.children[0].children[0].attributes.align).toBe('left');
|
|
175
|
+
expect(thead.children[0].children[1].attributes.align).toBe('center');
|
|
176
|
+
expect(thead.children[0].children[2].attributes.align).toBe('right');
|
|
177
|
+
|
|
178
|
+
expect(tbody.children[0].children[0].attributes.align).toBe('left');
|
|
179
|
+
expect(tbody.children[0].children[1].attributes.align).toBe('center');
|
|
180
|
+
expect(tbody.children[0].children[2].attributes.align).toBe('right');
|
|
181
|
+
});
|
|
140
182
|
});
|
|
141
183
|
|
|
142
184
|
it('handling a header', function () {
|
package/src/parser.ts
CHANGED
|
@@ -14,11 +14,15 @@ const mappings: Record<string, string> = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
function annotate(node: Node, attributes: AttributeValue[]) {
|
|
17
|
-
for (const
|
|
17
|
+
for (const attribute of attributes) {
|
|
18
|
+
node.annotations.push(attribute);
|
|
19
|
+
|
|
20
|
+
const { name, value, type } = attribute;
|
|
18
21
|
if (type === 'attribute') node.attributes[name] = value;
|
|
19
22
|
else if (type === 'class')
|
|
20
23
|
if (node.attributes.class) node.attributes.class[name] = value;
|
|
21
24
|
else node.attributes.class = { [name]: value };
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
function handleAttrs(token: Token, type: string) {
|
|
@@ -29,11 +33,15 @@ function handleAttrs(token: Token, type: string) {
|
|
|
29
33
|
return { ordered: token.type.startsWith('ordered') };
|
|
30
34
|
case 'link': {
|
|
31
35
|
const attrs = Object.fromEntries(token.attrs);
|
|
32
|
-
return
|
|
36
|
+
return attrs.title
|
|
37
|
+
? { href: attrs.href, title: attrs.title }
|
|
38
|
+
: { href: attrs.href };
|
|
33
39
|
}
|
|
34
40
|
case 'image': {
|
|
35
41
|
const attrs = Object.fromEntries(token.attrs);
|
|
36
|
-
return
|
|
42
|
+
return attrs.title
|
|
43
|
+
? { alt: token.content, src: attrs.src, title: attrs.title }
|
|
44
|
+
: { alt: token.content, src: attrs.src };
|
|
37
45
|
}
|
|
38
46
|
case 'text':
|
|
39
47
|
case 'code':
|
|
@@ -44,6 +52,28 @@ function handleAttrs(token: Token, type: string) {
|
|
|
44
52
|
? { content: token.content }
|
|
45
53
|
: { content: token.content, language };
|
|
46
54
|
}
|
|
55
|
+
case 'td':
|
|
56
|
+
case 'th': {
|
|
57
|
+
if (token.attrs) {
|
|
58
|
+
const attrs = Object.fromEntries(token.attrs);
|
|
59
|
+
|
|
60
|
+
let align;
|
|
61
|
+
if (attrs.style) {
|
|
62
|
+
if (attrs.style.includes('left')) {
|
|
63
|
+
align = 'left';
|
|
64
|
+
} else if (attrs.style.includes('center')) {
|
|
65
|
+
align = 'center';
|
|
66
|
+
} else if (attrs.style.includes('right')) {
|
|
67
|
+
align = 'right';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (align) {
|
|
72
|
+
return { align };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
47
77
|
default:
|
|
48
78
|
return {};
|
|
49
79
|
}
|
package/src/schema.ts
CHANGED
package/src/tags/partial.ts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import type { Node, Config, Schema } from '../types';
|
|
1
|
+
import type { Node, Config, Schema, ValidationError } from '../types';
|
|
2
|
+
|
|
3
|
+
class PartialFile {
|
|
4
|
+
validate(file: any, config: Config): ValidationError[] {
|
|
5
|
+
const { partials = {} } = config;
|
|
6
|
+
const partial = partials[file];
|
|
7
|
+
|
|
8
|
+
if (!partial)
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
id: 'attribute-value-invalid',
|
|
12
|
+
level: 'error',
|
|
13
|
+
message: `Partial \`${file}\` not found. The 'file' attribute must be set in \`config.partials\``,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
2
20
|
|
|
3
21
|
export const partial: Schema = {
|
|
4
22
|
selfClosing: true,
|
|
5
23
|
attributes: {
|
|
6
|
-
file: { type:
|
|
24
|
+
file: { type: PartialFile, render: false, required: true },
|
|
7
25
|
variables: { type: Object, render: false },
|
|
8
26
|
},
|
|
9
|
-
|
|
10
27
|
transform(node: Node, config: Config) {
|
|
11
28
|
const { partials = {} } = config;
|
|
12
29
|
const { file, variables } = node.attributes;
|
package/src/tokenizer/index.ts
CHANGED
|
@@ -12,7 +12,11 @@ export default class Tokenizer {
|
|
|
12
12
|
this.parser = new MarkdownIt(config);
|
|
13
13
|
this.parser.use(annotations, 'annotations', {});
|
|
14
14
|
this.parser.use(frontmatter, 'frontmatter', {});
|
|
15
|
-
this.parser.disable(
|
|
15
|
+
this.parser.disable([
|
|
16
|
+
'lheading',
|
|
17
|
+
// Disable indented `code_block` support https://spec.commonmark.org/0.30/#indented-code-block
|
|
18
|
+
'code',
|
|
19
|
+
]);
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
tokenize(content: string): Token[] {
|
|
@@ -280,6 +280,66 @@ describe('MarkdownIt Annotations plugin', function () {
|
|
|
280
280
|
]);
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
|
+
|
|
284
|
+
describe('fence', function () {
|
|
285
|
+
it('simple with no tags', function () {
|
|
286
|
+
const example = parse('```\nhello\n```');
|
|
287
|
+
expect(example).toDeepEqualSubset([
|
|
288
|
+
{
|
|
289
|
+
type: 'fence',
|
|
290
|
+
children: [
|
|
291
|
+
{
|
|
292
|
+
type: 'text',
|
|
293
|
+
content: 'hello\n',
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
]);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('simple with one tag', function () {
|
|
301
|
+
const example = parse('```\nhello {% foo %}bar{% /foo %}\n```');
|
|
302
|
+
expect(example).toDeepEqualSubset([
|
|
303
|
+
{
|
|
304
|
+
type: 'fence',
|
|
305
|
+
children: [
|
|
306
|
+
{
|
|
307
|
+
type: 'text',
|
|
308
|
+
content: 'hello ',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
type: 'tag_open',
|
|
312
|
+
info: '{% foo %}',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: 'text',
|
|
316
|
+
content: 'bar',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
type: 'tag_close',
|
|
320
|
+
info: '{% /foo %}',
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
]);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('unclosed tag', function () {
|
|
328
|
+
const example = parse('```\nhello {%\n```');
|
|
329
|
+
// unclosed tags should not result in crashes
|
|
330
|
+
expect(example).toDeepEqualSubset([
|
|
331
|
+
{
|
|
332
|
+
type: 'fence',
|
|
333
|
+
children: [
|
|
334
|
+
{
|
|
335
|
+
type: 'text',
|
|
336
|
+
content: 'hello {%\n',
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
]);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
283
343
|
});
|
|
284
344
|
|
|
285
345
|
describe('parsing inline annotations', function () {
|