@vuepress/markdown 2.0.0-beta.8 → 2.0.0-rc.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 (72) hide show
  1. package/dist/index.d.ts +184 -0
  2. package/dist/index.js +577 -0
  3. package/package.json +48 -17
  4. package/CHANGELOG.md +0 -231
  5. package/lib/index.d.ts +0 -4
  6. package/lib/index.js +0 -16
  7. package/lib/markdown.d.ts +0 -5
  8. package/lib/markdown.js +0 -77
  9. package/lib/plugins/anchorPlugin.d.ts +0 -62
  10. package/lib/plugins/anchorPlugin.js +0 -5
  11. package/lib/plugins/assetsPlugin.d.ts +0 -11
  12. package/lib/plugins/assetsPlugin.js +0 -24
  13. package/lib/plugins/codePlugin/codePlugin.d.ts +0 -28
  14. package/lib/plugins/codePlugin/codePlugin.js +0 -73
  15. package/lib/plugins/codePlugin/index.d.ts +0 -6
  16. package/lib/plugins/codePlugin/index.js +0 -18
  17. package/lib/plugins/codePlugin/languages.d.ts +0 -38
  18. package/lib/plugins/codePlugin/languages.js +0 -68
  19. package/lib/plugins/codePlugin/resolveHighlightLines.d.ts +0 -9
  20. package/lib/plugins/codePlugin/resolveHighlightLines.js +0 -28
  21. package/lib/plugins/codePlugin/resolveLanguage.d.ts +0 -5
  22. package/lib/plugins/codePlugin/resolveLanguage.js +0 -41
  23. package/lib/plugins/codePlugin/resolveLineNumbers.d.ts +0 -4
  24. package/lib/plugins/codePlugin/resolveLineNumbers.js +0 -16
  25. package/lib/plugins/codePlugin/resolveVPre.d.ts +0 -4
  26. package/lib/plugins/codePlugin/resolveVPre.js +0 -16
  27. package/lib/plugins/customComponentPlugin/customComponentPlugin.d.ts +0 -6
  28. package/lib/plugins/customComponentPlugin/customComponentPlugin.js +0 -18
  29. package/lib/plugins/customComponentPlugin/htmlBlockRule.d.ts +0 -2
  30. package/lib/plugins/customComponentPlugin/htmlBlockRule.js +0 -90
  31. package/lib/plugins/customComponentPlugin/htmlInlineRule.d.ts +0 -2
  32. package/lib/plugins/customComponentPlugin/htmlInlineRule.js +0 -40
  33. package/lib/plugins/customComponentPlugin/htmlRe.d.ts +0 -2
  34. package/lib/plugins/customComponentPlugin/htmlRe.js +0 -33
  35. package/lib/plugins/customComponentPlugin/index.d.ts +0 -4
  36. package/lib/plugins/customComponentPlugin/index.js +0 -16
  37. package/lib/plugins/customComponentPlugin/inlineTags.d.ts +0 -18
  38. package/lib/plugins/customComponentPlugin/inlineTags.js +0 -78
  39. package/lib/plugins/customComponentPlugin/vueReservedTags.d.ts +0 -6
  40. package/lib/plugins/customComponentPlugin/vueReservedTags.js +0 -17
  41. package/lib/plugins/emojiPlugin.d.ts +0 -25
  42. package/lib/plugins/emojiPlugin.js +0 -5
  43. package/lib/plugins/extractHeadersPlugin.d.ts +0 -27
  44. package/lib/plugins/extractHeadersPlugin.js +0 -31
  45. package/lib/plugins/hoistTagsPlugin.d.ts +0 -12
  46. package/lib/plugins/hoistTagsPlugin.js +0 -26
  47. package/lib/plugins/index.d.ts +0 -9
  48. package/lib/plugins/index.js +0 -21
  49. package/lib/plugins/linksPlugin/index.d.ts +0 -2
  50. package/lib/plugins/linksPlugin/index.js +0 -14
  51. package/lib/plugins/linksPlugin/linksPlugin.d.ts +0 -12
  52. package/lib/plugins/linksPlugin/linksPlugin.js +0 -108
  53. package/lib/plugins/linksPlugin/resolvePaths.d.ts +0 -7
  54. package/lib/plugins/linksPlugin/resolvePaths.js +0 -38
  55. package/lib/plugins/tocPlugin/createRenderHeaders.d.ts +0 -5
  56. package/lib/plugins/tocPlugin/createRenderHeaders.js +0 -28
  57. package/lib/plugins/tocPlugin/createTocBlockRule.d.ts +0 -11
  58. package/lib/plugins/tocPlugin/createTocBlockRule.js +0 -50
  59. package/lib/plugins/tocPlugin/index.d.ts +0 -3
  60. package/lib/plugins/tocPlugin/index.js +0 -15
  61. package/lib/plugins/tocPlugin/tocPlugin.d.ts +0 -65
  62. package/lib/plugins/tocPlugin/tocPlugin.js +0 -54
  63. package/lib/types.d.ts +0 -58
  64. package/lib/types.js +0 -2
  65. package/lib/utils/index.d.ts +0 -3
  66. package/lib/utils/index.js +0 -15
  67. package/lib/utils/parseEmoji.d.ts +0 -1
  68. package/lib/utils/parseEmoji.js +0 -6
  69. package/lib/utils/resolveHeadersFromTokens.d.ts +0 -11
  70. package/lib/utils/resolveHeadersFromTokens.js +0 -81
  71. package/lib/utils/slugify.d.ts +0 -1
  72. package/lib/utils/slugify.js +0 -24
package/CHANGELOG.md DELETED
@@ -1,231 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [2.0.0-beta.8](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2021-04-11)
7
-
8
-
9
- ### Features
10
-
11
- * **markdown:** support internalTag option in links plugin ([1872ad9](https://github.com/vuepress/vuepress-next/commit/1872ad95d7c86247883c24f2ec86db07d7596923))
12
-
13
-
14
-
15
-
16
-
17
- # [2.0.0-beta.7](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2021-04-09)
18
-
19
- **Note:** Version bump only for package @vuepress/markdown
20
-
21
-
22
-
23
-
24
-
25
- # [2.0.0-beta.5](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2021-03-26)
26
-
27
-
28
- ### Bug Fixes
29
-
30
- * **markdown:** avoid wrapping highlighted code with multiple pre ([f0b3872](https://github.com/vuepress/vuepress-next/commit/f0b38722f1a06c736366a36d7c4888952d28c947))
31
-
32
-
33
-
34
-
35
-
36
- # [2.0.0-beta.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2021-03-20)
37
-
38
-
39
- ### Code Refactoring
40
-
41
- * **markdown:** remove default syntax highlighter ([4a1abe3](https://github.com/vuepress/vuepress-next/commit/4a1abe39335eaaf3ef1dca3e35a324b12981c0d2))
42
-
43
-
44
- ### BREAKING CHANGES
45
-
46
- * **markdown:** prismjs is no longer the default syntax highlighter
47
-
48
-
49
-
50
-
51
-
52
- # [2.0.0-beta.1](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2021-03-13)
53
-
54
- **Note:** Version bump only for package @vuepress/markdown
55
-
56
-
57
-
58
-
59
-
60
- # [2.0.0-beta.0](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.26...v2.0.0-beta.0) (2021-03-13)
61
-
62
- **Note:** Version bump only for package @vuepress/markdown
63
-
64
-
65
-
66
-
67
-
68
- # [2.0.0-alpha.25](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.24...v2.0.0-alpha.25) (2021-02-20)
69
-
70
-
71
- ### Bug Fixes
72
-
73
- * **markdown:** do not treat autolink as a component (close [#60](https://github.com/vuepress/vuepress-next/issues/60)) ([9f6cffa](https://github.com/vuepress/vuepress-next/commit/9f6cffa1e0c39d0caf9f7ab34c5f06f36a87948b))
74
-
75
-
76
-
77
-
78
-
79
- # [2.0.0-alpha.24](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.23...v2.0.0-alpha.24) (2021-02-13)
80
-
81
- **Note:** Version bump only for package @vuepress/markdown
82
-
83
-
84
-
85
-
86
-
87
- # [2.0.0-alpha.23](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.22...v2.0.0-alpha.23) (2021-02-10)
88
-
89
-
90
- ### Bug Fixes
91
-
92
- * **markdown:** remove site base from internal links (close [#58](https://github.com/vuepress/vuepress-next/issues/58)) ([a8c7fdd](https://github.com/vuepress/vuepress-next/commit/a8c7fdd86a9c4f08c51673f3dba0451455a731d2))
93
-
94
-
95
-
96
-
97
-
98
- # [2.0.0-alpha.22](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.21...v2.0.0-alpha.22) (2021-02-10)
99
-
100
- **Note:** Version bump only for package @vuepress/markdown
101
-
102
-
103
-
104
-
105
-
106
- # [2.0.0-alpha.20](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.19...v2.0.0-alpha.20) (2021-02-04)
107
-
108
- **Note:** Version bump only for package @vuepress/markdown
109
-
110
-
111
-
112
-
113
-
114
- # [2.0.0-alpha.19](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.18...v2.0.0-alpha.19) (2021-01-24)
115
-
116
- **Note:** Version bump only for package @vuepress/markdown
117
-
118
-
119
-
120
-
121
-
122
- # [2.0.0-alpha.18](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2021-01-17)
123
-
124
-
125
- ### Bug Fixes
126
-
127
- * **markdown:** load some languages by default to partially avoid prism issue ([48c085a](https://github.com/vuepress/vuepress-next/commit/48c085af6a8751211fe7180a82bb67ff5a7b191f))
128
-
129
-
130
-
131
-
132
-
133
- # [2.0.0-alpha.16](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.15...v2.0.0-alpha.16) (2021-01-11)
134
-
135
-
136
- ### Bug Fixes
137
-
138
- * **core:** support special characters in filename and permalink ([c3e68ef](https://github.com/vuepress/vuepress-next/commit/c3e68ef6a4aa3f6722d5bc4079bafe5d3b176e5e))
139
- * **markdown:** fix assets relative path handling (close [#33](https://github.com/vuepress/vuepress-next/issues/33)) ([9a95431](https://github.com/vuepress/vuepress-next/commit/9a95431aa3994855f7194d3efe810b4fd2cf72d9))
140
-
141
-
142
-
143
-
144
-
145
- # [2.0.0-alpha.15](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.14...v2.0.0-alpha.15) (2021-01-04)
146
-
147
- **Note:** Version bump only for package @vuepress/markdown
148
-
149
-
150
-
151
-
152
-
153
- # [2.0.0-alpha.13](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.12...v2.0.0-alpha.13) (2020-12-23)
154
-
155
-
156
- ### Bug Fixes
157
-
158
- * **markdown:** only prepend prefix to explicit relative image path ([8d6a095](https://github.com/vuepress/vuepress-next/commit/8d6a095ace0ed724b4ac4eea0e44a28f120a48bc))
159
-
160
-
161
-
162
-
163
-
164
- # [2.0.0-alpha.12](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.11...v2.0.0-alpha.12) (2020-12-19)
165
-
166
-
167
- ### Bug Fixes
168
-
169
- * **markdown:** support v-on shorthand in html inline tags ([86a1299](https://github.com/vuepress/vuepress-next/commit/86a1299d16555fb453f36aa1db49ff9ce184e874))
170
-
171
-
172
- ### Features
173
-
174
- * **markdown:** code-block-level config for line-numbers and v-pre ([9ac3e4a](https://github.com/vuepress/vuepress-next/commit/9ac3e4a12066f8b05e5d3a5211adf837a944c29d))
175
-
176
-
177
-
178
-
179
-
180
- # [2.0.0-alpha.7](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2020-12-09)
181
-
182
- **Note:** Version bump only for package @vuepress/markdown
183
-
184
-
185
-
186
-
187
-
188
- # [2.0.0-alpha.6](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2020-12-09)
189
-
190
- **Note:** Version bump only for package @vuepress/markdown
191
-
192
-
193
-
194
-
195
-
196
- # [2.0.0-alpha.5](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.4...v2.0.0-alpha.5) (2020-12-03)
197
-
198
-
199
- ### Features
200
-
201
- * **markdown:** support doc lang highlight ([dc91db6](https://github.com/vuepress/vuepress-next/commit/dc91db6327fd818f365abbec96cc5dde0b6ba243))
202
-
203
-
204
-
205
-
206
-
207
- # [2.0.0-alpha.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2020-12-02)
208
-
209
- **Note:** Version bump only for package @vuepress/markdown
210
-
211
-
212
-
213
-
214
-
215
- # 2.0.0-alpha.1 (2020-12-01)
216
-
217
-
218
- ### Bug Fixes
219
-
220
- * **markdown:** do not add prefix to external images ([dc75f57](https://github.com/vuepress/vuepress-next/commit/dc75f57cfda3193d617c4feaf091748df8482504))
221
- * **markdown:** escape text token ([f226d54](https://github.com/vuepress/vuepress-next/commit/f226d544a9a2045b3dd0f2ea0a7186c7fd2d4adc))
222
-
223
-
224
- ### Features
225
-
226
- * **markdown:** add assetsPlugin to handle assets links ([79e50b5](https://github.com/vuepress/vuepress-next/commit/79e50b5bfa4e39ca4df76d1d580c424c70b09a42))
227
- * **markdown:** add code plugin ([0e29d69](https://github.com/vuepress/vuepress-next/commit/0e29d6995f2f631b0dd73225f7ddd604de857416))
228
- * **markdown:** allow disable built-in plugins ([a0746e5](https://github.com/vuepress/vuepress-next/commit/a0746e518aca472bc08e0ee738c72aa50a2142bf))
229
- * **markdown:** enable line numbers by default ([44b1e47](https://github.com/vuepress/vuepress-next/commit/44b1e4707c217d6155ff72d6c1ec14c72d0e004a))
230
- * **markdown:** migrate to markdown-it-toc-done-right ([5f9f092](https://github.com/vuepress/vuepress-next/commit/5f9f0928d4a99882084ebbfc6b806e86bd98dc43))
231
- * **markdown:** support highlight-lines in code plugin ([932b737](https://github.com/vuepress/vuepress-next/commit/932b7375ac7e5aef9b05bdf330a754c4f82fc0f6))
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './markdown';
2
- export * from './plugins';
3
- export * from './types';
4
- export * from './utils';
package/lib/index.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./markdown"), exports);
14
- __exportStar(require("./plugins"), exports);
15
- __exportStar(require("./types"), exports);
16
- __exportStar(require("./utils"), exports);
package/lib/markdown.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Markdown, MarkdownOptions } from './types';
2
- /**
3
- * Create vuepress customized markdown-it instance
4
- */
5
- export declare const createMarkdown: ({ anchor, assets, code, customComponent, emoji, extractHeaders, hoistTags, links, toc, ...markdownItOptions }?: MarkdownOptions) => Markdown;
package/lib/markdown.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMarkdown = void 0;
4
- const MarkdownIt = require("markdown-it");
5
- const plugins_1 = require("./plugins");
6
- const utils_1 = require("./utils");
7
- /**
8
- * Create vuepress customized markdown-it instance
9
- */
10
- const createMarkdown = ({ anchor, assets, code, customComponent, emoji, extractHeaders, hoistTags, links, toc, ...markdownItOptions } = {}) => {
11
- // create raw markdown-it instance
12
- const md = MarkdownIt({
13
- ...markdownItOptions,
14
- // should always enable html option
15
- html: true,
16
- });
17
- // =====================================================
18
- // following plugins push rules to the end of chain, so
19
- // the order to use them is important
20
- // parse emoji (before anchor and toc plugin)
21
- if (emoji !== false) {
22
- md.use(plugins_1.emojiPlugin, emoji);
23
- }
24
- // add anchor to headers
25
- if (anchor !== false) {
26
- md.use(plugins_1.anchorPlugin, {
27
- level: [1, 2, 3, 4, 5, 6],
28
- slugify: utils_1.slugify,
29
- permalink: true,
30
- permalinkBefore: true,
31
- permalinkSymbol: '#',
32
- ...anchor,
33
- });
34
- }
35
- // allow toc syntax (after anchor plugin)
36
- if (toc !== false) {
37
- md.use(plugins_1.tocPlugin, {
38
- level: [2, 3],
39
- slugify: utils_1.slugify,
40
- linkTag: 'RouterLink',
41
- ...toc,
42
- });
43
- }
44
- // extract headers into env (after anchor plugin)
45
- if (extractHeaders !== false) {
46
- md.use(plugins_1.extractHeadersPlugin, {
47
- level: [2, 3],
48
- slugify: utils_1.slugify,
49
- ...extractHeaders,
50
- });
51
- }
52
- // =====================================================
53
- // following plugins modify or replace the rule in place
54
- // and have no conflicts, so the order is not important
55
- // treat unknown html tags as custom components
56
- if (customComponent !== false) {
57
- md.use(plugins_1.customComponentPlugin);
58
- }
59
- // replace relative link of assets with absolute link
60
- if (assets !== false) {
61
- md.use(plugins_1.assetsPlugin, assets);
62
- }
63
- // hoist vue SFC blocks and extract them into env
64
- if (hoistTags !== false) {
65
- md.use(plugins_1.hoistTagsPlugin, hoistTags);
66
- }
67
- // process external and internal links
68
- if (links !== false) {
69
- md.use(plugins_1.linksPlugin, links);
70
- }
71
- // process code fence
72
- if (code !== false) {
73
- md.use(plugins_1.codePlugin, code);
74
- }
75
- return md;
76
- };
77
- exports.createMarkdown = createMarkdown;
@@ -1,62 +0,0 @@
1
- import type { PluginWithOptions } from 'markdown-it';
2
- import State = require('markdown-it/lib/rules_core/state_core');
3
- import Token = require('markdown-it/lib/token');
4
- /**
5
- * Options for markdown-it-anchor
6
- *
7
- * @see https://github.com/valeriangalliat/markdown-it-anchor
8
- */
9
- export interface AnchorPluginOptions {
10
- /**
11
- * Minimum level to apply anchors on or array of selected levels
12
- *
13
- * @default 1
14
- */
15
- level?: number | number[];
16
- /**
17
- * A custom slugification function
18
- */
19
- slugify?: (str: string) => string;
20
- /**
21
- * Whether to add permalinks next to titles
22
- *
23
- * @default false
24
- */
25
- permalink?: boolean;
26
- /**
27
- * A custom permalink rendering function
28
- */
29
- renderPermalink?: (slug: string, opts: AnchorPluginOptions, state: State, tokenIndex: number) => void;
30
- /**
31
- * The class of the permalink anchor
32
- */
33
- permalinkClass?: string;
34
- /**
35
- * Place space between the header text and the permalink anchor
36
- */
37
- permalinkSpace?: boolean;
38
- /**
39
- * The symbol in the permalink anchor
40
- */
41
- permalinkSymbol?: string;
42
- /**
43
- * Place the permalink before the title
44
- */
45
- permalinkBefore?: boolean;
46
- /**
47
- * A custom permalink `href` rendering function
48
- */
49
- permalinkHref?: (slug: string, state: State) => string;
50
- /**
51
- * A custom permalink attributes rendering function
52
- */
53
- permalinkAttrs?: (slug: string, state: State) => Record<string, string>;
54
- /**
55
- * Called with token and info after rendering
56
- */
57
- callback?: (token: Token, opts: {
58
- slug: string;
59
- title: string;
60
- }) => void;
61
- }
62
- export declare const anchorPlugin: PluginWithOptions<AnchorPluginOptions>;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.anchorPlugin = void 0;
4
- const rawAnchorPlugin = require("markdown-it-anchor");
5
- exports.anchorPlugin = rawAnchorPlugin;
@@ -1,11 +0,0 @@
1
- import type { PluginWithOptions } from 'markdown-it';
2
- export interface AssetsPluginOptions {
3
- /**
4
- * Prefix to add to relative assets links
5
- */
6
- relativePathPrefix?: string;
7
- }
8
- /**
9
- * Plugin to handle assets links
10
- */
11
- export declare const assetsPlugin: PluginWithOptions<AssetsPluginOptions>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assetsPlugin = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Plugin to handle assets links
7
- */
8
- const assetsPlugin = (md, { relativePathPrefix = '@source' } = {}) => {
9
- const rawRule = md.renderer.rules.image;
10
- md.renderer.rules.image = (tokens, idx, options, env, self) => {
11
- const token = tokens[idx];
12
- // get the image link
13
- const link = token.attrGet('src');
14
- // if the link is relative path, and the `env.filePathRelative` exists
15
- if (link && /^\.{1,2}\//.test(link) && env.filePathRelative) {
16
- // add `@source` alias to the link
17
- const resolvedLink = `${relativePathPrefix}/${utils_1.path.join(utils_1.path.dirname(env.filePathRelative), link)}`;
18
- // replace the original link with absolute path
19
- token.attrSet('src', resolvedLink);
20
- }
21
- return rawRule(tokens, idx, options, env, self);
22
- };
23
- };
24
- exports.assetsPlugin = assetsPlugin;
@@ -1,28 +0,0 @@
1
- import type { PluginWithOptions } from 'markdown-it';
2
- export interface CodePluginOptions {
3
- /**
4
- * Enable highlight lines or not
5
- */
6
- highlightLines?: boolean;
7
- /**
8
- * Enable line numbers or not
9
- */
10
- lineNumbers?: boolean;
11
- /**
12
- * Wrap the `<pre>` tag with an extra `<div>` or not. Do not disable it unless you
13
- * understand what's it for
14
- *
15
- * - Required for `highlightLines`
16
- * - Required for `lineNumbers`
17
- * - Required for language display of default theme
18
- */
19
- preWrapper?: boolean;
20
- /**
21
- * Add `v-pre` directive to `<pre>` tag or not
22
- */
23
- vPre?: boolean;
24
- }
25
- /**
26
- * Code plugin
27
- */
28
- export declare const codePlugin: PluginWithOptions<CodePluginOptions>;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.codePlugin = void 0;
4
- const resolveHighlightLines_1 = require("./resolveHighlightLines");
5
- const resolveLanguage_1 = require("./resolveLanguage");
6
- const resolveLineNumbers_1 = require("./resolveLineNumbers");
7
- const resolveVPre_1 = require("./resolveVPre");
8
- /**
9
- * Code plugin
10
- */
11
- const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper = true, vPre = true, } = {}) => {
12
- // override default fence renderer
13
- md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
14
- var _a, _b, _c;
15
- const token = tokens[idx];
16
- // get token info
17
- const info = token.info ? md.utils.unescapeAll(token.info).trim() : '';
18
- // resolve highlight line ranges from token info
19
- let highlightLinesRanges = null;
20
- if (highlightLines) {
21
- highlightLinesRanges = resolveHighlightLines_1.resolveHighlightLines(info);
22
- }
23
- // resolve line-numbers mark from token info
24
- const useLineNumbers = (_a = resolveLineNumbers_1.resolveLineNumbers(info)) !== null && _a !== void 0 ? _a : lineNumbers;
25
- // resolve v-pre mark from token info
26
- const useVPre = (_b = resolveVPre_1.resolveVPre(info)) !== null && _b !== void 0 ? _b : vPre;
27
- // resolve language from token info
28
- const language = resolveLanguage_1.resolveLanguage(info);
29
- // the result of code and lang
30
- let code = token.content;
31
- // try to highlight code
32
- code =
33
- ((_c = options.highlight) === null || _c === void 0 ? void 0 : _c.call(options, code, language.name, '')) || md.utils.escapeHtml(code);
34
- const languageClass = `${options.langPrefix}${language.name}`;
35
- // wrap highlighted code with `<pre>` and `<code>`
36
- let result = code.startsWith('<pre')
37
- ? code
38
- : `<pre class="${languageClass}"><code>${code}</code></pre>`;
39
- if (useVPre) {
40
- result = `<pre v-pre${result.slice('<pre'.length)}`;
41
- }
42
- // if `preWrapper` is disabled, return directly
43
- if (!preWrapper) {
44
- return result;
45
- }
46
- // code fences always have an ending `\n`, so we should trim the last line
47
- const lines = code.split('\n').slice(0, -1);
48
- // generate highlight lines
49
- if (highlightLinesRanges) {
50
- const ranges = highlightLinesRanges;
51
- const highlightLinesCode = lines
52
- .map((_, index) => {
53
- if (resolveHighlightLines_1.isHighlightLine(index + 1, ranges)) {
54
- return '<div class="highlight-line">&nbsp;</div>';
55
- }
56
- return '<br>';
57
- })
58
- .join('');
59
- result = `${result}<div class="highlight-lines">${highlightLinesCode}</div>`;
60
- }
61
- // generate line numbers
62
- if (useLineNumbers) {
63
- // generate line numbers code
64
- const lineNumbersCode = lines
65
- .map((_, index) => `<span class="line-number">${index + 1}</span><br>`)
66
- .join('');
67
- result = `${result}<div class="line-numbers">${lineNumbersCode}</div>`;
68
- }
69
- result = `<div class="${languageClass} ext-${language.ext}${useLineNumbers ? ' line-numbers-mode' : ''}">${result}</div>`;
70
- return result;
71
- };
72
- };
73
- exports.codePlugin = codePlugin;
@@ -1,6 +0,0 @@
1
- export * from './codePlugin';
2
- export * from './languages';
3
- export * from './resolveHighlightLines';
4
- export * from './resolveLanguage';
5
- export * from './resolveLineNumbers';
6
- export * from './resolveVPre';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./codePlugin"), exports);
14
- __exportStar(require("./languages"), exports);
15
- __exportStar(require("./resolveHighlightLines"), exports);
16
- __exportStar(require("./resolveLanguage"), exports);
17
- __exportStar(require("./resolveLineNumbers"), exports);
18
- __exportStar(require("./resolveVPre"), exports);
@@ -1,38 +0,0 @@
1
- /**
2
- * Language type for syntax highlight
3
- */
4
- export interface HighlightLanguage {
5
- /**
6
- * Name of the language
7
- *
8
- * The name to be used for the class name,
9
- * e.g. `class="language-typescript"`
10
- */
11
- name: string;
12
- /**
13
- * Extension of the language
14
- *
15
- * The file extension, which will be used for the
16
- * class name, e.g. `class="ext-ts"`
17
- */
18
- ext: string;
19
- /**
20
- * Aliases that point to this language
21
- *
22
- * Do not conflict with other languages
23
- */
24
- aliases: string[];
25
- }
26
- export declare const languageBash: HighlightLanguage;
27
- export declare const languageCsharp: HighlightLanguage;
28
- export declare const languageDocker: HighlightLanguage;
29
- export declare const languageFsharp: HighlightLanguage;
30
- export declare const languageJavascript: HighlightLanguage;
31
- export declare const languageKotlin: HighlightLanguage;
32
- export declare const languageMarkdown: HighlightLanguage;
33
- export declare const languagePython: HighlightLanguage;
34
- export declare const languageRuby: HighlightLanguage;
35
- export declare const languageRust: HighlightLanguage;
36
- export declare const languageStylus: HighlightLanguage;
37
- export declare const languageTypescript: HighlightLanguage;
38
- export declare const languageYaml: HighlightLanguage;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.languageYaml = exports.languageTypescript = exports.languageStylus = exports.languageRust = exports.languageRuby = exports.languagePython = exports.languageMarkdown = exports.languageKotlin = exports.languageJavascript = exports.languageFsharp = exports.languageDocker = exports.languageCsharp = exports.languageBash = void 0;
4
- exports.languageBash = {
5
- name: 'bash',
6
- ext: 'sh',
7
- aliases: ['bash', 'sh', 'shell', 'zsh'],
8
- };
9
- exports.languageCsharp = {
10
- name: 'csharp',
11
- ext: 'cs',
12
- aliases: ['cs', 'csharp'],
13
- };
14
- exports.languageDocker = {
15
- name: 'docker',
16
- ext: 'docker',
17
- aliases: ['docker', 'dockerfile'],
18
- };
19
- exports.languageFsharp = {
20
- name: 'fsharp',
21
- ext: 'fs',
22
- aliases: ['fs', 'fsharp'],
23
- };
24
- exports.languageJavascript = {
25
- name: 'javascript',
26
- ext: 'js',
27
- aliases: ['javascript', 'js'],
28
- };
29
- exports.languageKotlin = {
30
- name: 'kotlin',
31
- ext: 'kt',
32
- aliases: ['kotlin', 'kt'],
33
- };
34
- exports.languageMarkdown = {
35
- name: 'markdown',
36
- ext: 'md',
37
- aliases: ['markdown', 'md'],
38
- };
39
- exports.languagePython = {
40
- name: 'python',
41
- ext: 'py',
42
- aliases: ['py', 'python'],
43
- };
44
- exports.languageRuby = {
45
- name: 'ruby',
46
- ext: 'rb',
47
- aliases: ['rb', 'ruby'],
48
- };
49
- exports.languageRust = {
50
- name: 'rust',
51
- ext: 'rs',
52
- aliases: ['rs', 'rust'],
53
- };
54
- exports.languageStylus = {
55
- name: 'stylus',
56
- ext: 'styl',
57
- aliases: ['styl', 'stylus'],
58
- };
59
- exports.languageTypescript = {
60
- name: 'typescript',
61
- ext: 'ts',
62
- aliases: ['ts', 'typescript'],
63
- };
64
- exports.languageYaml = {
65
- name: 'yaml',
66
- ext: 'yml',
67
- aliases: ['yaml', 'yml'],
68
- };