@substrate-system/markdown-toc 1.3.4 → 1.3.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/README.md +12 -9
- package/dist/cli.js +114 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +7 -0
- package/dist/insert-markdown.js +37 -0
- package/dist/insert-markdown.js.map +7 -0
- package/dist/markdown-toc.js +230 -0
- package/dist/markdown-toc.js.map +7 -0
- package/dist/meta.json +177 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/insert-markdown.d.ts +3 -0
- package/dist/src/insert-markdown.d.ts.map +1 -0
- package/dist/src/markdown-toc.d.ts +11 -0
- package/dist/src/markdown-toc.d.ts.map +1 -0
- package/dist/src/types.d.ts +67 -0
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +40 -107
- package/cli.js +0 -78
- package/index.js +0 -255
- package/lib/insert.js +0 -67
- package/lib/utils.js +0 -86
package/dist/meta.json
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
{
|
|
2
|
+
"inputs": {
|
|
3
|
+
"src/index.ts": {
|
|
4
|
+
"bytes": 1028,
|
|
5
|
+
"imports": [],
|
|
6
|
+
"format": "esm"
|
|
7
|
+
},
|
|
8
|
+
"src/cli.ts": {
|
|
9
|
+
"bytes": 4082,
|
|
10
|
+
"imports": [],
|
|
11
|
+
"format": "esm"
|
|
12
|
+
},
|
|
13
|
+
"src/markdown-toc.ts": {
|
|
14
|
+
"bytes": 8699,
|
|
15
|
+
"imports": [],
|
|
16
|
+
"format": "esm"
|
|
17
|
+
},
|
|
18
|
+
"src/insert-markdown.ts": {
|
|
19
|
+
"bytes": 1454,
|
|
20
|
+
"imports": [],
|
|
21
|
+
"format": "esm"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"outputs": {
|
|
25
|
+
"dist/index.js.map": {
|
|
26
|
+
"imports": [],
|
|
27
|
+
"exports": [],
|
|
28
|
+
"inputs": {},
|
|
29
|
+
"bytes": 1510
|
|
30
|
+
},
|
|
31
|
+
"dist/index.js": {
|
|
32
|
+
"imports": [
|
|
33
|
+
{
|
|
34
|
+
"path": "remarkable",
|
|
35
|
+
"kind": "import-statement",
|
|
36
|
+
"external": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "./markdown-toc.js",
|
|
40
|
+
"kind": "import-statement",
|
|
41
|
+
"external": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"path": "./insert-markdown.js",
|
|
45
|
+
"kind": "import-statement",
|
|
46
|
+
"external": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"exports": [
|
|
50
|
+
"Remarkable",
|
|
51
|
+
"bullets",
|
|
52
|
+
"generateToc",
|
|
53
|
+
"getHighest",
|
|
54
|
+
"getTitle",
|
|
55
|
+
"insertMarkdown",
|
|
56
|
+
"linkify",
|
|
57
|
+
"plugin",
|
|
58
|
+
"renderBullets",
|
|
59
|
+
"slugify",
|
|
60
|
+
"strip",
|
|
61
|
+
"titleize",
|
|
62
|
+
"toc",
|
|
63
|
+
"utils"
|
|
64
|
+
],
|
|
65
|
+
"entryPoint": "src/index.ts",
|
|
66
|
+
"inputs": {
|
|
67
|
+
"src/index.ts": {
|
|
68
|
+
"bytesInOutput": 543
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"bytes": 993
|
|
72
|
+
},
|
|
73
|
+
"dist/cli.js.map": {
|
|
74
|
+
"imports": [],
|
|
75
|
+
"exports": [],
|
|
76
|
+
"inputs": {},
|
|
77
|
+
"bytes": 6524
|
|
78
|
+
},
|
|
79
|
+
"dist/cli.js": {
|
|
80
|
+
"imports": [
|
|
81
|
+
{
|
|
82
|
+
"path": "node:fs",
|
|
83
|
+
"kind": "import-statement",
|
|
84
|
+
"external": true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"path": "node:process",
|
|
88
|
+
"kind": "import-statement",
|
|
89
|
+
"external": true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"path": "./index.js",
|
|
93
|
+
"kind": "import-statement",
|
|
94
|
+
"external": true
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"exports": [
|
|
98
|
+
"main"
|
|
99
|
+
],
|
|
100
|
+
"entryPoint": "src/cli.ts",
|
|
101
|
+
"inputs": {
|
|
102
|
+
"src/cli.ts": {
|
|
103
|
+
"bytesInOutput": 3393
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"bytes": 3593
|
|
107
|
+
},
|
|
108
|
+
"dist/markdown-toc.js.map": {
|
|
109
|
+
"imports": [],
|
|
110
|
+
"exports": [],
|
|
111
|
+
"inputs": {},
|
|
112
|
+
"bytes": 14185
|
|
113
|
+
},
|
|
114
|
+
"dist/markdown-toc.js": {
|
|
115
|
+
"imports": [
|
|
116
|
+
{
|
|
117
|
+
"path": "diacritics-map",
|
|
118
|
+
"kind": "import-statement",
|
|
119
|
+
"external": true
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"path": "remarkable",
|
|
123
|
+
"kind": "import-statement",
|
|
124
|
+
"external": true
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"exports": [
|
|
128
|
+
"generatePlugin",
|
|
129
|
+
"generateToc",
|
|
130
|
+
"getHighest",
|
|
131
|
+
"getTitle",
|
|
132
|
+
"linkify",
|
|
133
|
+
"renderBullets",
|
|
134
|
+
"slugify",
|
|
135
|
+
"strip",
|
|
136
|
+
"titleize"
|
|
137
|
+
],
|
|
138
|
+
"entryPoint": "src/markdown-toc.ts",
|
|
139
|
+
"inputs": {
|
|
140
|
+
"src/markdown-toc.ts": {
|
|
141
|
+
"bytesInOutput": 7497
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"bytes": 7797
|
|
145
|
+
},
|
|
146
|
+
"dist/insert-markdown.js.map": {
|
|
147
|
+
"imports": [],
|
|
148
|
+
"exports": [],
|
|
149
|
+
"inputs": {},
|
|
150
|
+
"bytes": 2516
|
|
151
|
+
},
|
|
152
|
+
"dist/insert-markdown.js": {
|
|
153
|
+
"imports": [
|
|
154
|
+
{
|
|
155
|
+
"path": "gray-matter",
|
|
156
|
+
"kind": "import-statement",
|
|
157
|
+
"external": true
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"path": "./markdown-toc.js",
|
|
161
|
+
"kind": "import-statement",
|
|
162
|
+
"external": true
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"exports": [
|
|
166
|
+
"insertMarkdown"
|
|
167
|
+
],
|
|
168
|
+
"entryPoint": "src/insert-markdown.ts",
|
|
169
|
+
"inputs": {
|
|
170
|
+
"src/insert-markdown.ts": {
|
|
171
|
+
"bytesInOutput": 1316
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"bytes": 1518
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAYA,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuC1C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Remarkable from 'remarkable';
|
|
2
|
+
import { generatePlugin, generateToc, getHighest, getTitle, linkify as linkifyHeading, renderBullets, slugify as slugifyHeading, strip as stripHeading, titleize as titleizeHeading } from './markdown-toc.js';
|
|
3
|
+
import { insertMarkdown } from './insert-markdown.js';
|
|
4
|
+
import type { TocOptions, TocResult, TocUtils } from './types.js';
|
|
5
|
+
export type * from './types.js';
|
|
6
|
+
export { Remarkable };
|
|
7
|
+
export { generatePlugin as plugin, generateToc, getHighest, getTitle, insertMarkdown, linkifyHeading as linkify, renderBullets, slugifyHeading as slugify, stripHeading as strip, titleizeHeading as titleize, };
|
|
8
|
+
export { renderBullets as bullets };
|
|
9
|
+
export declare function toc(markdown: string, options?: Readonly<TocOptions>): TocResult;
|
|
10
|
+
export declare const utils: TocUtils;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EACH,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,IAAI,cAAc,EACzB,aAAa,EACb,OAAO,IAAI,cAAc,EACzB,KAAK,IAAI,YAAY,EACrB,QAAQ,IAAI,eAAe,EAC9B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjE,mBAAmB,YAAY,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,OAAO,EACH,cAAc,IAAI,MAAM,EACxB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EACd,cAAc,IAAI,OAAO,EACzB,aAAa,EACb,cAAc,IAAI,OAAO,EACzB,YAAY,IAAI,KAAK,EACrB,eAAe,IAAI,QAAQ,GAC9B,CAAA;AACD,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,CAAA;AAEnC,wBAAgB,GAAG,CACf,QAAQ,EAAC,MAAM,EACf,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,SAAS,CAEV;AAED,eAAO,MAAM,KAAK,EAAC,QAMlB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-markdown.d.ts","sourceRoot":"","sources":["../../src/insert-markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,wBAAgB,cAAc,CAC1B,QAAQ,EAAC,MAAM,EACf,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,MAAM,CAiCP"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RemarkablePlugin, TocOptions, TocResult, TocToken } from './types.js';
|
|
2
|
+
export declare function generateToc(markdown: string, options?: Readonly<TocOptions>): TocResult;
|
|
3
|
+
export declare function generatePlugin(options?: Readonly<TocOptions>): RemarkablePlugin;
|
|
4
|
+
export declare function renderBullets(tokens: ReadonlyArray<TocToken>, options?: Readonly<TocOptions>): string;
|
|
5
|
+
export declare function linkify(token: TocToken | null, options?: Readonly<TocOptions>): TocToken;
|
|
6
|
+
export declare function slugify(text: string, options?: Readonly<TocOptions>): string;
|
|
7
|
+
export declare function titleize(text: string, options?: Readonly<TocOptions>): string;
|
|
8
|
+
export declare function strip(text: string, options?: Readonly<TocOptions>): string;
|
|
9
|
+
export declare function getTitle(text: string): string;
|
|
10
|
+
export declare function getHighest(tokens: ReadonlyArray<TocToken>): number;
|
|
11
|
+
//# sourceMappingURL=markdown-toc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-toc.d.ts","sourceRoot":"","sources":["../../src/markdown-toc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,gBAAgB,EAEhB,UAAU,EACV,SAAS,EACT,QAAQ,EACX,MAAM,YAAY,CAAA;AASnB,wBAAgB,WAAW,CACvB,QAAQ,EAAC,MAAM,EACf,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,SAAS,CAKV;AAED,wBAAgB,cAAc,CAC1B,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,gBAAgB,CAyGjB;AAED,wBAAgB,aAAa,CACzB,MAAM,EAAC,aAAa,CAAC,QAAQ,CAAC,EAC9B,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,MAAM,CA4BP;AAED,wBAAgB,OAAO,CACnB,KAAK,EAAC,QAAQ,GAAC,IAAI,EACnB,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,QAAQ,CAgBT;AAED,wBAAgB,OAAO,CACnB,IAAI,EAAC,MAAM,EACX,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,MAAM,CAqBP;AAED,wBAAgB,QAAQ,CACpB,IAAI,EAAC,MAAM,EACX,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,MAAM,CAWP;AAED,wBAAgB,KAAK,CACjB,IAAI,EAAC,MAAM,EACX,OAAO,GAAC,QAAQ,CAAC,UAAU,CAAM,GACnC,MAAM,CAQP;AAED,wBAAgB,QAAQ,CAAE,IAAI,EAAC,MAAM,GAAE,MAAM,CAM5C;AAED,wBAAgB,UAAU,CAAE,MAAM,EAAC,aAAa,CAAC,QAAQ,CAAC,GAAE,MAAM,CAOjE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type SlugifyFn = (text: string, options: Readonly<TocOptions>) => string;
|
|
2
|
+
export type TitleizeFn = (text: string, options: Readonly<TocOptions>) => string;
|
|
3
|
+
export type StripFn = (text: string, options: Readonly<TocOptions>) => string;
|
|
4
|
+
export type FilterFn = (text: string, token: TocToken, tokens: ReadonlyArray<TocToken>) => boolean;
|
|
5
|
+
export type LinkifyFn = (token: TocToken, text: string, slug: string, options: Readonly<TocOptions>) => TocToken;
|
|
6
|
+
export type TocOptions = {
|
|
7
|
+
readonly append?: string;
|
|
8
|
+
readonly bullets?: string | ReadonlyArray<string>;
|
|
9
|
+
readonly chars?: string | ReadonlyArray<string>;
|
|
10
|
+
readonly close?: string;
|
|
11
|
+
readonly filter?: FilterFn;
|
|
12
|
+
readonly firsth1?: boolean;
|
|
13
|
+
readonly indent?: string;
|
|
14
|
+
readonly linkify?: boolean | LinkifyFn;
|
|
15
|
+
readonly maxdepth?: number;
|
|
16
|
+
readonly num?: number;
|
|
17
|
+
readonly open?: string;
|
|
18
|
+
readonly regex?: RegExp;
|
|
19
|
+
readonly slugify?: false | SlugifyFn;
|
|
20
|
+
readonly strip?: ReadonlyArray<string> | StripFn;
|
|
21
|
+
readonly stripHeadingTags?: boolean;
|
|
22
|
+
readonly titleize?: false | TitleizeFn;
|
|
23
|
+
readonly toc?: string;
|
|
24
|
+
readonly highest?: number;
|
|
25
|
+
};
|
|
26
|
+
export type TocToken = {
|
|
27
|
+
readonly type: string;
|
|
28
|
+
readonly content: string;
|
|
29
|
+
readonly hLevel?: number;
|
|
30
|
+
readonly lines?: ReadonlyArray<number> | null;
|
|
31
|
+
readonly children?: ReadonlyArray<TocToken> | null;
|
|
32
|
+
readonly lvl?: number;
|
|
33
|
+
readonly i?: number;
|
|
34
|
+
readonly seen?: number;
|
|
35
|
+
readonly slug?: string;
|
|
36
|
+
};
|
|
37
|
+
export type TocHeading = {
|
|
38
|
+
readonly content: string;
|
|
39
|
+
readonly slug: string;
|
|
40
|
+
readonly lvl: number;
|
|
41
|
+
readonly i: number;
|
|
42
|
+
readonly seen: number;
|
|
43
|
+
};
|
|
44
|
+
export type TocResult = {
|
|
45
|
+
readonly content: string;
|
|
46
|
+
readonly highest: number;
|
|
47
|
+
readonly json: Array<TocHeading>;
|
|
48
|
+
readonly tokens: Array<TocToken>;
|
|
49
|
+
};
|
|
50
|
+
export type RemarkableRenderer = {
|
|
51
|
+
render: (tokens: Array<TocToken>, options?: unknown, environment?: unknown) => unknown;
|
|
52
|
+
};
|
|
53
|
+
export type RemarkableInstance = {
|
|
54
|
+
renderer: RemarkableRenderer;
|
|
55
|
+
use: (plugin: RemarkablePlugin) => RemarkableInstance;
|
|
56
|
+
render: (markdown: string, environment?: unknown) => unknown;
|
|
57
|
+
};
|
|
58
|
+
export type RemarkablePlugin = (instance: RemarkableInstance) => void;
|
|
59
|
+
export type RemarkableConstructor = new (...options: ReadonlyArray<unknown>) => RemarkableInstance;
|
|
60
|
+
export type TocUtils = {
|
|
61
|
+
readonly Remarkable: RemarkableConstructor;
|
|
62
|
+
readonly getTitle: (text: string) => string;
|
|
63
|
+
readonly slugify: SlugifyFn;
|
|
64
|
+
readonly strip: (text: string, options?: Readonly<TocOptions>) => string;
|
|
65
|
+
readonly titleize: (text: string, options?: Readonly<TocOptions>) => string;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,MAAM,CAAA;AAE7E,MAAM,MAAM,UAAU,GAAG,CACrB,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,QAAQ,CAAC,UAAU,CAAC,KAC3B,MAAM,CAAA;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,MAAM,CAAA;AAE3E,MAAM,MAAM,QAAQ,GAAG,CACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,QAAQ,EACd,MAAM,EAAC,aAAa,CAAC,QAAQ,CAAC,KAC7B,OAAO,CAAA;AAEZ,MAAM,MAAM,SAAS,GAAG,CACpB,KAAK,EAAC,QAAQ,EACd,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,QAAQ,CAAC,UAAU,CAAC,KAC3B,QAAQ,CAAA;AAEb,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAC,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAC,MAAM,GAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM,GAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,KAAK,C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M,QAAQ,GAAG;IACnB,QAAQ,CAAC,UAAU,EAAC,qBAAqB,CAAA;IACzC,QAAQ,CAAC,QAAQ,EAAC,CAAC,IAAI,EAAC,MAAM,KAAK,MAAM,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAC,SAAS,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAC,CACX,IAAI,EAAC,MAAM,EACX,OAAO,CAAC,EAAC,QAAQ,CAAC,UAAU,CAAC,KAC5B,MAAM,CAAA;IACX,QAAQ,CAAC,QAAQ,EAAC,CACd,IAAI,EAAC,MAAM,EACX,OAAO,CAAC,EAAC,QAAQ,CAAC,UAAU,CAAC,KAC5B,MAAM,CAAA;CACd,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,121 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrate-system/markdown-toc",
|
|
3
3
|
"description": "Generate a markdown TOC (table of contents) with Remarkable.",
|
|
4
|
-
"version": "1.3.
|
|
5
|
-
"
|
|
6
|
-
"
|
|
4
|
+
"version": "1.3.7",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"./dist/*"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/index.js",
|
|
13
|
+
"./*": [
|
|
14
|
+
"./dist/*.js",
|
|
15
|
+
"./dist/*"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"markdown-toc": "./dist/cli.js"
|
|
20
|
+
},
|
|
7
21
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
22
|
+
"lint": "eslint \"./**/*.{ts,js}\"",
|
|
23
|
+
"test": "esbuild test/index.ts --platform=node --format=esm --keep-names --bundle --external:gray-matter --external:remarkable --external:diacritics-map | node --input-type=module | tap-spec",
|
|
24
|
+
"build-esm": "esbuild src/index.ts src/cli.ts src/markdown-toc.ts src/insert-markdown.ts --format=esm --metafile=dist/meta.json --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --sourcemap && tsc --emitDeclarationOnly --project tsconfig.build.json --outDir dist",
|
|
25
|
+
"build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-esm",
|
|
26
|
+
"preversion": "npm run lint",
|
|
27
|
+
"version": "auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md README.md",
|
|
28
|
+
"postversion": "git push --follow-tags && npm publish",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
12
30
|
},
|
|
13
31
|
"dependencies": {
|
|
14
|
-
"
|
|
32
|
+
"@types/remarkable": "^2.0.8",
|
|
15
33
|
"diacritics-map": "^0.1.0",
|
|
16
34
|
"gray-matter": "^4.0.3",
|
|
17
|
-
"
|
|
18
|
-
"list-item": "^1.1.1",
|
|
19
|
-
"markdown-link": "^0.1.1",
|
|
20
|
-
"minimist": "^1.2.0",
|
|
21
|
-
"mixin-deep": "^1.1.3",
|
|
22
|
-
"object.pick": "^1.3.0",
|
|
23
|
-
"remarkable": "^1.7.1",
|
|
24
|
-
"repeat-string": "^1.6.1",
|
|
25
|
-
"strip-color": "^0.1.0"
|
|
35
|
+
"remarkable": "^1.7.1"
|
|
26
36
|
},
|
|
27
37
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"Daniel Mietchen (http://about.me/daniel.mietchen)",
|
|
38
|
-
"David Mohl (https://dvcrn.github.io)",
|
|
39
|
-
"Federico Soave (https://github.com/Feder1co5oave)",
|
|
40
|
-
"Gary Green (https://github.com/garygreen)",
|
|
41
|
-
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
|
42
|
-
"Josh Duff (https://tehshrike.github.io)",
|
|
43
|
-
"Matt Ellis (http://sticklebackplastic.com)",
|
|
44
|
-
"Nicolas Morel (https://github.com/Marsup)",
|
|
45
|
-
"nichoth (https://nichoth.com)",
|
|
46
|
-
"Rafael Steil (http://rafaelsteil.com)",
|
|
47
|
-
"Richard Bradley (https://github.com/RichardBradley)",
|
|
48
|
-
"Seth Vincent (https://sethvincent.com)",
|
|
49
|
-
"Stefan Walther (http://qliksite.io)",
|
|
50
|
-
"Tao Wang (https://github.com/twang2218)",
|
|
51
|
-
"(https://github.com/lu22do)",
|
|
52
|
-
"Zeke Sikelianos (http://zeke.sikelianos.com)"
|
|
53
|
-
],
|
|
54
|
-
"repository": "substrate-system/markdown-toc",
|
|
55
|
-
"bugs": {
|
|
56
|
-
"url": "https://github.com/substrate-system/markdown-toc/issues"
|
|
38
|
+
"@substrate-system/tapzero": "^0.10.16",
|
|
39
|
+
"@types/node": "^24.0.3",
|
|
40
|
+
"auto-changelog": "^2.6.1",
|
|
41
|
+
"esbuild": "^0.28.2",
|
|
42
|
+
"eslint": "^10.10.0",
|
|
43
|
+
"newneostandard": "^0.14.3",
|
|
44
|
+
"tap-spec": "^5.0.0",
|
|
45
|
+
"typescript": "^6.0.3",
|
|
46
|
+
"typescript-eslint": "^8.70.0"
|
|
57
47
|
},
|
|
58
48
|
"license": "MIT",
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"index.js",
|
|
62
|
-
"lib"
|
|
63
|
-
],
|
|
64
|
-
"main": "index.js",
|
|
65
|
-
"bin": {
|
|
66
|
-
"markdown-toc": "cli.js"
|
|
67
|
-
},
|
|
49
|
+
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
|
50
|
+
"repository": "substrate-system/markdown-toc",
|
|
68
51
|
"engines": {
|
|
69
|
-
"node": ">=
|
|
70
|
-
}
|
|
71
|
-
"keywords": [
|
|
72
|
-
"anchor",
|
|
73
|
-
"API documentation",
|
|
74
|
-
"code documentation",
|
|
75
|
-
"commonmark",
|
|
76
|
-
"content navigation",
|
|
77
|
-
"content organization",
|
|
78
|
-
"developer tools",
|
|
79
|
-
"docs",
|
|
80
|
-
"document structure",
|
|
81
|
-
"document",
|
|
82
|
-
"documentation tool",
|
|
83
|
-
"documentation",
|
|
84
|
-
"glossary",
|
|
85
|
-
"heading",
|
|
86
|
-
"headings",
|
|
87
|
-
"index",
|
|
88
|
-
"javascript",
|
|
89
|
-
"links",
|
|
90
|
-
"markdown parser",
|
|
91
|
-
"markdown tools",
|
|
92
|
-
"Markdown-based",
|
|
93
|
-
"markdown-toc",
|
|
94
|
-
"markdown",
|
|
95
|
-
"markup language",
|
|
96
|
-
"md files",
|
|
97
|
-
"md parser",
|
|
98
|
-
"md-toc",
|
|
99
|
-
"md",
|
|
100
|
-
"node.js",
|
|
101
|
-
"npm",
|
|
102
|
-
"open-source",
|
|
103
|
-
"outline",
|
|
104
|
-
"package.json",
|
|
105
|
-
"plugin",
|
|
106
|
-
"README tool",
|
|
107
|
-
"readme",
|
|
108
|
-
"reference",
|
|
109
|
-
"remarkable",
|
|
110
|
-
"remarkableplugin",
|
|
111
|
-
"render",
|
|
112
|
-
"renderer",
|
|
113
|
-
"structure",
|
|
114
|
-
"table of contents",
|
|
115
|
-
"table-of-contents",
|
|
116
|
-
"table",
|
|
117
|
-
"toc-generator",
|
|
118
|
-
"toc",
|
|
119
|
-
"write"
|
|
120
|
-
]
|
|
52
|
+
"node": ">=18"
|
|
53
|
+
}
|
|
121
54
|
}
|
package/cli.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var toc = require('./index.js');
|
|
5
|
-
var utils = require('./lib/utils');
|
|
6
|
-
var args = utils.minimist(process.argv.slice(2), {
|
|
7
|
-
boolean: ['i', 'json', 'firsth1', 'stripHeadingTags'],
|
|
8
|
-
string: ['append', 'bullets', 'indent'],
|
|
9
|
-
default: {
|
|
10
|
-
firsth1: true,
|
|
11
|
-
stripHeadingTags: true
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
if (args._.length !== 1) {
|
|
16
|
-
console.error([
|
|
17
|
-
'Usage: markdown-toc [options] <input> ',
|
|
18
|
-
'',
|
|
19
|
-
' input: The Markdown file to parse for table of contents,',
|
|
20
|
-
' or "-" to read from stdin.',
|
|
21
|
-
'',
|
|
22
|
-
' -i: Edit the <input> file directly, injecting the TOC at <!-- toc -->',
|
|
23
|
-
' (Without this flag, the default is to print the TOC to stdout.)',
|
|
24
|
-
'',
|
|
25
|
-
' --json: Print the TOC in JSON format',
|
|
26
|
-
'',
|
|
27
|
-
' --append: Append a string to the end of the TOC',
|
|
28
|
-
'',
|
|
29
|
-
' --bullets: Bullets to use for items in the generated TOC',
|
|
30
|
-
' (Supports multiple bullets: --bullets "*" --bullets "-" --bullets "+")',
|
|
31
|
-
' (Default is "*".)',
|
|
32
|
-
'',
|
|
33
|
-
' --maxdepth: Use headings whose depth is at most maxdepth',
|
|
34
|
-
' (Default is 6.)',
|
|
35
|
-
'',
|
|
36
|
-
' --no-firsth1: Include the first h1-level heading in a file',
|
|
37
|
-
'',
|
|
38
|
-
' --no-stripHeadingTags: Do not strip extraneous HTML tags from heading',
|
|
39
|
-
' text before slugifying',
|
|
40
|
-
'',
|
|
41
|
-
' --indent: Provide the indentation to use - defaults to \' \'',
|
|
42
|
-
' (to specify a tab, use the bash-escaped $\'\\t\')'
|
|
43
|
-
].join('\n'));
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (args.i && args.json) {
|
|
48
|
-
console.error('markdown-toc: you cannot use both --json and -i');
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (args.i && args._[0] === '-') {
|
|
53
|
-
console.error('markdown-toc: you cannot use -i with "-" (stdin) for input');
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var input = process.stdin;
|
|
58
|
-
if (args._[0] !== '-') input = fs.createReadStream(args._[0]);
|
|
59
|
-
|
|
60
|
-
input.pipe(utils.concat(function(input) {
|
|
61
|
-
if (args.i) {
|
|
62
|
-
var newMarkdown = toc.insert(input.toString(), args);
|
|
63
|
-
fs.writeFileSync(args._[0], newMarkdown);
|
|
64
|
-
} else {
|
|
65
|
-
var parsed = toc(input.toString(), args);
|
|
66
|
-
output(parsed);
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
input.on('error', function onErr(err) {
|
|
71
|
-
console.error(err);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
function output(parsed) {
|
|
76
|
-
if (args.json) return console.log(JSON.stringify(parsed.json, null, ' '));
|
|
77
|
-
process.stdout.write(parsed.content);
|
|
78
|
-
}
|