markdecl 0.1.0

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 (63) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +11 -0
  3. package/dist/index.d.ts +95 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3368 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/ast/base.d.ts +7 -0
  8. package/dist/src/ast/base.d.ts.map +1 -0
  9. package/dist/src/ast/function.d.ts +9 -0
  10. package/dist/src/ast/function.d.ts.map +1 -0
  11. package/dist/src/ast/index.d.ts +18 -0
  12. package/dist/src/ast/index.d.ts.map +1 -0
  13. package/dist/src/ast/node.d.ts +23 -0
  14. package/dist/src/ast/node.d.ts.map +1 -0
  15. package/dist/src/ast/variable.d.ts +8 -0
  16. package/dist/src/ast/variable.d.ts.map +1 -0
  17. package/dist/src/formatter.d.ts +11 -0
  18. package/dist/src/formatter.d.ts.map +1 -0
  19. package/dist/src/functions/index.d.ts +11 -0
  20. package/dist/src/functions/index.d.ts.map +1 -0
  21. package/dist/src/parser.d.ts +4 -0
  22. package/dist/src/parser.d.ts.map +1 -0
  23. package/dist/src/renderers/html.d.ts +3 -0
  24. package/dist/src/renderers/html.d.ts.map +1 -0
  25. package/dist/src/renderers/index.d.ts +6 -0
  26. package/dist/src/renderers/index.d.ts.map +1 -0
  27. package/dist/src/schema-types/conditional.d.ts +13 -0
  28. package/dist/src/schema-types/conditional.d.ts.map +1 -0
  29. package/dist/src/schema.d.ts +36 -0
  30. package/dist/src/schema.d.ts.map +1 -0
  31. package/dist/src/tag.d.ts +10 -0
  32. package/dist/src/tag.d.ts.map +1 -0
  33. package/dist/src/tags/conditional.d.ts +5 -0
  34. package/dist/src/tags/conditional.d.ts.map +1 -0
  35. package/dist/src/tags/index.d.ts +9 -0
  36. package/dist/src/tags/index.d.ts.map +1 -0
  37. package/dist/src/tags/partial.d.ts +3 -0
  38. package/dist/src/tags/partial.d.ts.map +1 -0
  39. package/dist/src/tags/slot.d.ts +3 -0
  40. package/dist/src/tags/slot.d.ts.map +1 -0
  41. package/dist/src/tags/table.d.ts +3 -0
  42. package/dist/src/tags/table.d.ts.map +1 -0
  43. package/dist/src/tokenizer/index.d.ts +11 -0
  44. package/dist/src/tokenizer/index.d.ts.map +1 -0
  45. package/dist/src/tokenizer/plugins/annotations.d.ts +3 -0
  46. package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -0
  47. package/dist/src/tokenizer/plugins/comments.d.ts +3 -0
  48. package/dist/src/tokenizer/plugins/comments.d.ts.map +1 -0
  49. package/dist/src/tokenizer/plugins/frontmatter.d.ts +3 -0
  50. package/dist/src/tokenizer/plugins/frontmatter.d.ts.map +1 -0
  51. package/dist/src/transformer.d.ts +4 -0
  52. package/dist/src/transformer.d.ts.map +1 -0
  53. package/dist/src/transforms/index.d.ts +4 -0
  54. package/dist/src/transforms/index.d.ts.map +1 -0
  55. package/dist/src/transforms/table.d.ts +3 -0
  56. package/dist/src/transforms/table.d.ts.map +1 -0
  57. package/dist/src/types.d.ts +134 -0
  58. package/dist/src/types.d.ts.map +1 -0
  59. package/dist/src/utils.d.ts +9 -0
  60. package/dist/src/utils.d.ts.map +1 -0
  61. package/dist/src/validator.d.ts +28 -0
  62. package/dist/src/validator.d.ts.map +1 -0
  63. package/package.json +62 -0
@@ -0,0 +1,13 @@
1
+ import { Config, CustomAttributeTypeInterface, ValidationError } from '../types';
2
+ /**
3
+ * Conditional attribute type for Markdoc {% if /%} and {% else /%} tags.
4
+ *
5
+ * Acceptable values are:
6
+ * - `boolean` (true or false)
7
+ * - `null` or `undefined` (in case of using variable that's not defined)
8
+ * - `object`
9
+ */
10
+ export declare class ConditionalAttributeType implements CustomAttributeTypeInterface {
11
+ validate(value: any, _config: Config, key: string): ValidationError[];
12
+ }
13
+ //# sourceMappingURL=conditional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../src/schema-types/conditional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEjF;;;;;;;GAOG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAC3E,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE;CAkBtE"}
@@ -0,0 +1,36 @@
1
+ import { Schema } from './types';
2
+ export declare const document: Schema;
3
+ export declare const heading: Schema;
4
+ export declare const paragraph: Schema;
5
+ export declare const image: Schema;
6
+ export declare const fence: Schema;
7
+ export declare const blockquote: Schema;
8
+ export declare const item: Schema;
9
+ export declare const list: Schema;
10
+ export declare const hr: Schema;
11
+ export declare const table: Schema;
12
+ export declare const td: Schema;
13
+ export declare const th: Schema;
14
+ export declare const tr: Schema;
15
+ export declare const tbody: Schema;
16
+ export declare const thead: Schema;
17
+ export declare const strong: Schema;
18
+ export declare const em: Schema;
19
+ export declare const s: Schema;
20
+ export declare const inline: Schema;
21
+ export declare const link: Schema;
22
+ export declare const code: Schema;
23
+ export declare const text: Schema;
24
+ export declare const hardbreak: Schema;
25
+ export declare const softbreak: Schema;
26
+ export declare const comment: {
27
+ attributes: {
28
+ content: {
29
+ type: StringConstructor;
30
+ required: boolean;
31
+ };
32
+ };
33
+ };
34
+ export declare const error: {};
35
+ export declare const node: {};
36
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +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,MAiBtB,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,MAGxB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAclB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAclB,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,MAQhB,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,MAMpB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,MAMhB,CAAC;AAEF,eAAO,MAAM,CAAC,EAAE,MAGf,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAcpB,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,OAAO;;;;;;;CAInB,CAAC;AAEF,eAAO,MAAM,KAAK,IAAK,CAAC;AACxB,eAAO,MAAM,IAAI,IAAK,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { 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
+ static isTag: (tag: any) => tag is Tag;
5
+ name: N;
6
+ attributes: A;
7
+ children: RenderableTreeNode[];
8
+ constructor(name?: N, attributes?: A, children?: RenderableTreeNode[]);
9
+ }
10
+ //# 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,EAAG,KAAK,CAAU;IAEnC,MAAM,CAAC,KAAK,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,GAAG,CAEnC;IAEF,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,CAAC,CAAC;IACd,QAAQ,EAAE,kBAAkB,EAAE,CAAC;gBAEnB,IAAI,GAAY,CAAC,EAAE,UAAU,GAAS,CAAC,EAAE,QAAQ,GAAE,kBAAkB,EAAO;CAKzF"}
@@ -0,0 +1,5 @@
1
+ import { Schema } from '../types';
2
+ export declare function truthy(value: any): boolean;
3
+ export declare const tagIf: Schema;
4
+ export declare const tagElse: Schema;
5
+ //# sourceMappingURL=conditional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../src/tags/conditional.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,MAAM,EAEP,MAAM,UAAU,CAAC;AAKlB,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,WAEhC;AAgBD,eAAO,MAAM,KAAK,EAAE,MAmBnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAKrB,CAAC"}
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ else: import('../types').Schema;
3
+ if: import('../types').Schema;
4
+ partial: import('../types').Schema;
5
+ slot: import('../types').Schema;
6
+ table: import('../types').Schema;
7
+ };
8
+ export default _default;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":";;;;;;;AAKA,wBAME"}
@@ -0,0 +1,3 @@
1
+ import { Schema } from '../types';
2
+ export declare const partial: Schema;
3
+ //# sourceMappingURL=partial.d.ts.map
@@ -0,0 +1 @@
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,MA4BrB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Schema } from '../types';
2
+ export declare const slot: Schema;
3
+ //# sourceMappingURL=slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../../src/tags/slot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,IAAI,EAAE,MAIlB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Schema } from '../types';
2
+ export declare const table: Schema;
3
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/tags/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,KAAK,EAAE,MAGnB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Options as MarkdownItOptions } from 'markdown-it/lib/index.mjs';
2
+ import { default as Token } from 'markdown-it/lib/token.mjs';
3
+ export default class Tokenizer {
4
+ private parser;
5
+ constructor(config?: MarkdownItOptions & {
6
+ allowIndentation?: boolean;
7
+ allowComments?: boolean;
8
+ });
9
+ tokenize(content: string): Token[];
10
+ }
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/index.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,KAAK,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAI1F,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,CAAC,MAAM,CAAa;gBAGzB,MAAM,GAAE,iBAAiB,GAAG;QAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;KACpB;IAcR,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE;CAGnC"}
@@ -0,0 +1,3 @@
1
+ import { default as MarkdownIt } from 'markdown-it/lib/index.mjs';
2
+ export default function plugin(md: MarkdownIt): void;
3
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../../src/tokenizer/plugins/annotations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AAsHxD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,UAAU,QAM5C"}
@@ -0,0 +1,3 @@
1
+ import { default as MarkdownIt } from 'markdown-it/lib/index.mjs';
2
+ export default function plugin(md: MarkdownIt): void;
3
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../../src/tokenizer/plugins/comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AA0CxD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,UAAU,QAG5C"}
@@ -0,0 +1,3 @@
1
+ import { default as MarkdownIt } from 'markdown-it/lib/index.mjs';
2
+ export default function plugin(md: MarkdownIt): void;
3
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../../src/tokenizer/plugins/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AA8BxD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,EAAE,UAAU,QAE5C"}
@@ -0,0 +1,4 @@
1
+ import { Transformer } from './types';
2
+ declare const _default: Transformer;
3
+ export default _default;
4
+ //# sourceMappingURL=transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAMV,WAAW,EACZ,MAAM,SAAS,CAAC;wBAoEZ,WAAW;AAlEhB,wBAkEiB"}
@@ -0,0 +1,4 @@
1
+ import { default as table } from './table';
2
+ declare const _default: (typeof table)[];
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;;AAC5B,wBAAuB"}
@@ -0,0 +1,3 @@
1
+ import { Node } from '../types';
2
+ export default function transform(document: Node): void;
3
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,134 @@
1
+ import { default as Func } from './ast/function';
2
+ import { default as Node } from './ast/node';
3
+ import { default as Var } from './ast/variable';
4
+ import { default as Tag } from './tag';
5
+ export type { Node, Tag };
6
+ export declare type Function = Func;
7
+ export declare type Variable = Var;
8
+ export type MaybePromise<T> = T | Promise<T>;
9
+ export interface AstType {
10
+ readonly $$mdtype: 'Function' | 'Node' | 'Variable';
11
+ resolve(config: Config): any;
12
+ }
13
+ export type AttributeValue = {
14
+ type: string;
15
+ name: string;
16
+ value: any;
17
+ };
18
+ export type Config<R = string> = Readonly<ConfigType<R>>;
19
+ export type ConfigType<R = string> = Partial<{
20
+ nodes: Partial<Record<NodeType, Schema<ConfigType, R>>>;
21
+ tags: Record<string, Schema>;
22
+ variables: Record<string, any>;
23
+ functions: Record<string, ConfigFunction>;
24
+ partials: Record<string, any>;
25
+ validation?: {
26
+ parents?: Node[];
27
+ validateFunctions?: boolean;
28
+ environment?: string;
29
+ };
30
+ }>;
31
+ export type ConfigFunction = {
32
+ returns?: ValidationType | ValidationType[];
33
+ parameters?: Record<string, SchemaAttribute>;
34
+ transform?(parameters: Record<string, any>, config: Config): any;
35
+ validate?(fn: Func, config: Config): ValidationError[];
36
+ };
37
+ export interface CustomAttributeTypeInterface {
38
+ transform?(value: any, config: Config): Scalar;
39
+ validate?(value: any, config: Config, name: string): ValidationError[];
40
+ }
41
+ export interface CustomAttributeType {
42
+ new (): CustomAttributeTypeInterface;
43
+ readonly prototype: CustomAttributeTypeInterface;
44
+ }
45
+ export type Location = {
46
+ file?: string;
47
+ start: LocationEdge;
48
+ end: LocationEdge;
49
+ };
50
+ export type LocationEdge = {
51
+ line: number;
52
+ character?: number;
53
+ };
54
+ export type NodeType = 'blockquote' | 'code' | 'comment' | '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';
55
+ export type Primitive = null | boolean | number | string;
56
+ export type RenderableTreeNode = Tag | Scalar;
57
+ export type RenderableTreeNodes = RenderableTreeNode | RenderableTreeNode[];
58
+ export type Scalar = Primitive | Scalar[] | {
59
+ [key: string]: Scalar;
60
+ };
61
+ export type Schema<C extends Config = Config, R = string> = {
62
+ render?: R;
63
+ children?: string[];
64
+ attributes?: Record<string, SchemaAttribute>;
65
+ slots?: Record<string, SchemaSlot>;
66
+ selfClosing?: boolean;
67
+ inline?: boolean;
68
+ transform?(node: Node, config: C): MaybePromise<RenderableTreeNodes>;
69
+ validate?(node: Node, config: C): MaybePromise<ValidationError[]>;
70
+ description?: string;
71
+ };
72
+ export type SchemaAttribute = {
73
+ type?: ValidationType | ValidationType[];
74
+ render?: boolean | string;
75
+ default?: any;
76
+ required?: boolean;
77
+ matches?: SchemaMatches | ((config: Config) => SchemaMatches);
78
+ validate?(value: any, config: Config, name: string): ValidationError[];
79
+ errorLevel?: ValidationError['level'];
80
+ description?: string;
81
+ };
82
+ export type SchemaMatches = RegExp | string[] | null;
83
+ export type SchemaSlot = {
84
+ render?: boolean | string;
85
+ required?: boolean;
86
+ };
87
+ export interface Transformer {
88
+ findSchema(node: Node, config: Config): Schema | undefined;
89
+ node(node: Node, config: Config): MaybePromise<RenderableTreeNodes>;
90
+ attributes(node: Node, config: Config): Record<string, any>;
91
+ children(node: Node, config: Config): RenderableTreeNode[];
92
+ }
93
+ export type ValidationError = {
94
+ id: string;
95
+ level: 'debug' | 'info' | 'warning' | 'error' | 'critical';
96
+ message: string;
97
+ location?: Location;
98
+ };
99
+ export type ValidateError = {
100
+ type: string;
101
+ lines: number[];
102
+ location?: Location;
103
+ error: ValidationError;
104
+ };
105
+ export type ValidationType = CustomAttributeType | typeof String | typeof Number | typeof Boolean | typeof Object | typeof Array | 'String' | 'Number' | 'Boolean' | 'Object' | 'Array';
106
+ export type Value = AstType | Scalar;
107
+ export type ParserArgs = {
108
+ file?: string;
109
+ slots?: boolean;
110
+ location?: boolean;
111
+ };
112
+ export type ParserToken = {
113
+ type: string;
114
+ tag?: string;
115
+ attrs?: [string, string][] | null;
116
+ map?: [number, number] | null;
117
+ nesting?: 1 | 0 | -1;
118
+ level?: number;
119
+ content?: string;
120
+ markup?: string;
121
+ info?: string;
122
+ block?: boolean;
123
+ hidden?: boolean;
124
+ meta?: any;
125
+ errors?: ValidationError[];
126
+ position?: {
127
+ start?: number;
128
+ end?: number;
129
+ };
130
+ start?: number;
131
+ end?: number;
132
+ children?: ParserToken[] | null;
133
+ };
134
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAE7B,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAC1B,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,IAAI,CAAC;AACpC,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,GAAG,CAAC;AAEnC,MAAM,MAAM,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,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzD,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC;IAC3C,KAAK,EAAE,OAAO,CAAC,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C;IAC9B,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;CACjC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ParserToken } from './types';
2
+ export declare const OPEN = "{%";
3
+ export declare const CLOSE = "%}";
4
+ export declare const IDENTIFIER_REGEX: RegExp;
5
+ export declare function isIdentifier(s: any): s is string;
6
+ export declare function isPromise(a: any): a is Promise<any>;
7
+ export declare function findTagEnd(content: string, start?: number): number | null;
8
+ export declare function parseTags(content: string, firstLine?: number): ParserToken[];
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQ3C,eAAO,MAAM,IAAI,OAAO,CAAC;AACzB,eAAO,MAAM,KAAK,OAAO,CAAC;AAE1B,eAAO,MAAM,gBAAgB,QAAqB,CAAC;AAEnD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,MAAM,CAEhD;AAED,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,WAAW,EAAE,CA+DvE"}
@@ -0,0 +1,28 @@
1
+ import { Node, Config, SchemaAttribute, ValidationError, Value } from './types';
2
+ type TypeParam = NonNullable<SchemaAttribute['type']>;
3
+ export declare function validateType(type: TypeParam, value: Value, config: Config, key: string): boolean | ValidationError[];
4
+ export default function validator(node: Node, config: Config): ValidationError[] | Promise<ValidationError[]>;
5
+ export declare function walkWithParents(node: Node, parents?: Node[]): Generator<[Node, Node[]]>;
6
+ export declare function validateTree(content: Node, config: Config): Promise<({
7
+ type: import('./types').NodeType;
8
+ lines: number[];
9
+ location: import('./types').Location | undefined;
10
+ error: ValidationError;
11
+ } | {
12
+ type: import('./types').NodeType;
13
+ lines: number[];
14
+ location: import('./types').Location | undefined;
15
+ error: ValidationError;
16
+ })[]> | (Promise<{
17
+ type: import('./types').NodeType;
18
+ lines: number[];
19
+ location: import('./types').Location | undefined;
20
+ error: ValidationError;
21
+ }[]> | {
22
+ type: import('./types').NodeType;
23
+ lines: number[];
24
+ location: import('./types').Location | undefined;
25
+ error: ValidationError;
26
+ })[];
27
+ export {};
28
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAU/F,KAAK,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,EACd,GAAG,EAAE,MAAM,GACV,OAAO,GAAG,eAAe,EAAE,CA0B7B;AA2ED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kDA+J3D;AAED,wBAAiB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,IAAI,EAAO,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAI5F;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;KAqBzD"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "markdecl",
3
+ "author": "Yuhei Yamauchi",
4
+ "version": "0.1.0",
5
+ "description": "fork of markdoc",
6
+ "type": "module",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "sideEffects": false,
20
+ "license": "MIT",
21
+ "engines": {
22
+ "node": ">=24.0.0"
23
+ },
24
+ "optionalDependencies": {
25
+ "@types/linkify-it": "^5.0.0",
26
+ "@types/markdown-it": "14.1.2"
27
+ },
28
+ "dependencies": {
29
+ "markdown-it": "14.1.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.3.0",
33
+ "deep-assert": "0.3.0",
34
+ "diff": "^8.0.3",
35
+ "jest-diff": "^30.2.0",
36
+ "oxfmt": "^0.34.0",
37
+ "oxlint": "^1.49.0",
38
+ "peggy": "^5.0.6",
39
+ "typescript": "^5.9.3",
40
+ "vite": "^7.3.1",
41
+ "vite-plugin-dts": "^4.5.4",
42
+ "vitest": "^4.0.18",
43
+ "yaml-js": "^0.3.1"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "registry": "https://registry.npmjs.org/"
48
+ },
49
+ "scripts": {
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
52
+ "marktest": "vitest run spec/marktest/marktest.test.ts",
53
+ "build": "vite build",
54
+ "lint": "oxlint . --vitest-plugin",
55
+ "grammar": "peggy --format es --output src/grammar/tag.js src/grammar/tag.pegjs",
56
+ "postgrammar": "oxfmt --write src/grammar/tag.js",
57
+ "format": "oxfmt --write index.ts src spec",
58
+ "format:check": "oxfmt --check index.ts src spec",
59
+ "type:check": "tsc --noEmit",
60
+ "prepublish": "pnpm run build && pnpm run grammar"
61
+ }
62
+ }