@markdoc/markdoc 0.5.10 → 0.5.12
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 +20 -13
- package/dist/index.d.ts +22 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6528 -6331
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +6498 -6301
- package/dist/index.mjs.map +4 -4
- package/dist/react.js +2 -1
- package/dist/react.js.map +2 -2
- package/dist/src/parser.d.ts +1 -2
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/renderers/react/react.d.ts.map +1 -1
- package/dist/src/tokenizer/index.d.ts +17 -8
- package/dist/src/tokenizer/index.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/annotations.d.ts +1 -1
- package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/comments.d.ts +1 -1
- package/dist/src/tokenizer/plugins/comments.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/frontmatter.d.ts +1 -1
- package/dist/src/tokenizer/plugins/frontmatter.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/link.d.ts +2 -2
- package/dist/src/tokenizer/plugins/link.d.ts.map +1 -1
- package/dist/src/types.d.ts +22 -0
- 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/index.ts +8 -3
- package/package.json +34 -48
- package/src/grammar/tag.d.ts +1 -1
- package/src/parser.ts +19 -13
- package/src/renderers/react/react.ts +8 -6
- package/src/renderers/react/static.ts +4 -4
- package/src/tag.ts +1 -1
- package/src/tokenizer/index.ts +27 -14
- package/src/tokenizer/plugins/annotations.ts +33 -15
- package/src/tokenizer/plugins/comments.ts +1 -3
- package/src/tokenizer/plugins/frontmatter.ts +1 -2
- package/src/tokenizer/plugins/link.ts +5 -10
- package/src/types.ts +23 -0
- package/src/utils.ts +1 -1
- package/src/validator.ts +2 -2
- package/global.d.ts +0 -18
- package/spec/marktest/index.ts +0 -136
package/README.md
CHANGED
|
@@ -15,13 +15,7 @@ We designed Markdoc to power [Stripe's public docs](http://stripe.com/docs), our
|
|
|
15
15
|
To get started with Markdoc, first install the library:
|
|
16
16
|
|
|
17
17
|
```shell
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
or
|
|
22
|
-
|
|
23
|
-
```shell
|
|
24
|
-
yarn add @markdoc/markdoc
|
|
18
|
+
pnpm add @markdoc/markdoc
|
|
25
19
|
```
|
|
26
20
|
|
|
27
21
|
and import it in your app:
|
|
@@ -54,24 +48,33 @@ Check out [our docs](https://markdoc.dev/docs) for more guidance on how to use M
|
|
|
54
48
|
|
|
55
49
|
### TypeScript
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
The public renderer types require `@types/react`, even when using only the
|
|
52
|
+
Markdown parser or HTML renderer. Package managers that install peer dependencies
|
|
53
|
+
automatically will install it; otherwise, install `@types/react` explicitly.
|
|
54
|
+
The React runtime is optional.
|
|
55
|
+
|
|
56
|
+
For TypeScript projects that use a bundler, use:
|
|
58
57
|
|
|
59
58
|
```json
|
|
60
59
|
{
|
|
61
60
|
"compilerOptions": {
|
|
62
|
-
"
|
|
61
|
+
"module": "esnext",
|
|
62
|
+
"moduleResolution": "bundler",
|
|
63
63
|
"target": "esnext", // works with es2015 or greater
|
|
64
64
|
"esModuleInterop": true
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
For code run directly by Node.js, use `"module": "nodenext"` and
|
|
70
|
+
`"moduleResolution": "nodenext"` instead.
|
|
71
|
+
|
|
69
72
|
### React
|
|
70
73
|
|
|
71
74
|
If you are using React, install Markdoc with:
|
|
72
75
|
|
|
73
76
|
```sh
|
|
74
|
-
|
|
77
|
+
pnpm add @markdoc/markdoc react @types/react
|
|
75
78
|
```
|
|
76
79
|
|
|
77
80
|
## Contributing
|
|
@@ -80,9 +83,13 @@ Contributions and feedback are welcome and encouraged. Check out our [contributi
|
|
|
80
83
|
|
|
81
84
|
### Development
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
Use [pnpm](https://pnpm.io/installation), with the version pinned in `package.json`.
|
|
87
|
+
If using Corepack, run `corepack enable` first.
|
|
88
|
+
|
|
89
|
+
1. Run `pnpm install`
|
|
90
|
+
1. Run `pnpm run build`
|
|
91
|
+
1. Run the tests using `pnpm test`
|
|
92
|
+
1. Check the built package's TypeScript declarations using `pnpm run test:types`
|
|
86
93
|
|
|
87
94
|
## Code of conduct
|
|
88
95
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,10 +12,9 @@ import transformer, { globalAttributes } from './src/transformer';
|
|
|
12
12
|
import transforms from './src/transforms';
|
|
13
13
|
import { parseTags } from './src/utils';
|
|
14
14
|
import validator from './src/validator';
|
|
15
|
-
import type { ParserArgs } from './src/types';
|
|
16
|
-
import type Token from 'markdown-it/lib/token';
|
|
17
|
-
import type { Config, RenderableTreeNode, ValidateError } from './src/types';
|
|
15
|
+
import type { Config, ParserArgs, RenderableTreeNode, Token, ValidateError } from './src/types';
|
|
18
16
|
export * from './src/types';
|
|
17
|
+
export type { TokenizerOptions } from './src/tokenizer';
|
|
19
18
|
export declare function parse(content: string | Token[], args?: string | ParserArgs): Node;
|
|
20
19
|
export declare function resolve<C extends Config = Config>(content: Node, config: C): Node;
|
|
21
20
|
export declare function resolve<C extends Config = Config>(content: Node[], config: C): Node[];
|
|
@@ -35,21 +34,21 @@ export { nodes, tags, functions, globalAttributes, transforms, renderers, Ast, N
|
|
|
35
34
|
export default class Markdoc {
|
|
36
35
|
static nodes: typeof nodes;
|
|
37
36
|
static tags: {
|
|
38
|
-
else: import("
|
|
39
|
-
if: import("
|
|
40
|
-
partial: import("
|
|
41
|
-
slot: import("
|
|
42
|
-
table: import("
|
|
37
|
+
else: import(".").Schema;
|
|
38
|
+
if: import(".").Schema;
|
|
39
|
+
partial: import(".").Schema;
|
|
40
|
+
slot: import(".").Schema;
|
|
41
|
+
table: import(".").Schema;
|
|
43
42
|
};
|
|
44
43
|
static functions: {
|
|
45
|
-
and: import("
|
|
46
|
-
or: import("
|
|
47
|
-
not: import("
|
|
48
|
-
equals: import("
|
|
49
|
-
default: import("
|
|
50
|
-
debug: import("
|
|
44
|
+
and: import(".").ConfigFunction;
|
|
45
|
+
or: import(".").ConfigFunction;
|
|
46
|
+
not: import(".").ConfigFunction;
|
|
47
|
+
equals: import(".").ConfigFunction;
|
|
48
|
+
default: import(".").ConfigFunction;
|
|
49
|
+
debug: import(".").ConfigFunction;
|
|
51
50
|
};
|
|
52
|
-
static globalAttributes: Record<string, import("
|
|
51
|
+
static globalAttributes: Record<string, import(".").SchemaAttribute> | undefined;
|
|
53
52
|
static renderers: {
|
|
54
53
|
html: typeof import("./src/renderers/html").default;
|
|
55
54
|
react: typeof import("./src/renderers/react/react").default;
|
|
@@ -58,10 +57,10 @@ export default class Markdoc {
|
|
|
58
57
|
static transforms: typeof import("./src/transforms/table").default[];
|
|
59
58
|
static Ast: {
|
|
60
59
|
fromJSON: (text: string) => Node | Node[];
|
|
61
|
-
isAst(value?: any): value is import("
|
|
62
|
-
isFunction(value?: any): value is import("
|
|
63
|
-
isVariable(value?: any): value is import("
|
|
64
|
-
getAstValues(value: any): Generator<import("
|
|
60
|
+
isAst(value?: any): value is import(".").AstType;
|
|
61
|
+
isFunction(value?: any): value is import(".").Function;
|
|
62
|
+
isVariable(value?: any): value is import(".").Variable;
|
|
63
|
+
getAstValues(value: any): Generator<import(".").AstType, void, unknown>;
|
|
65
64
|
resolve(value: any, config?: Config): any;
|
|
66
65
|
Function: typeof import("./src/ast/function").default;
|
|
67
66
|
Node: typeof Node;
|
|
@@ -70,7 +69,7 @@ export default class Markdoc {
|
|
|
70
69
|
static Tag: typeof Tag;
|
|
71
70
|
static Tokenizer: typeof Tokenizer;
|
|
72
71
|
static parseTags: typeof parseTags;
|
|
73
|
-
static transformer: import("
|
|
72
|
+
static transformer: import(".").Transformer;
|
|
74
73
|
static validator: typeof validator;
|
|
75
74
|
static parse: typeof parse;
|
|
76
75
|
static transform: typeof transform;
|
|
@@ -79,10 +78,10 @@ export default class Markdoc {
|
|
|
79
78
|
static truthy: typeof truthy;
|
|
80
79
|
static format: typeof format;
|
|
81
80
|
config: Readonly<Partial<{
|
|
82
|
-
nodes: Partial<Record<import("
|
|
83
|
-
tags: Record<string, import("
|
|
81
|
+
nodes: Partial<Record<import(".").NodeType, import(".").Schema<Partial</*elided*/ any>, string>>>;
|
|
82
|
+
tags: Record<string, import(".").Schema>;
|
|
84
83
|
variables: Record<string, any>;
|
|
85
|
-
functions: Record<string, import("
|
|
84
|
+
functions: Record<string, import(".").ConfigFunction>;
|
|
86
85
|
partials: Record<string, any>;
|
|
87
86
|
validation?: {
|
|
88
87
|
parents?: Node[];
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,WAAW,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,SAA2B,MAAM,iBAAiB,CAAC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