@vuepress/markdown 2.0.0-beta.49 → 2.0.0-beta.50-pre.1

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 (51) hide show
  1. package/dist/index.d.ts +272 -0
  2. package/dist/index.js +583 -0
  3. package/package.json +38 -16
  4. package/lib/index.d.ts +0 -3
  5. package/lib/index.js +0 -19
  6. package/lib/markdown.d.ts +0 -5
  7. package/lib/markdown.js +0 -99
  8. package/lib/plugins/anchorPlugin.d.ts +0 -3
  9. package/lib/plugins/anchorPlugin.js +0 -5
  10. package/lib/plugins/assetsPlugin/assetsPlugin.d.ts +0 -11
  11. package/lib/plugins/assetsPlugin/assetsPlugin.js +0 -41
  12. package/lib/plugins/assetsPlugin/index.d.ts +0 -2
  13. package/lib/plugins/assetsPlugin/index.js +0 -18
  14. package/lib/plugins/assetsPlugin/resolveLink.d.ts +0 -2
  15. package/lib/plugins/assetsPlugin/resolveLink.js +0 -16
  16. package/lib/plugins/codePlugin/codePlugin.d.ts +0 -40
  17. package/lib/plugins/codePlugin/codePlugin.js +0 -78
  18. package/lib/plugins/codePlugin/index.d.ts +0 -6
  19. package/lib/plugins/codePlugin/index.js +0 -22
  20. package/lib/plugins/codePlugin/languages.d.ts +0 -38
  21. package/lib/plugins/codePlugin/languages.js +0 -68
  22. package/lib/plugins/codePlugin/resolveHighlightLines.d.ts +0 -9
  23. package/lib/plugins/codePlugin/resolveHighlightLines.js +0 -28
  24. package/lib/plugins/codePlugin/resolveLanguage.d.ts +0 -5
  25. package/lib/plugins/codePlugin/resolveLanguage.js +0 -40
  26. package/lib/plugins/codePlugin/resolveLineNumbers.d.ts +0 -4
  27. package/lib/plugins/codePlugin/resolveLineNumbers.js +0 -16
  28. package/lib/plugins/codePlugin/resolveVPre.d.ts +0 -4
  29. package/lib/plugins/codePlugin/resolveVPre.js +0 -16
  30. package/lib/plugins/emojiPlugin.d.ts +0 -3
  31. package/lib/plugins/emojiPlugin.js +0 -5
  32. package/lib/plugins/importCodePlugin/createImportCodeBlockRule.d.ts +0 -3
  33. package/lib/plugins/importCodePlugin/createImportCodeBlockRule.js +0 -52
  34. package/lib/plugins/importCodePlugin/importCodePlugin.d.ts +0 -8
  35. package/lib/plugins/importCodePlugin/importCodePlugin.js +0 -26
  36. package/lib/plugins/importCodePlugin/index.d.ts +0 -4
  37. package/lib/plugins/importCodePlugin/index.js +0 -20
  38. package/lib/plugins/importCodePlugin/resolveImportCode.d.ts +0 -6
  39. package/lib/plugins/importCodePlugin/resolveImportCode.js +0 -37
  40. package/lib/plugins/importCodePlugin/types.d.ts +0 -5
  41. package/lib/plugins/importCodePlugin/types.js +0 -2
  42. package/lib/plugins/index.d.ts +0 -12
  43. package/lib/plugins/index.js +0 -28
  44. package/lib/plugins/linksPlugin/index.d.ts +0 -2
  45. package/lib/plugins/linksPlugin/index.js +0 -18
  46. package/lib/plugins/linksPlugin/linksPlugin.d.ts +0 -28
  47. package/lib/plugins/linksPlugin/linksPlugin.js +0 -98
  48. package/lib/plugins/linksPlugin/resolvePaths.d.ts +0 -7
  49. package/lib/plugins/linksPlugin/resolvePaths.js +0 -51
  50. package/lib/types.d.ts +0 -71
  51. package/lib/types.js +0 -2
package/dist/index.js ADDED
@@ -0,0 +1,583 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/markdown.ts
8
+ import { slugify as defaultSlugify } from "@mdit-vue/shared";
9
+ import MarkdownIt from "markdown-it";
10
+
11
+ // src/plugins.ts
12
+ import {
13
+ componentPlugin
14
+ } from "@mdit-vue/plugin-component";
15
+ import {
16
+ frontmatterPlugin
17
+ } from "@mdit-vue/plugin-frontmatter";
18
+ import {
19
+ headersPlugin
20
+ } from "@mdit-vue/plugin-headers";
21
+ import { sfcPlugin } from "@mdit-vue/plugin-sfc";
22
+ import { titlePlugin } from "@mdit-vue/plugin-title";
23
+ import { tocPlugin } from "@mdit-vue/plugin-toc";
24
+
25
+ // src/plugins/anchorPlugin.ts
26
+ import anchorPlugin from "markdown-it-anchor";
27
+
28
+ // src/plugins/assetsPlugin/resolveLink.ts
29
+ import { path } from "@vuepress/utils";
30
+ import { decode } from "mdurl";
31
+ var resolveLink = (link, relativePathPrefix, env) => {
32
+ let resolvedLink = decode(link);
33
+ if (/^\.{1,2}\//.test(link) && env.filePathRelative) {
34
+ resolvedLink = `${relativePathPrefix}/${path.join(
35
+ path.dirname(env.filePathRelative),
36
+ resolvedLink
37
+ )}`;
38
+ }
39
+ return resolvedLink;
40
+ };
41
+
42
+ // src/plugins/assetsPlugin/assetsPlugin.ts
43
+ var assetsPlugin = (md, { relativePathPrefix = "@source" } = {}) => {
44
+ const rawImageRule = md.renderer.rules.image;
45
+ md.renderer.rules.image = (tokens, idx, options, env, self) => {
46
+ const token = tokens[idx];
47
+ const link = token.attrGet("src");
48
+ if (link) {
49
+ token.attrSet("src", resolveLink(link, relativePathPrefix, env));
50
+ }
51
+ return rawImageRule(tokens, idx, options, env, self);
52
+ };
53
+ const createHtmlRule = (rawHtmlRule) => (tokens, idx, options, env, self) => {
54
+ tokens[idx].content = tokens[idx].content.replace(
55
+ /(<img\b.*?src=")([^"]*)(")/gs,
56
+ (_, prefix, src, suffix) => `${prefix}${resolveLink(
57
+ src.trim(),
58
+ relativePathPrefix,
59
+ env
60
+ )}${suffix}`
61
+ ).replace(
62
+ /(<img\b.*?srcset=")([^"]*)(")/gs,
63
+ (_, prefix, srcset, suffix) => `${prefix}${srcset.split(",").map(
64
+ (item) => item.trim().replace(
65
+ /^([^ ]*?)([ \n].*)?$/,
66
+ (_2, url, descriptor = "") => `${resolveLink(
67
+ url.trim(),
68
+ relativePathPrefix,
69
+ env
70
+ )}${descriptor.replace(/[ \n]+/g, " ").trimEnd()}`
71
+ )
72
+ ).join(", ")}${suffix}`
73
+ );
74
+ return rawHtmlRule(tokens, idx, options, env, self);
75
+ };
76
+ const rawHtmlBlockRule = md.renderer.rules.html_block;
77
+ const rawHtmlInlineRule = md.renderer.rules.html_inline;
78
+ md.renderer.rules.html_block = createHtmlRule(rawHtmlBlockRule);
79
+ md.renderer.rules.html_inline = createHtmlRule(rawHtmlInlineRule);
80
+ };
81
+
82
+ // src/plugins/codePlugin/resolveHighlightLines.ts
83
+ var resolveHighlightLines = (info) => {
84
+ const match = info.match(/{([\d,-]+)}/);
85
+ if (match === null) {
86
+ return null;
87
+ }
88
+ return match[1].split(",").map((item) => {
89
+ const range = item.split("-");
90
+ if (range.length === 1) {
91
+ range.push(range[0]);
92
+ }
93
+ return range.map((str) => Number.parseInt(str, 10));
94
+ });
95
+ };
96
+ var isHighlightLine = (lineNumber, ranges) => ranges.some(([start, end]) => lineNumber >= start && lineNumber <= end);
97
+
98
+ // src/plugins/codePlugin/languages.ts
99
+ var languages_exports = {};
100
+ __export(languages_exports, {
101
+ languageBash: () => languageBash,
102
+ languageCsharp: () => languageCsharp,
103
+ languageDocker: () => languageDocker,
104
+ languageFsharp: () => languageFsharp,
105
+ languageJavascript: () => languageJavascript,
106
+ languageKotlin: () => languageKotlin,
107
+ languageMarkdown: () => languageMarkdown,
108
+ languagePython: () => languagePython,
109
+ languageRuby: () => languageRuby,
110
+ languageRust: () => languageRust,
111
+ languageStylus: () => languageStylus,
112
+ languageTypescript: () => languageTypescript,
113
+ languageYaml: () => languageYaml
114
+ });
115
+ var languageBash = {
116
+ name: "bash",
117
+ ext: "sh",
118
+ aliases: ["bash", "sh", "shell", "zsh"]
119
+ };
120
+ var languageCsharp = {
121
+ name: "csharp",
122
+ ext: "cs",
123
+ aliases: ["cs", "csharp"]
124
+ };
125
+ var languageDocker = {
126
+ name: "docker",
127
+ ext: "docker",
128
+ aliases: ["docker", "dockerfile"]
129
+ };
130
+ var languageFsharp = {
131
+ name: "fsharp",
132
+ ext: "fs",
133
+ aliases: ["fs", "fsharp"]
134
+ };
135
+ var languageJavascript = {
136
+ name: "javascript",
137
+ ext: "js",
138
+ aliases: ["javascript", "js"]
139
+ };
140
+ var languageKotlin = {
141
+ name: "kotlin",
142
+ ext: "kt",
143
+ aliases: ["kotlin", "kt"]
144
+ };
145
+ var languageMarkdown = {
146
+ name: "markdown",
147
+ ext: "md",
148
+ aliases: ["markdown", "md"]
149
+ };
150
+ var languagePython = {
151
+ name: "python",
152
+ ext: "py",
153
+ aliases: ["py", "python"]
154
+ };
155
+ var languageRuby = {
156
+ name: "ruby",
157
+ ext: "rb",
158
+ aliases: ["rb", "ruby"]
159
+ };
160
+ var languageRust = {
161
+ name: "rust",
162
+ ext: "rs",
163
+ aliases: ["rs", "rust"]
164
+ };
165
+ var languageStylus = {
166
+ name: "stylus",
167
+ ext: "styl",
168
+ aliases: ["styl", "stylus"]
169
+ };
170
+ var languageTypescript = {
171
+ name: "typescript",
172
+ ext: "ts",
173
+ aliases: ["ts", "typescript"]
174
+ };
175
+ var languageYaml = {
176
+ name: "yaml",
177
+ ext: "yml",
178
+ aliases: ["yaml", "yml"]
179
+ };
180
+
181
+ // src/plugins/codePlugin/resolveLanguage.ts
182
+ var languagesMap;
183
+ var getLanguagesMap = () => {
184
+ if (!languagesMap) {
185
+ languagesMap = Object.values(languages_exports).reduce((result, item) => {
186
+ item.aliases.forEach((alias) => {
187
+ result[alias] = item;
188
+ });
189
+ return result;
190
+ }, {});
191
+ }
192
+ return languagesMap;
193
+ };
194
+ var resolveLanguage = (info) => {
195
+ const alias = info.match(/^([^ :[{]+)/)?.[1] || "text";
196
+ return getLanguagesMap()[alias] ?? {
197
+ name: alias,
198
+ ext: alias,
199
+ aliases: [alias]
200
+ };
201
+ };
202
+
203
+ // src/plugins/codePlugin/resolveLineNumbers.ts
204
+ var resolveLineNumbers = (info) => {
205
+ if (/:line-numbers\b/.test(info)) {
206
+ return true;
207
+ }
208
+ if (/:no-line-numbers\b/.test(info)) {
209
+ return false;
210
+ }
211
+ return null;
212
+ };
213
+
214
+ // src/plugins/codePlugin/resolveVPre.ts
215
+ var resolveVPre = (info) => {
216
+ if (/:v-pre\b/.test(info)) {
217
+ return true;
218
+ }
219
+ if (/:no-v-pre\b/.test(info)) {
220
+ return false;
221
+ }
222
+ return null;
223
+ };
224
+
225
+ // src/plugins/codePlugin/codePlugin.ts
226
+ var codePlugin = (md, {
227
+ highlightLines = true,
228
+ lineNumbers = true,
229
+ preWrapper = true,
230
+ vPre: { block: vPreBlock = true, inline: vPreInline = true } = {}
231
+ } = {}) => {
232
+ md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
233
+ const token = tokens[idx];
234
+ const info = token.info ? md.utils.unescapeAll(token.info).trim() : "";
235
+ const language = resolveLanguage(info);
236
+ const languageClass = `${options.langPrefix}${language.name}`;
237
+ const code = options.highlight?.(token.content, language.name, "") || md.utils.escapeHtml(token.content);
238
+ let result = code.startsWith("<pre") ? code : `<pre class="${languageClass}"><code>${code}</code></pre>`;
239
+ const useVPre = resolveVPre(info) ?? vPreBlock;
240
+ if (useVPre) {
241
+ result = `<pre v-pre${result.slice("<pre".length)}`;
242
+ }
243
+ if (!preWrapper) {
244
+ return result;
245
+ }
246
+ const lines = code.split("\n").slice(0, -1);
247
+ const highlightLinesRanges = highlightLines ? resolveHighlightLines(info) : null;
248
+ if (highlightLinesRanges) {
249
+ const highlightLinesCode = lines.map((_, index) => {
250
+ if (isHighlightLine(index + 1, highlightLinesRanges)) {
251
+ return '<div class="highlight-line">&nbsp;</div>';
252
+ }
253
+ return "<br>";
254
+ }).join("");
255
+ result = `${result}<div class="highlight-lines">${highlightLinesCode}</div>`;
256
+ }
257
+ const useLineNumbers = resolveLineNumbers(info) ?? (typeof lineNumbers === "number" ? lines.length >= lineNumbers : lineNumbers);
258
+ if (useLineNumbers) {
259
+ const lineNumbersCode = lines.map(() => `<div class="line-number"></div>`).join("");
260
+ result = `${result}<div class="line-numbers" aria-hidden="true">${lineNumbersCode}</div>`;
261
+ }
262
+ result = `<div class="${languageClass} ext-${language.ext}${useLineNumbers ? " line-numbers-mode" : ""}">${result}</div>`;
263
+ return result;
264
+ };
265
+ if (vPreInline) {
266
+ const rawInlineCodeRule = md.renderer.rules.code_inline;
267
+ md.renderer.rules.code_inline = (tokens, idx, options, env, slf) => {
268
+ const result = rawInlineCodeRule(tokens, idx, options, env, slf);
269
+ return `<code v-pre${result.slice("<code".length)}`;
270
+ };
271
+ }
272
+ };
273
+
274
+ // src/plugins/emojiPlugin.ts
275
+ import emojiPlugin from "markdown-it-emoji";
276
+
277
+ // src/plugins/importCodePlugin/createImportCodeBlockRule.ts
278
+ import { path as path2 } from "@vuepress/utils";
279
+ var MIN_LENGTH = 9;
280
+ var START_CODES = [64, 91, 99, 111, 100, 101];
281
+ var SYNTAX_RE = /^@\[code(?:{(?:(\d+)?-(\d+)?)})?(?: ([^\]]+))?\]\(([^)]*)\)/;
282
+ var createImportCodeBlockRule = ({ handleImportPath = (str) => str }) => (state, startLine, endLine, silent) => {
283
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
284
+ return false;
285
+ }
286
+ const pos = state.bMarks[startLine] + state.tShift[startLine];
287
+ const max = state.eMarks[startLine];
288
+ if (pos + MIN_LENGTH > max)
289
+ return false;
290
+ for (let i = 0; i < START_CODES.length; i += 1) {
291
+ if (state.src.charCodeAt(pos + i) !== START_CODES[i]) {
292
+ return false;
293
+ }
294
+ }
295
+ const match = state.src.slice(pos, max).match(SYNTAX_RE);
296
+ if (!match)
297
+ return false;
298
+ if (silent)
299
+ return true;
300
+ const [, lineStart, lineEnd, info, importPath] = match;
301
+ const meta = {
302
+ importPath: handleImportPath(importPath),
303
+ lineStart: lineStart ? Number.parseInt(lineStart, 10) : 0,
304
+ lineEnd: lineEnd ? Number.parseInt(lineEnd, 10) : void 0
305
+ };
306
+ const token = state.push("import_code", "code", 0);
307
+ token.info = info ?? path2.extname(meta.importPath).slice(1);
308
+ token.markup = "```";
309
+ token.map = [startLine, startLine + 1];
310
+ token.meta = meta;
311
+ state.line = startLine + 1;
312
+ return true;
313
+ };
314
+
315
+ // src/plugins/importCodePlugin/resolveImportCode.ts
316
+ import { fs, path as path3 } from "@vuepress/utils";
317
+ var resolveImportCode = ({ importPath, lineStart, lineEnd }, { filePath }) => {
318
+ let importFilePath = importPath;
319
+ if (!path3.isAbsolute(importPath)) {
320
+ if (!filePath) {
321
+ return {
322
+ importFilePath: null,
323
+ importCode: "Error when resolving path"
324
+ };
325
+ }
326
+ importFilePath = path3.resolve(filePath, "..", importPath);
327
+ }
328
+ if (!fs.existsSync(importFilePath)) {
329
+ return {
330
+ importFilePath,
331
+ importCode: "File not found"
332
+ };
333
+ }
334
+ const fileContent = fs.readFileSync(importFilePath).toString();
335
+ return {
336
+ importFilePath,
337
+ importCode: fileContent.split("\n").slice(lineStart ? lineStart - 1 : lineStart, lineEnd).join("\n").replace(/\n?$/, "\n")
338
+ };
339
+ };
340
+
341
+ // src/plugins/importCodePlugin/importCodePlugin.ts
342
+ var importCodePlugin = (md, options = {}) => {
343
+ md.block.ruler.before(
344
+ "fence",
345
+ "import_code",
346
+ createImportCodeBlockRule(options),
347
+ {
348
+ alt: ["paragraph", "reference", "blockquote", "list"]
349
+ }
350
+ );
351
+ md.renderer.rules.import_code = (tokens, idx, options2, env, slf) => {
352
+ const token = tokens[idx];
353
+ const { importFilePath, importCode } = resolveImportCode(token.meta, env);
354
+ token.content = importCode;
355
+ if (importFilePath) {
356
+ const importedFiles = env.importedFiles || (env.importedFiles = []);
357
+ importedFiles.push(importFilePath);
358
+ }
359
+ return md.renderer.rules.fence(tokens, idx, options2, env, slf);
360
+ };
361
+ };
362
+
363
+ // src/plugins/linksPlugin/linksPlugin.ts
364
+ import { isLinkExternal } from "@vuepress/shared";
365
+
366
+ // src/plugins/linksPlugin/resolvePaths.ts
367
+ import { removeLeadingSlash } from "@vuepress/shared";
368
+ import { path as path4 } from "@vuepress/utils";
369
+ var resolvePaths = (rawPath, base, filePathRelative) => {
370
+ let absolutePath;
371
+ let relativePath;
372
+ if (rawPath.startsWith("/")) {
373
+ if (rawPath.endsWith(".md")) {
374
+ absolutePath = path4.join(base, rawPath);
375
+ relativePath = removeLeadingSlash(rawPath);
376
+ } else {
377
+ absolutePath = rawPath;
378
+ relativePath = path4.relative(base, absolutePath);
379
+ }
380
+ } else {
381
+ if (filePathRelative) {
382
+ relativePath = path4.join(
383
+ path4.dirname(encodeURI(filePathRelative)),
384
+ rawPath
385
+ );
386
+ absolutePath = path4.join(base, relativePath);
387
+ } else {
388
+ relativePath = rawPath.replace(/^(?:\.\/)?(.*)$/, "$1");
389
+ absolutePath = relativePath;
390
+ }
391
+ }
392
+ return {
393
+ absolutePath,
394
+ relativePath
395
+ };
396
+ };
397
+
398
+ // src/plugins/linksPlugin/linksPlugin.ts
399
+ var linksPlugin = (md, options = {}) => {
400
+ const internalTag = options.internalTag || "RouterLink";
401
+ const externalAttrs = {
402
+ target: "_blank",
403
+ rel: "noopener noreferrer",
404
+ ...options.externalAttrs
405
+ };
406
+ let hasOpenInternalLink = false;
407
+ const handleLinkOpen = (tokens, idx, env) => {
408
+ const token = tokens[idx];
409
+ const hrefIndex = token.attrIndex("href");
410
+ if (hrefIndex < 0) {
411
+ return;
412
+ }
413
+ const hrefAttr = token.attrs[hrefIndex];
414
+ const hrefLink = hrefAttr[1];
415
+ const { base = "/", filePathRelative = null } = env;
416
+ if (isLinkExternal(hrefLink, base)) {
417
+ Object.entries(externalAttrs).forEach(
418
+ ([key, val]) => token.attrSet(key, val)
419
+ );
420
+ return;
421
+ }
422
+ const internalLinkMatch = hrefLink.match(
423
+ /^((?:.*)(?:\/|\.md|\.html))(#.*)?$/
424
+ );
425
+ if (!internalLinkMatch) {
426
+ return;
427
+ }
428
+ const rawPath = internalLinkMatch[1];
429
+ const rawHash = internalLinkMatch[2] || "";
430
+ const { relativePath, absolutePath } = resolvePaths(
431
+ rawPath,
432
+ base,
433
+ filePathRelative
434
+ );
435
+ const normalizedPath = absolutePath.replace(new RegExp(`^${base}`), "/").replace(/(^|\/)(README|index).md$/i, "$1").replace(/\.md$/, ".html");
436
+ if (internalTag === "RouterLink") {
437
+ token.tag = internalTag;
438
+ hrefAttr[0] = "to";
439
+ hasOpenInternalLink = true;
440
+ }
441
+ hrefAttr[1] = `${normalizedPath}${rawHash}`;
442
+ const links = env.links || (env.links = []);
443
+ links.push({
444
+ raw: hrefLink,
445
+ relative: relativePath,
446
+ absolute: absolutePath
447
+ });
448
+ };
449
+ md.renderer.rules.link_open = (tokens, idx, options2, env, self) => {
450
+ handleLinkOpen(tokens, idx, env);
451
+ return self.renderToken(tokens, idx, options2);
452
+ };
453
+ md.renderer.rules.link_close = (tokens, idx, options2, env, self) => {
454
+ if (hasOpenInternalLink) {
455
+ hasOpenInternalLink = false;
456
+ tokens[idx].tag = internalTag;
457
+ }
458
+ return self.renderToken(tokens, idx, options2);
459
+ };
460
+ };
461
+
462
+ // src/markdown.ts
463
+ var createMarkdown = ({
464
+ anchor,
465
+ assets,
466
+ code,
467
+ component,
468
+ emoji,
469
+ frontmatter,
470
+ headers,
471
+ title,
472
+ importCode,
473
+ links,
474
+ sfc,
475
+ slugify = defaultSlugify,
476
+ toc,
477
+ ...markdownItOptions
478
+ } = {}) => {
479
+ const md = MarkdownIt({
480
+ ...markdownItOptions,
481
+ html: true
482
+ });
483
+ if (emoji !== false) {
484
+ md.use(emojiPlugin, emoji);
485
+ }
486
+ if (anchor !== false) {
487
+ md.use(anchorPlugin, {
488
+ level: [1, 2, 3, 4, 5, 6],
489
+ slugify,
490
+ permalink: anchorPlugin.permalink.ariaHidden({
491
+ class: "header-anchor",
492
+ symbol: "#",
493
+ space: true,
494
+ placement: "before"
495
+ }),
496
+ ...anchor
497
+ });
498
+ }
499
+ if (toc !== false) {
500
+ md.use(tocPlugin, {
501
+ level: [2, 3],
502
+ slugify,
503
+ linkTag: "router-link",
504
+ ...toc
505
+ });
506
+ }
507
+ if (headers !== false) {
508
+ md.use(headersPlugin, {
509
+ level: [2, 3],
510
+ slugify,
511
+ ...headers
512
+ });
513
+ }
514
+ if (title !== false) {
515
+ md.use(titlePlugin);
516
+ }
517
+ if (component !== false) {
518
+ md.use(componentPlugin);
519
+ }
520
+ if (frontmatter !== false) {
521
+ md.use(frontmatterPlugin, {
522
+ ...frontmatter,
523
+ grayMatterOptions: {
524
+ excerpt: true,
525
+ excerpt_separator: "<!-- more -->",
526
+ ...frontmatter?.grayMatterOptions
527
+ }
528
+ });
529
+ }
530
+ if (assets !== false) {
531
+ md.use(assetsPlugin, assets);
532
+ }
533
+ if (sfc !== false) {
534
+ md.use(sfcPlugin, sfc);
535
+ }
536
+ if (links !== false) {
537
+ md.use(linksPlugin, links);
538
+ }
539
+ if (code !== false) {
540
+ md.use(codePlugin, code);
541
+ }
542
+ if (importCode !== false) {
543
+ md.use(importCodePlugin, importCode);
544
+ }
545
+ return md;
546
+ };
547
+ export {
548
+ anchorPlugin,
549
+ assetsPlugin,
550
+ codePlugin,
551
+ componentPlugin,
552
+ createImportCodeBlockRule,
553
+ createMarkdown,
554
+ emojiPlugin,
555
+ frontmatterPlugin,
556
+ headersPlugin,
557
+ importCodePlugin,
558
+ isHighlightLine,
559
+ languageBash,
560
+ languageCsharp,
561
+ languageDocker,
562
+ languageFsharp,
563
+ languageJavascript,
564
+ languageKotlin,
565
+ languageMarkdown,
566
+ languagePython,
567
+ languageRuby,
568
+ languageRust,
569
+ languageStylus,
570
+ languageTypescript,
571
+ languageYaml,
572
+ linksPlugin,
573
+ resolveHighlightLines,
574
+ resolveImportCode,
575
+ resolveLanguage,
576
+ resolveLineNumbers,
577
+ resolveLink,
578
+ resolvePaths,
579
+ resolveVPre,
580
+ sfcPlugin,
581
+ titlePlugin,
582
+ tocPlugin
583
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/markdown",
3
- "version": "2.0.0-beta.49",
3
+ "version": "2.0.0-beta.50-pre.1",
4
4
  "description": "Markdown package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -16,34 +16,56 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "author": "meteorlxy",
19
- "main": "lib/index.js",
20
- "types": "lib/index.d.ts",
19
+ "type": "module",
20
+ "exports": {
21
+ ".": "./dist/index.js",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
21
26
  "files": [
22
- "lib"
27
+ "dist"
23
28
  ],
24
29
  "dependencies": {
25
- "@mdit-vue/plugin-component": "^0.6.0",
26
- "@mdit-vue/plugin-frontmatter": "^0.6.0",
27
- "@mdit-vue/plugin-headers": "^0.6.0",
28
- "@mdit-vue/plugin-sfc": "^0.6.0",
29
- "@mdit-vue/plugin-title": "^0.6.0",
30
- "@mdit-vue/plugin-toc": "^0.6.0",
31
- "@mdit-vue/shared": "^0.6.0",
32
- "@mdit-vue/types": "^0.6.0",
30
+ "@mdit-vue/plugin-component": "^0.9.0",
31
+ "@mdit-vue/plugin-frontmatter": "^0.9.1",
32
+ "@mdit-vue/plugin-headers": "^0.9.1",
33
+ "@mdit-vue/plugin-sfc": "^0.9.1",
34
+ "@mdit-vue/plugin-title": "^0.9.1",
35
+ "@mdit-vue/plugin-toc": "^0.9.1",
36
+ "@mdit-vue/shared": "^0.9.1",
37
+ "@mdit-vue/types": "^0.9.0",
33
38
  "@types/markdown-it": "^12.2.3",
34
39
  "@types/markdown-it-emoji": "^2.0.2",
35
- "@vuepress/shared": "2.0.0-beta.49",
36
- "@vuepress/utils": "2.0.0-beta.49",
40
+ "@vuepress/shared": "2.0.0-beta.50-pre.1",
41
+ "@vuepress/utils": "2.0.0-beta.50-pre.1",
37
42
  "markdown-it": "^13.0.1",
38
43
  "markdown-it-anchor": "^8.6.4",
39
44
  "markdown-it-emoji": "^2.0.2",
40
45
  "mdurl": "^1.0.1"
41
46
  },
47
+ "devDependencies": {
48
+ "@types/mdurl": "^1.0.2"
49
+ },
42
50
  "publishConfig": {
43
51
  "access": "public"
44
52
  },
53
+ "tsup": {
54
+ "clean": true,
55
+ "dts": "./src/index.ts",
56
+ "entry": [
57
+ "./src/index.ts"
58
+ ],
59
+ "format": [
60
+ "esm"
61
+ ],
62
+ "outDir": "./dist",
63
+ "sourcemap": false,
64
+ "target": "es2020",
65
+ "tsconfig": "../tsconfig.dts.json"
66
+ },
45
67
  "scripts": {
46
- "build": "tsc -b tsconfig.build.json",
47
- "clean": "rimraf lib *.tsbuildinfo"
68
+ "build": "tsup",
69
+ "clean": "rimraf dist"
48
70
  }
49
71
  }
package/lib/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './markdown';
2
- export * from './plugins';
3
- export * from './types';
package/lib/index.js DELETED
@@ -1,19 +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
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./markdown"), exports);
18
- __exportStar(require("./plugins"), exports);
19
- __exportStar(require("./types"), 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, component, emoji, frontmatter, headers, title, importCode, links, sfc, slugify, toc, ...markdownItOptions }?: MarkdownOptions) => Markdown;