@vuepress/markdown 2.0.0-beta.9 → 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 -247
  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 -32
  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 -56
  63. package/lib/types.d.ts +0 -62
  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 -12
  70. package/lib/utils/resolveHeadersFromTokens.js +0 -83
  71. package/lib/utils/slugify.d.ts +0 -1
  72. package/lib/utils/slugify.js +0 -24
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveHeadersFromTokens = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Resolve headers from markdown-it tokens
7
- */
8
- const resolveHeadersFromTokens = (tokens, { level, allowHtml, escapeText, slugify, format, }) => {
9
- // store the result of headers
10
- const headers = [];
11
- // a temp headers stack for generating the headers tree
12
- const stack = [];
13
- // push a header to the headers tree
14
- const push = (header) => {
15
- while (stack.length !== 0 && header.level <= stack[0].level) {
16
- stack.shift();
17
- }
18
- if (stack.length === 0) {
19
- headers.push(header);
20
- stack.push(header);
21
- }
22
- else {
23
- stack[0].children.push(header);
24
- stack.unshift(header);
25
- }
26
- };
27
- tokens.forEach((_, idx) => {
28
- var _a, _b;
29
- const token = tokens[idx];
30
- // if the token type is not matched, skip
31
- if ((token === null || token === void 0 ? void 0 : token.type) !== 'heading_open') {
32
- return;
33
- }
34
- // get the level from the tag, h1 -> 1
35
- const headerLevel = Number.parseInt(token.tag.slice(1), 10);
36
- // if the level should not be extracted, skip
37
- if (!level.includes(headerLevel)) {
38
- return;
39
- }
40
- // the next token of 'heading_open' contains the heading content
41
- const nextToken = tokens[idx + 1];
42
- // if the next token does not exist, skip
43
- if (!nextToken) {
44
- return;
45
- }
46
- // children of the next token contains the parsed result of the heading title
47
- const nextTokenChildren = (_a = nextToken.children) !== null && _a !== void 0 ? _a : [];
48
- // filter tokens for generating heading title
49
- // 'text' and 'code_inline' should be escaped to avoid being treated as html
50
- // 'emoji' and 'html_inline' should be used directly
51
- const titleTokenTypes = ['text', 'emoji', 'code_inline'];
52
- // include 'html_inline' or not
53
- if (allowHtml) {
54
- titleTokenTypes.push('html_inline');
55
- }
56
- const titleTokens = nextTokenChildren.filter((item) => titleTokenTypes.includes(item.type));
57
- // get title from tokens
58
- const title = titleTokens
59
- .reduce((result, item) => {
60
- if (escapeText) {
61
- // escape the content of 'code_inline' and 'text'
62
- if (item.type === 'code_inline' || item.type === 'text') {
63
- return `${result}${shared_1.htmlEscape(item.content)}`;
64
- }
65
- }
66
- // keep the content of 'emoji' and 'html_inline'
67
- return `${result}${item.content}`;
68
- }, '')
69
- .trim();
70
- // the id of the heading anchor is the slugify result of markdown-it-anchor
71
- // if the id does not exist, slugify the title ourselves
72
- const slug = (_b = token.attrGet('id')) !== null && _b !== void 0 ? _b : slugify(title);
73
- // push the header to tree
74
- push({
75
- level: headerLevel,
76
- title: shared_1.isFunction(format) ? format(title) : title,
77
- slug,
78
- children: [],
79
- });
80
- });
81
- return headers;
82
- };
83
- exports.resolveHeadersFromTokens = resolveHeadersFromTokens;
@@ -1 +0,0 @@
1
- export declare const slugify: (str: string) => string;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.slugify = void 0;
4
- // eslint-disable-next-line no-control-regex
5
- const rControl = /[\u0000-\u001f]/g;
6
- const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g;
7
- const rCombining = /[\u0300-\u036F]/g;
8
- const slugify = (str) => str
9
- .normalize('NFKD')
10
- // Remove accents
11
- .replace(rCombining, '')
12
- // Remove control characters
13
- .replace(rControl, '')
14
- // Replace special characters
15
- .replace(rSpecial, '-')
16
- // Remove continuos separators
17
- .replace(/-{2,}/g, '-')
18
- // Remove prefixing and trailing separators
19
- .replace(/^-+|-+$/g, '')
20
- // ensure it doesn't start with a number (#121)
21
- .replace(/^(\d)/, '_$1')
22
- // lowercase
23
- .toLowerCase();
24
- exports.slugify = slugify;