@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.
- package/dist/index.d.ts +184 -0
- package/dist/index.js +577 -0
- package/package.json +48 -17
- package/CHANGELOG.md +0 -247
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -16
- package/lib/markdown.d.ts +0 -5
- package/lib/markdown.js +0 -77
- package/lib/plugins/anchorPlugin.d.ts +0 -62
- package/lib/plugins/anchorPlugin.js +0 -5
- package/lib/plugins/assetsPlugin.d.ts +0 -11
- package/lib/plugins/assetsPlugin.js +0 -24
- package/lib/plugins/codePlugin/codePlugin.d.ts +0 -28
- package/lib/plugins/codePlugin/codePlugin.js +0 -73
- package/lib/plugins/codePlugin/index.d.ts +0 -6
- package/lib/plugins/codePlugin/index.js +0 -18
- 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 -41
- 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 -4
- package/lib/plugins/customComponentPlugin/index.js +0 -16
- 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 -27
- package/lib/plugins/extractHeadersPlugin.js +0 -32
- package/lib/plugins/hoistTagsPlugin.d.ts +0 -12
- package/lib/plugins/hoistTagsPlugin.js +0 -26
- package/lib/plugins/index.d.ts +0 -9
- package/lib/plugins/index.js +0 -21
- package/lib/plugins/linksPlugin/index.d.ts +0 -2
- package/lib/plugins/linksPlugin/index.js +0 -14
- package/lib/plugins/linksPlugin/linksPlugin.d.ts +0 -12
- package/lib/plugins/linksPlugin/linksPlugin.js +0 -108
- package/lib/plugins/linksPlugin/resolvePaths.d.ts +0 -7
- package/lib/plugins/linksPlugin/resolvePaths.js +0 -38
- 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 -15
- package/lib/plugins/tocPlugin/tocPlugin.d.ts +0 -65
- package/lib/plugins/tocPlugin/tocPlugin.js +0 -56
- package/lib/types.d.ts +0 -62
- package/lib/types.js +0 -2
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -15
- package/lib/utils/parseEmoji.d.ts +0 -1
- package/lib/utils/parseEmoji.js +0 -6
- package/lib/utils/resolveHeadersFromTokens.d.ts +0 -12
- package/lib/utils/resolveHeadersFromTokens.js +0 -83
- package/lib/utils/slugify.d.ts +0 -1
- package/lib/utils/slugify.js +0 -24
|
@@ -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
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare type HighlightLinesRange = [number, number];
|
|
2
|
-
/**
|
|
3
|
-
* Resolve highlight-lines ranges from token info
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolveHighlightLines: (info: string) => HighlightLinesRange[] | null;
|
|
6
|
-
/**
|
|
7
|
-
* Check if a line number is in ranges
|
|
8
|
-
*/
|
|
9
|
-
export declare const isHighlightLine: (lineNumber: number, ranges: HighlightLinesRange[]) => boolean;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isHighlightLine = exports.resolveHighlightLines = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve highlight-lines ranges from token info
|
|
6
|
-
*/
|
|
7
|
-
const resolveHighlightLines = (info) => {
|
|
8
|
-
// try to match highlight-lines mark
|
|
9
|
-
const match = info.match(/{([\d,-]+)}/);
|
|
10
|
-
// no highlight-lines mark, return `null`
|
|
11
|
-
if (match === null) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
// resolve lines ranges from the highlight-lines mark
|
|
15
|
-
return match[1].split(',').map((item) => {
|
|
16
|
-
const range = item.split('-');
|
|
17
|
-
if (range.length === 1) {
|
|
18
|
-
range.push(range[0]);
|
|
19
|
-
}
|
|
20
|
-
return range.map((str) => Number.parseInt(str, 10));
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.resolveHighlightLines = resolveHighlightLines;
|
|
24
|
-
/**
|
|
25
|
-
* Check if a line number is in ranges
|
|
26
|
-
*/
|
|
27
|
-
const isHighlightLine = (lineNumber, ranges) => ranges.some(([start, end]) => lineNumber >= start && lineNumber <= end);
|
|
28
|
-
exports.isHighlightLine = isHighlightLine;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveLanguage = void 0;
|
|
4
|
-
const languages = require("./languages");
|
|
5
|
-
/**
|
|
6
|
-
* A key-value map to get language info from alias
|
|
7
|
-
*
|
|
8
|
-
* - key: alias
|
|
9
|
-
* - value: language
|
|
10
|
-
*/
|
|
11
|
-
let languagesMap;
|
|
12
|
-
/**
|
|
13
|
-
* Lazy generate languages map
|
|
14
|
-
*/
|
|
15
|
-
const getLanguagesMap = () => {
|
|
16
|
-
if (!languagesMap) {
|
|
17
|
-
languagesMap = Object.values(languages).reduce((result, item) => {
|
|
18
|
-
item.aliases.forEach((alias) => {
|
|
19
|
-
result[alias] = item;
|
|
20
|
-
});
|
|
21
|
-
return result;
|
|
22
|
-
}, {});
|
|
23
|
-
}
|
|
24
|
-
return languagesMap;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Resolve language for highlight from token info
|
|
28
|
-
*/
|
|
29
|
-
const resolveLanguage = (info) => {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
// get user-defined language alias
|
|
32
|
-
const alias = ((_a = info.match(/^([a-zA-Z]+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'text';
|
|
33
|
-
// if the alias does not have a match in the map
|
|
34
|
-
// fallback to the alias itself
|
|
35
|
-
return ((_b = getLanguagesMap()[alias]) !== null && _b !== void 0 ? _b : {
|
|
36
|
-
name: alias,
|
|
37
|
-
ext: alias,
|
|
38
|
-
aliases: [alias],
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.resolveLanguage = resolveLanguage;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveLineNumbers = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the `:line-numbers` / `:no-line-numbers` mark from token info
|
|
6
|
-
*/
|
|
7
|
-
const resolveLineNumbers = (info) => {
|
|
8
|
-
if (/:line-numbers\b/.test(info)) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (/:no-line-numbers\b/.test(info)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
exports.resolveLineNumbers = resolveLineNumbers;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVPre = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the `:v-pre` / `:no-v-pre` mark from token info
|
|
6
|
-
*/
|
|
7
|
-
const resolveVPre = (info) => {
|
|
8
|
-
if (/:v-pre\b/.test(info)) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (/:no-v-pre\b/.test(info)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
exports.resolveVPre = resolveVPre;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customComponentPlugin = void 0;
|
|
4
|
-
const htmlBlockRule_1 = require("./htmlBlockRule");
|
|
5
|
-
const htmlInlineRule_1 = require("./htmlInlineRule");
|
|
6
|
-
/**
|
|
7
|
-
* Replacing the default htmlBlock rule to allow using custom components
|
|
8
|
-
* in markdown
|
|
9
|
-
*/
|
|
10
|
-
const customComponentPlugin = (md) => {
|
|
11
|
-
// override default html block ruler
|
|
12
|
-
md.block.ruler.at('html_block', htmlBlockRule_1.htmlBlockRule, {
|
|
13
|
-
alt: ['paragraph', 'reference', 'blockquote'],
|
|
14
|
-
});
|
|
15
|
-
// override default html inline ruler
|
|
16
|
-
md.inline.ruler.at('html_inline', htmlInlineRule_1.htmlInlineRule);
|
|
17
|
-
};
|
|
18
|
-
exports.customComponentPlugin = customComponentPlugin;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlBlockRule = void 0;
|
|
4
|
-
const blockNames = require("markdown-it/lib/common/html_blocks");
|
|
5
|
-
const htmlRe_1 = require("./htmlRe");
|
|
6
|
-
const inlineTags_1 = require("./inlineTags");
|
|
7
|
-
const vueReservedTags_1 = require("./vueReservedTags");
|
|
8
|
-
// Forked and modified from 'markdown-it/lib/rules_block/html_block.js'
|
|
9
|
-
// An array of opening and corresponding closing sequences for html tags,
|
|
10
|
-
// last argument defines whether it can terminate a paragraph or not
|
|
11
|
-
const HTML_SEQUENCES = [
|
|
12
|
-
[/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true],
|
|
13
|
-
[/^<!--/, /-->/, true],
|
|
14
|
-
[/^<\?/, /\?>/, true],
|
|
15
|
-
[/^<![A-Z]/, />/, true],
|
|
16
|
-
[/^<!\[CDATA\[/, /\]\]>/, true],
|
|
17
|
-
// MODIFIED HERE: Treat vue reserved tags as block tags
|
|
18
|
-
[
|
|
19
|
-
new RegExp('^</?(' + vueReservedTags_1.vueReservedTags.join('|') + ')(?=(\\s|/?>|$))', 'i'),
|
|
20
|
-
/^$/,
|
|
21
|
-
true,
|
|
22
|
-
],
|
|
23
|
-
// MODIFIED HERE: Treat unknown tags as block tags (custom components), excluding known inline tags
|
|
24
|
-
[
|
|
25
|
-
new RegExp('^</?(?!(' + inlineTags_1.inlineTags.join('|') + ')(?![\\w-]))\\w[\\w-]*[\\s/>]'),
|
|
26
|
-
/^$/,
|
|
27
|
-
true,
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
new RegExp('^</?(' + blockNames.join('|') + ')(?=(\\s|/?>|$))', 'i'),
|
|
31
|
-
/^$/,
|
|
32
|
-
true,
|
|
33
|
-
],
|
|
34
|
-
[new RegExp(htmlRe_1.HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false],
|
|
35
|
-
];
|
|
36
|
-
const htmlBlockRule = (state, startLine, endLine, silent) => {
|
|
37
|
-
let i;
|
|
38
|
-
let nextLine;
|
|
39
|
-
let lineText;
|
|
40
|
-
let pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
41
|
-
let max = state.eMarks[startLine];
|
|
42
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
43
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
if (!state.md.options.html) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
if (state.src.charCodeAt(pos) !== 0x3c /* < */) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
lineText = state.src.slice(pos, max);
|
|
53
|
-
for (i = 0; i < HTML_SEQUENCES.length; i++) {
|
|
54
|
-
if (HTML_SEQUENCES[i][0].test(lineText)) {
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (i === HTML_SEQUENCES.length) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
if (silent) {
|
|
62
|
-
// true if this sequence can be a terminator, false otherwise
|
|
63
|
-
return HTML_SEQUENCES[i][2];
|
|
64
|
-
}
|
|
65
|
-
nextLine = startLine + 1;
|
|
66
|
-
// If we are here - we detected HTML block.
|
|
67
|
-
// Let's roll down till block end.
|
|
68
|
-
if (!HTML_SEQUENCES[i][1].test(lineText)) {
|
|
69
|
-
for (; nextLine < endLine; nextLine++) {
|
|
70
|
-
if (state.sCount[nextLine] < state.blkIndent) {
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
74
|
-
max = state.eMarks[nextLine];
|
|
75
|
-
lineText = state.src.slice(pos, max);
|
|
76
|
-
if (HTML_SEQUENCES[i][1].test(lineText)) {
|
|
77
|
-
if (lineText.length !== 0) {
|
|
78
|
-
nextLine++;
|
|
79
|
-
}
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
state.line = nextLine;
|
|
85
|
-
const token = state.push('html_block', '', 0);
|
|
86
|
-
token.map = [startLine, nextLine];
|
|
87
|
-
token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
|
|
88
|
-
return true;
|
|
89
|
-
};
|
|
90
|
-
exports.htmlBlockRule = htmlBlockRule;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlInlineRule = void 0;
|
|
4
|
-
const htmlRe_1 = require("./htmlRe");
|
|
5
|
-
// Forked and modified from 'markdown-it/lib/rules_inline/html_inline.js'
|
|
6
|
-
const isLetter = (ch) => {
|
|
7
|
-
const lc = ch | 0x20; // to lower case
|
|
8
|
-
return lc >= 0x61 /* a */ && lc <= 0x7a; /* z */
|
|
9
|
-
};
|
|
10
|
-
const htmlInlineRule = (state, silent) => {
|
|
11
|
-
const pos = state.pos;
|
|
12
|
-
if (!state.md.options.html) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
// Check start
|
|
16
|
-
const max = state.posMax;
|
|
17
|
-
if (state.src.charCodeAt(pos) !== 0x3c /* < */ || pos + 2 >= max) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
// Quick fail on second char
|
|
21
|
-
const ch = state.src.charCodeAt(pos + 1);
|
|
22
|
-
if (ch !== 0x21 /* ! */ &&
|
|
23
|
-
ch !== 0x3f /* ? */ &&
|
|
24
|
-
ch !== 0x2f /* / */ &&
|
|
25
|
-
!isLetter(ch)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
// MODIFIED HERE: Tweak the original HTML_TAG_RE
|
|
29
|
-
const match = state.src.slice(pos).match(htmlRe_1.HTML_TAG_RE);
|
|
30
|
-
if (!match) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (!silent) {
|
|
34
|
-
const token = state.push('html_inline', '', 0);
|
|
35
|
-
token.content = state.src.slice(pos, pos + match[0].length);
|
|
36
|
-
}
|
|
37
|
-
state.pos += match[0].length;
|
|
38
|
-
return true;
|
|
39
|
-
};
|
|
40
|
-
exports.htmlInlineRule = htmlInlineRule;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HTML_OPEN_CLOSE_TAG_RE = exports.HTML_TAG_RE = void 0;
|
|
5
|
-
// Forked and modified from 'markdown-it/lib/common/html_re.js'
|
|
6
|
-
// Regexps to match html elements
|
|
7
|
-
// MODIFIED HERE: Support `@` as the first char of attr name
|
|
8
|
-
const attr_name = '[a-zA-Z_:@][a-zA-Z0-9:._-]*';
|
|
9
|
-
const unquoted = '[^"\'=<>`\\x00-\\x20]+';
|
|
10
|
-
const single_quoted = "'[^']*'";
|
|
11
|
-
const double_quoted = '"[^"]*"';
|
|
12
|
-
const attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';
|
|
13
|
-
const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
|
|
14
|
-
const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
|
|
15
|
-
const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
|
|
16
|
-
const comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
|
|
17
|
-
const processing = '<[?][\\s\\S]*?[?]>';
|
|
18
|
-
const declaration = '<![A-Z]+\\s+[^>]*>';
|
|
19
|
-
const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
|
|
20
|
-
exports.HTML_TAG_RE = new RegExp('^(?:' +
|
|
21
|
-
open_tag +
|
|
22
|
-
'|' +
|
|
23
|
-
close_tag +
|
|
24
|
-
'|' +
|
|
25
|
-
comment +
|
|
26
|
-
'|' +
|
|
27
|
-
processing +
|
|
28
|
-
'|' +
|
|
29
|
-
declaration +
|
|
30
|
-
'|' +
|
|
31
|
-
cdata +
|
|
32
|
-
')');
|
|
33
|
-
exports.HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
|
|
@@ -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("./customComponentPlugin"), exports);
|
|
14
|
-
__exportStar(require("./htmlBlockRule"), exports);
|
|
15
|
-
__exportStar(require("./inlineTags"), exports);
|
|
16
|
-
__exportStar(require("./vueReservedTags"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* According to markdown spec, all non-block html tags are treated as "inline"
|
|
3
|
-
* tags (wrapped with <p></p>), including those "unknown" tags
|
|
4
|
-
*
|
|
5
|
-
* Therefore, markdown-it processes "inline" tags and "unknown" tags in the same
|
|
6
|
-
* way, and does not care if a tag is "inline" or "unknown"
|
|
7
|
-
*
|
|
8
|
-
* As we want to take those "unknown" tags as custom components, we should
|
|
9
|
-
* treat them as "block" tags
|
|
10
|
-
*
|
|
11
|
-
* So we have to distinguish between "inline" and "unknown" tags ourselves
|
|
12
|
-
*
|
|
13
|
-
* The inline tags list comes from MDN
|
|
14
|
-
*
|
|
15
|
-
* @see https://spec.commonmark.org/0.29/#raw-html
|
|
16
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
|
|
17
|
-
*/
|
|
18
|
-
export declare const inlineTags: string[];
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inlineTags = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* According to markdown spec, all non-block html tags are treated as "inline"
|
|
6
|
-
* tags (wrapped with <p></p>), including those "unknown" tags
|
|
7
|
-
*
|
|
8
|
-
* Therefore, markdown-it processes "inline" tags and "unknown" tags in the same
|
|
9
|
-
* way, and does not care if a tag is "inline" or "unknown"
|
|
10
|
-
*
|
|
11
|
-
* As we want to take those "unknown" tags as custom components, we should
|
|
12
|
-
* treat them as "block" tags
|
|
13
|
-
*
|
|
14
|
-
* So we have to distinguish between "inline" and "unknown" tags ourselves
|
|
15
|
-
*
|
|
16
|
-
* The inline tags list comes from MDN
|
|
17
|
-
*
|
|
18
|
-
* @see https://spec.commonmark.org/0.29/#raw-html
|
|
19
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
|
|
20
|
-
*/
|
|
21
|
-
exports.inlineTags = [
|
|
22
|
-
'a',
|
|
23
|
-
'abbr',
|
|
24
|
-
'acronym',
|
|
25
|
-
'audio',
|
|
26
|
-
'b',
|
|
27
|
-
'bdi',
|
|
28
|
-
'bdo',
|
|
29
|
-
'big',
|
|
30
|
-
'br',
|
|
31
|
-
'button',
|
|
32
|
-
'canvas',
|
|
33
|
-
'cite',
|
|
34
|
-
'code',
|
|
35
|
-
'data',
|
|
36
|
-
'datalist',
|
|
37
|
-
'del',
|
|
38
|
-
'dfn',
|
|
39
|
-
'em',
|
|
40
|
-
'embed',
|
|
41
|
-
'i',
|
|
42
|
-
/* iframe is treated as HTML blocks in markdown spec */
|
|
43
|
-
// 'iframe',
|
|
44
|
-
'img',
|
|
45
|
-
'input',
|
|
46
|
-
'ins',
|
|
47
|
-
'kbd',
|
|
48
|
-
'label',
|
|
49
|
-
'map',
|
|
50
|
-
'mark',
|
|
51
|
-
'meter',
|
|
52
|
-
'noscript',
|
|
53
|
-
'object',
|
|
54
|
-
'output',
|
|
55
|
-
'picture',
|
|
56
|
-
'progress',
|
|
57
|
-
'q',
|
|
58
|
-
'ruby',
|
|
59
|
-
's',
|
|
60
|
-
'samp',
|
|
61
|
-
'script',
|
|
62
|
-
'select',
|
|
63
|
-
'slot',
|
|
64
|
-
'small',
|
|
65
|
-
'span',
|
|
66
|
-
'strong',
|
|
67
|
-
'sub',
|
|
68
|
-
'sup',
|
|
69
|
-
'svg',
|
|
70
|
-
'template',
|
|
71
|
-
'textarea',
|
|
72
|
-
'time',
|
|
73
|
-
'u',
|
|
74
|
-
'tt',
|
|
75
|
-
'var',
|
|
76
|
-
'video',
|
|
77
|
-
'wbr',
|
|
78
|
-
];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.vueReservedTags = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Vue reserved tags
|
|
6
|
-
*
|
|
7
|
-
* @see https://v3.vuejs.org/api/built-in-components.html
|
|
8
|
-
*/
|
|
9
|
-
exports.vueReservedTags = [
|
|
10
|
-
'template',
|
|
11
|
-
'component',
|
|
12
|
-
'transition',
|
|
13
|
-
'transition-group',
|
|
14
|
-
'keep-alive',
|
|
15
|
-
'slot',
|
|
16
|
-
'teleport',
|
|
17
|
-
];
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PluginWithOptions } from 'markdown-it';
|
|
2
|
-
/**
|
|
3
|
-
* Options for markdown-it-emoji
|
|
4
|
-
*
|
|
5
|
-
* @see https://github.com/markdown-it/markdown-it-emoji
|
|
6
|
-
*/
|
|
7
|
-
export interface EmojiPluginOptions {
|
|
8
|
-
/**
|
|
9
|
-
* rewrite available emoji definitions
|
|
10
|
-
*
|
|
11
|
-
* @example `{ name1: char1, name2: char2, ... }`
|
|
12
|
-
*/
|
|
13
|
-
defs?: Record<string, string>;
|
|
14
|
-
/**
|
|
15
|
-
* disable all emojis except whitelisted
|
|
16
|
-
*/
|
|
17
|
-
enabled?: string[];
|
|
18
|
-
/**
|
|
19
|
-
* rewrite default shortcuts
|
|
20
|
-
*
|
|
21
|
-
* @example `{ "smile": [ ":)", ":-)" ], "laughing": ":D" }`
|
|
22
|
-
*/
|
|
23
|
-
shortcuts?: Record<string, string | string[]>;
|
|
24
|
-
}
|
|
25
|
-
export declare const emojiPlugin: PluginWithOptions<EmojiPluginOptions>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PluginWithOptions } from 'markdown-it';
|
|
2
|
-
export interface ExtractHeadersPluginOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Heading level that going to be extracted to the `env`
|
|
5
|
-
*
|
|
6
|
-
* Should be a subset of markdown-it-anchor's `level` option
|
|
7
|
-
* to ensure the link is existed
|
|
8
|
-
*/
|
|
9
|
-
level?: number[];
|
|
10
|
-
/**
|
|
11
|
-
* A custom slugify function
|
|
12
|
-
*
|
|
13
|
-
* Should use the same slugify function with markdown-it-anchor
|
|
14
|
-
* to ensure the link is matched
|
|
15
|
-
*/
|
|
16
|
-
slugify?: (str: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* A function for formatting headers
|
|
19
|
-
*/
|
|
20
|
-
format?: (str: string) => string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Extracting markdown headers to env
|
|
24
|
-
*
|
|
25
|
-
* Would be used for generating sidebar nav and toc
|
|
26
|
-
*/
|
|
27
|
-
export declare const extractHeadersPlugin: PluginWithOptions<ExtractHeadersPluginOptions>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractHeadersPlugin = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Extracting markdown headers to env
|
|
7
|
-
*
|
|
8
|
-
* Would be used for generating sidebar nav and toc
|
|
9
|
-
*/
|
|
10
|
-
const extractHeadersPlugin = (md, { level = [2, 3], slugify = utils_1.slugify, format, } = {}) => {
|
|
11
|
-
let headers;
|
|
12
|
-
// push the rule to the end of the chain
|
|
13
|
-
// resolve headers from the parsed tokens
|
|
14
|
-
md.core.ruler.push('resolveExtractHeaders', (state) => {
|
|
15
|
-
headers = utils_1.resolveHeadersFromTokens(state.tokens, {
|
|
16
|
-
level,
|
|
17
|
-
allowHtml: false,
|
|
18
|
-
escapeText: false,
|
|
19
|
-
slugify,
|
|
20
|
-
format,
|
|
21
|
-
});
|
|
22
|
-
return true;
|
|
23
|
-
});
|
|
24
|
-
// extract headers to env
|
|
25
|
-
const render = md.render.bind(md);
|
|
26
|
-
md.render = (src, env = {}) => {
|
|
27
|
-
const result = render(src, env);
|
|
28
|
-
env.headers = headers !== null && headers !== void 0 ? headers : [];
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.extractHeadersPlugin = extractHeadersPlugin;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { PluginWithOptions } from 'markdown-it';
|
|
2
|
-
export interface HoistTagsPluginOptions {
|
|
3
|
-
customBlocks?: string[];
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Avoid rendering vue SFC script / style blocks
|
|
7
|
-
*
|
|
8
|
-
* Extract them into env
|
|
9
|
-
*
|
|
10
|
-
* Hoist them to vue SFC root level in following process
|
|
11
|
-
*/
|
|
12
|
-
export declare const hoistTagsPlugin: PluginWithOptions<HoistTagsPluginOptions>;
|