@vuepress/markdown 2.0.0-beta.43 → 2.0.0-beta.46
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.
|
@@ -21,7 +21,16 @@ const assetsPlugin = (md, { relativePathPrefix = '@source' } = {}) => {
|
|
|
21
21
|
// wrap raw html renderer rule
|
|
22
22
|
const createHtmlRule = (rawHtmlRule) => (tokens, idx, options, env, self) => {
|
|
23
23
|
// replace the original link with resolved link
|
|
24
|
-
tokens[idx].content = tokens[idx].content
|
|
24
|
+
tokens[idx].content = tokens[idx].content
|
|
25
|
+
// handle src
|
|
26
|
+
.replace(/(<img\b.*?src=")([^"]*)(")/gs, (_, prefix, src, suffix) => `${prefix}${(0, resolveLink_1.resolveLink)(src.trim(), relativePathPrefix, env)}${suffix}`)
|
|
27
|
+
// handle srcset
|
|
28
|
+
.replace(/(<img\b.*?srcset=")([^"]*)(")/gs, (_, prefix, srcset, suffix) => `${prefix}${srcset
|
|
29
|
+
.split(',')
|
|
30
|
+
.map((item) => item
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/^([^ ]*?)([ \n].*)?$/, (_, url, descriptor = '') => `${(0, resolveLink_1.resolveLink)(url.trim(), relativePathPrefix, env)}${descriptor.replace(/[ \n]+/g, ' ').trimEnd()}`))
|
|
33
|
+
.join(', ')}${suffix}`);
|
|
25
34
|
return rawHtmlRule(tokens, idx, options, env, self);
|
|
26
35
|
};
|
|
27
36
|
const rawHtmlBlockRule = md.renderer.rules.html_block;
|
|
@@ -60,7 +60,7 @@ const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper
|
|
|
60
60
|
if (useLineNumbers) {
|
|
61
61
|
// generate line numbers code
|
|
62
62
|
const lineNumbersCode = lines
|
|
63
|
-
.map((
|
|
63
|
+
.map(() => `<div class="line-number"></div>`)
|
|
64
64
|
.join('');
|
|
65
65
|
result = `${result}<div class="line-numbers" aria-hidden="true">${lineNumbersCode}</div>`;
|
|
66
66
|
}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolvePaths = void 0;
|
|
4
|
+
const shared_1 = require("@vuepress/shared");
|
|
4
5
|
const utils_1 = require("@vuepress/utils");
|
|
5
6
|
/**
|
|
6
7
|
* Resolve relative and absolute paths according to the `base` and `filePathRelative`
|
|
7
8
|
*/
|
|
8
9
|
const resolvePaths = (rawPath, base, filePathRelative) => {
|
|
9
|
-
let relativePath;
|
|
10
10
|
let absolutePath;
|
|
11
|
+
let relativePath;
|
|
11
12
|
if (rawPath.startsWith('/')) {
|
|
12
13
|
// if raw path is absolute
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
if (rawPath.endsWith('.md')) {
|
|
15
|
+
// if raw path is a link to markdown file
|
|
16
|
+
// prepend `base` to the link
|
|
17
|
+
absolutePath = utils_1.path.join(base, rawPath);
|
|
18
|
+
relativePath = (0, shared_1.removeLeadingSlash)(rawPath);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// if raw path is a link to other kind of file
|
|
22
|
+
// keep the link as is
|
|
23
|
+
absolutePath = rawPath;
|
|
24
|
+
relativePath = utils_1.path.relative(base, absolutePath);
|
|
25
|
+
}
|
|
15
26
|
}
|
|
16
27
|
else {
|
|
17
28
|
// if raw path is relative
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/markdown",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.46",
|
|
4
4
|
"description": "Markdown package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@types/markdown-it": "^12.2.3",
|
|
26
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
27
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
28
|
-
"markdown-it": "^13.0.
|
|
29
|
-
"markdown-it-anchor": "^8.4
|
|
30
|
-
"markdown-it-emoji": "^2.0.
|
|
26
|
+
"@vuepress/shared": "2.0.0-beta.46",
|
|
27
|
+
"@vuepress/utils": "2.0.0-beta.46",
|
|
28
|
+
"markdown-it": "^13.0.1",
|
|
29
|
+
"markdown-it-anchor": "^8.6.4",
|
|
30
|
+
"markdown-it-emoji": "^2.0.2",
|
|
31
31
|
"mdurl": "^1.0.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|