@vuepress/markdown 2.0.0-beta.48 → 2.0.0-beta.50-pre
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/package.json +39 -8
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -20
- package/lib/markdown.d.ts +0 -5
- package/lib/markdown.js +0 -88
- package/lib/plugins/anchorPlugin.d.ts +0 -3
- package/lib/plugins/anchorPlugin.js +0 -5
- package/lib/plugins/assetsPlugin/assetsPlugin.d.ts +0 -11
- package/lib/plugins/assetsPlugin/assetsPlugin.js +0 -41
- package/lib/plugins/assetsPlugin/index.d.ts +0 -2
- package/lib/plugins/assetsPlugin/index.js +0 -18
- package/lib/plugins/assetsPlugin/resolveLink.d.ts +0 -2
- package/lib/plugins/assetsPlugin/resolveLink.js +0 -16
- package/lib/plugins/codePlugin/codePlugin.d.ts +0 -40
- package/lib/plugins/codePlugin/codePlugin.js +0 -78
- package/lib/plugins/codePlugin/index.d.ts +0 -6
- package/lib/plugins/codePlugin/index.js +0 -22
- package/lib/plugins/codePlugin/languages.d.ts +0 -38
- package/lib/plugins/codePlugin/languages.js +0 -68
- package/lib/plugins/codePlugin/resolveHighlightLines.d.ts +0 -9
- package/lib/plugins/codePlugin/resolveHighlightLines.js +0 -28
- package/lib/plugins/codePlugin/resolveLanguage.d.ts +0 -5
- package/lib/plugins/codePlugin/resolveLanguage.js +0 -40
- package/lib/plugins/codePlugin/resolveLineNumbers.d.ts +0 -4
- package/lib/plugins/codePlugin/resolveLineNumbers.js +0 -16
- package/lib/plugins/codePlugin/resolveVPre.d.ts +0 -4
- package/lib/plugins/codePlugin/resolveVPre.js +0 -16
- package/lib/plugins/customComponentPlugin/customComponentPlugin.d.ts +0 -6
- package/lib/plugins/customComponentPlugin/customComponentPlugin.js +0 -18
- package/lib/plugins/customComponentPlugin/htmlBlockRule.d.ts +0 -2
- package/lib/plugins/customComponentPlugin/htmlBlockRule.js +0 -90
- package/lib/plugins/customComponentPlugin/htmlInlineRule.d.ts +0 -2
- package/lib/plugins/customComponentPlugin/htmlInlineRule.js +0 -40
- package/lib/plugins/customComponentPlugin/htmlRe.d.ts +0 -2
- package/lib/plugins/customComponentPlugin/htmlRe.js +0 -33
- package/lib/plugins/customComponentPlugin/index.d.ts +0 -6
- package/lib/plugins/customComponentPlugin/index.js +0 -22
- package/lib/plugins/customComponentPlugin/inlineTags.d.ts +0 -18
- package/lib/plugins/customComponentPlugin/inlineTags.js +0 -78
- package/lib/plugins/customComponentPlugin/vueReservedTags.d.ts +0 -6
- package/lib/plugins/customComponentPlugin/vueReservedTags.js +0 -17
- package/lib/plugins/emojiPlugin.d.ts +0 -25
- package/lib/plugins/emojiPlugin.js +0 -5
- package/lib/plugins/extractHeadersPlugin.d.ts +0 -28
- package/lib/plugins/extractHeadersPlugin.js +0 -32
- package/lib/plugins/extractTitlePlugin.d.ts +0 -5
- package/lib/plugins/extractTitlePlugin.js +0 -33
- package/lib/plugins/hoistTagsPlugin.d.ts +0 -12
- package/lib/plugins/hoistTagsPlugin.js +0 -27
- package/lib/plugins/importCodePlugin/createImportCodeBlockRule.d.ts +0 -3
- package/lib/plugins/importCodePlugin/createImportCodeBlockRule.js +0 -52
- package/lib/plugins/importCodePlugin/importCodePlugin.d.ts +0 -8
- package/lib/plugins/importCodePlugin/importCodePlugin.js +0 -26
- package/lib/plugins/importCodePlugin/index.d.ts +0 -4
- package/lib/plugins/importCodePlugin/index.js +0 -20
- package/lib/plugins/importCodePlugin/resolveImportCode.d.ts +0 -6
- package/lib/plugins/importCodePlugin/resolveImportCode.js +0 -37
- package/lib/plugins/importCodePlugin/types.d.ts +0 -5
- package/lib/plugins/importCodePlugin/types.js +0 -2
- package/lib/plugins/index.d.ts +0 -11
- package/lib/plugins/index.js +0 -27
- package/lib/plugins/linksPlugin/index.d.ts +0 -2
- package/lib/plugins/linksPlugin/index.js +0 -18
- package/lib/plugins/linksPlugin/linksPlugin.d.ts +0 -28
- package/lib/plugins/linksPlugin/linksPlugin.js +0 -98
- package/lib/plugins/linksPlugin/resolvePaths.d.ts +0 -7
- package/lib/plugins/linksPlugin/resolvePaths.js +0 -51
- package/lib/plugins/tocPlugin/createRenderHeaders.d.ts +0 -5
- package/lib/plugins/tocPlugin/createRenderHeaders.js +0 -28
- package/lib/plugins/tocPlugin/createTocBlockRule.d.ts +0 -11
- package/lib/plugins/tocPlugin/createTocBlockRule.js +0 -50
- package/lib/plugins/tocPlugin/index.d.ts +0 -3
- package/lib/plugins/tocPlugin/index.js +0 -19
- package/lib/plugins/tocPlugin/tocPlugin.d.ts +0 -66
- package/lib/plugins/tocPlugin/tocPlugin.js +0 -56
- package/lib/types.d.ts +0 -81
- package/lib/types.js +0 -2
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -19
- package/lib/utils/resolveHeadersFromTokens.d.ts +0 -12
- package/lib/utils/resolveHeadersFromTokens.js +0 -63
- package/lib/utils/resolveTitleFromToken.d.ts +0 -10
- package/lib/utils/resolveTitleFromToken.js +0 -37
- package/lib/utils/vuepressSlugify.d.ts +0 -5
- package/lib/utils/vuepressSlugify.js +0 -27
package/lib/types.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { PageFrontmatter, PageHeader } from '@vuepress/shared';
|
|
2
|
-
import type * as MarkdownIt from 'markdown-it';
|
|
3
|
-
import type { AnchorPluginOptions, AssetsPluginOptions, CodePluginOptions, EmojiPluginOptions, ExtractHeadersPluginOptions, HoistTagsPluginOptions, ImportCodePluginOptions, LinksPluginOptions, TocPluginOptions } from './plugins';
|
|
4
|
-
export declare type Markdown = MarkdownIt;
|
|
5
|
-
export interface MarkdownOptions extends MarkdownIt.Options {
|
|
6
|
-
anchor?: false | AnchorPluginOptions;
|
|
7
|
-
assets?: false | AssetsPluginOptions;
|
|
8
|
-
code?: false | CodePluginOptions;
|
|
9
|
-
customComponent?: false;
|
|
10
|
-
emoji?: false | EmojiPluginOptions;
|
|
11
|
-
extractHeaders?: false | ExtractHeadersPluginOptions;
|
|
12
|
-
extractTitle?: false;
|
|
13
|
-
hoistTags?: false | HoistTagsPluginOptions;
|
|
14
|
-
importCode?: false | ImportCodePluginOptions;
|
|
15
|
-
links?: false | LinksPluginOptions;
|
|
16
|
-
slugify?: MarkdownSlugifyFunction;
|
|
17
|
-
toc?: false | TocPluginOptions;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Headers in markdown file
|
|
21
|
-
*/
|
|
22
|
-
export declare type MarkdownHeader = PageHeader;
|
|
23
|
-
/**
|
|
24
|
-
* Internal links in markdown file
|
|
25
|
-
*
|
|
26
|
-
* Used for file existence check
|
|
27
|
-
*/
|
|
28
|
-
export interface MarkdownLink {
|
|
29
|
-
raw: string;
|
|
30
|
-
relative: string;
|
|
31
|
-
absolute: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The `env` object to be passed to markdown-it render function
|
|
35
|
-
*
|
|
36
|
-
* Input some meta data for markdown file parsing and rendering
|
|
37
|
-
*
|
|
38
|
-
* Output some resources from the markdown file
|
|
39
|
-
*/
|
|
40
|
-
export interface MarkdownEnv {
|
|
41
|
-
/**
|
|
42
|
-
* Base / publicPath of current site
|
|
43
|
-
*/
|
|
44
|
-
base?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Absolute file path of the markdown file
|
|
47
|
-
*/
|
|
48
|
-
filePath?: string | null;
|
|
49
|
-
/**
|
|
50
|
-
* Relative file path of the markdown file
|
|
51
|
-
*/
|
|
52
|
-
filePathRelative?: string | null;
|
|
53
|
-
/**
|
|
54
|
-
* Frontmatter of the markdown file
|
|
55
|
-
*/
|
|
56
|
-
frontmatter?: PageFrontmatter;
|
|
57
|
-
/**
|
|
58
|
-
* Headers that extracted by extractHeadersPlugin
|
|
59
|
-
*/
|
|
60
|
-
headers?: MarkdownHeader[];
|
|
61
|
-
/**
|
|
62
|
-
* Hoisted tags that extracted by hoistTagsPlugin
|
|
63
|
-
*/
|
|
64
|
-
hoistedTags?: string[];
|
|
65
|
-
/**
|
|
66
|
-
* Imported file that extracted by importCodePlugin
|
|
67
|
-
*/
|
|
68
|
-
importedFiles?: string[];
|
|
69
|
-
/**
|
|
70
|
-
* Links that extracted by linksPlugin
|
|
71
|
-
*/
|
|
72
|
-
links?: MarkdownLink[];
|
|
73
|
-
/**
|
|
74
|
-
* Title that extracted by extractTitlePlugin
|
|
75
|
-
*/
|
|
76
|
-
title?: string;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Type of `slugify` function
|
|
80
|
-
*/
|
|
81
|
-
export declare type MarkdownSlugifyFunction = (str: string) => string;
|
package/lib/types.js
DELETED
package/lib/utils/index.d.ts
DELETED
package/lib/utils/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("./resolveHeadersFromTokens"), exports);
|
|
18
|
-
__exportStar(require("./resolveTitleFromToken"), exports);
|
|
19
|
-
__exportStar(require("./vuepressSlugify"), exports);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as Token from 'markdown-it/lib/token';
|
|
2
|
-
import type { MarkdownHeader } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve headers from markdown-it tokens
|
|
5
|
-
*/
|
|
6
|
-
export declare const resolveHeadersFromTokens: (tokens: Token[], { level, allowHtml, escapeText, slugify, format, }: {
|
|
7
|
-
level: number[];
|
|
8
|
-
allowHtml: boolean;
|
|
9
|
-
escapeText: boolean;
|
|
10
|
-
slugify: (str: string) => string;
|
|
11
|
-
format?: ((str: string) => string) | undefined;
|
|
12
|
-
}) => MarkdownHeader[];
|
|
@@ -1,63 +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
|
-
const resolveTitleFromToken_1 = require("./resolveTitleFromToken");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve headers from markdown-it tokens
|
|
8
|
-
*/
|
|
9
|
-
const resolveHeadersFromTokens = (tokens, { level, allowHtml, escapeText, slugify, format, }) => {
|
|
10
|
-
// store the result of headers
|
|
11
|
-
const headers = [];
|
|
12
|
-
// a temp headers stack for generating the headers tree
|
|
13
|
-
const stack = [];
|
|
14
|
-
// push a header to the headers tree
|
|
15
|
-
const push = (header) => {
|
|
16
|
-
while (stack.length !== 0 && header.level <= stack[0].level) {
|
|
17
|
-
stack.shift();
|
|
18
|
-
}
|
|
19
|
-
if (stack.length === 0) {
|
|
20
|
-
headers.push(header);
|
|
21
|
-
stack.push(header);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
stack[0].children.push(header);
|
|
25
|
-
stack.unshift(header);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
tokens.forEach((_, idx) => {
|
|
29
|
-
const token = tokens[idx];
|
|
30
|
-
// if the token type does not match, skip
|
|
31
|
-
if (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
|
-
const title = (0, resolveTitleFromToken_1.resolveTitleFromToken)(nextToken, {
|
|
47
|
-
allowHtml,
|
|
48
|
-
escapeText,
|
|
49
|
-
});
|
|
50
|
-
// the id of the heading anchor is the slugify result of markdown-it-anchor
|
|
51
|
-
// if the id does not exist, slugify the title ourselves
|
|
52
|
-
const slug = token.attrGet('id') ?? slugify(title);
|
|
53
|
-
// push the header to tree
|
|
54
|
-
push({
|
|
55
|
-
level: headerLevel,
|
|
56
|
-
title: (0, shared_1.isFunction)(format) ? format(title) : title,
|
|
57
|
-
slug,
|
|
58
|
-
children: [],
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
return headers;
|
|
62
|
-
};
|
|
63
|
-
exports.resolveHeadersFromTokens = resolveHeadersFromTokens;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type * as Token from 'markdown-it/lib/token';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve header title from markdown-it token
|
|
4
|
-
*
|
|
5
|
-
* Typically using the next token of `heading_open` token
|
|
6
|
-
*/
|
|
7
|
-
export declare const resolveTitleFromToken: (token: Token, { allowHtml, escapeText, }: {
|
|
8
|
-
allowHtml: boolean;
|
|
9
|
-
escapeText: boolean;
|
|
10
|
-
}) => string;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveTitleFromToken = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve header title from markdown-it token
|
|
7
|
-
*
|
|
8
|
-
* Typically using the next token of `heading_open` token
|
|
9
|
-
*/
|
|
10
|
-
const resolveTitleFromToken = (token, { allowHtml, escapeText, }) => {
|
|
11
|
-
// children of the token contains the parsed result of the heading title
|
|
12
|
-
const children = token.children ?? [];
|
|
13
|
-
// type of tokens to be included in the heading title
|
|
14
|
-
const titleTokenTypes = ['text', 'emoji', 'code_inline'];
|
|
15
|
-
// include 'html_inline' or not
|
|
16
|
-
if (allowHtml) {
|
|
17
|
-
titleTokenTypes.push('html_inline');
|
|
18
|
-
}
|
|
19
|
-
// filter the token type to be included in the title
|
|
20
|
-
const titleTokens = children.filter((item) => titleTokenTypes.includes(item.type) &&
|
|
21
|
-
// filter permalink symbol that generated by markdown-it-anchor
|
|
22
|
-
!item.meta?.isPermalinkSymbol);
|
|
23
|
-
// get title from tokens
|
|
24
|
-
return titleTokens
|
|
25
|
-
.reduce((result, item) => {
|
|
26
|
-
if (escapeText) {
|
|
27
|
-
// escape the content of 'code_inline' and 'text'
|
|
28
|
-
if (item.type === 'code_inline' || item.type === 'text') {
|
|
29
|
-
return `${result}${(0, shared_1.htmlEscape)(item.content)}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// keep the content of 'emoji' and 'html_inline'
|
|
33
|
-
return `${result}${item.content}`;
|
|
34
|
-
}, '')
|
|
35
|
-
.trim();
|
|
36
|
-
};
|
|
37
|
-
exports.resolveTitleFromToken = resolveTitleFromToken;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.vuepressSlugify = 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
|
-
/**
|
|
9
|
-
* Default slugify function of vuepress
|
|
10
|
-
*/
|
|
11
|
-
const vuepressSlugify = (str) => str
|
|
12
|
-
.normalize('NFKD')
|
|
13
|
-
// Remove accents
|
|
14
|
-
.replace(rCombining, '')
|
|
15
|
-
// Remove control characters
|
|
16
|
-
.replace(rControl, '')
|
|
17
|
-
// Replace special characters
|
|
18
|
-
.replace(rSpecial, '-')
|
|
19
|
-
// Remove continuos separators
|
|
20
|
-
.replace(/-{2,}/g, '-')
|
|
21
|
-
// Remove prefixing and trailing separators
|
|
22
|
-
.replace(/^-+|-+$/g, '')
|
|
23
|
-
// ensure it doesn't start with a number (#121)
|
|
24
|
-
.replace(/^(\d)/, '_$1')
|
|
25
|
-
// lowercase
|
|
26
|
-
.toLowerCase();
|
|
27
|
-
exports.vuepressSlugify = vuepressSlugify;
|