@vuepress/markdown 2.0.0-beta.61 → 2.0.0-beta.62
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.js +16 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -28,9 +28,16 @@ import { default as anchorPlugin } from "markdown-it-anchor";
|
|
|
28
28
|
// src/plugins/assetsPlugin/resolveLink.ts
|
|
29
29
|
import { path } from "@vuepress/utils";
|
|
30
30
|
import { decode } from "mdurl";
|
|
31
|
-
var resolveLink = (link, relativePathPrefix, env) => {
|
|
31
|
+
var resolveLink = (link, relativePathPrefix, env, strict = false) => {
|
|
32
32
|
let resolvedLink = decode(link);
|
|
33
|
-
|
|
33
|
+
const isRelativePath = strict ? (
|
|
34
|
+
// in strict mode, only link that starts with `./` or `../` is considered as relative path
|
|
35
|
+
/^\.{1,2}\//.test(link)
|
|
36
|
+
) : (
|
|
37
|
+
// in non-strict mode, link that does not start with `/` and does not have protocol is considered as relative path
|
|
38
|
+
!link.startsWith("/") && !/[A-z]+:\/\//.test(link)
|
|
39
|
+
);
|
|
40
|
+
if (isRelativePath && env.filePathRelative) {
|
|
34
41
|
resolvedLink = `${relativePathPrefix}/${path.join(
|
|
35
42
|
path.dirname(env.filePathRelative),
|
|
36
43
|
resolvedLink
|
|
@@ -56,7 +63,8 @@ var assetsPlugin = (md, { relativePathPrefix = "@source" } = {}) => {
|
|
|
56
63
|
(_, prefix, quote, src) => `${prefix}${quote}${resolveLink(
|
|
57
64
|
src.trim(),
|
|
58
65
|
relativePathPrefix,
|
|
59
|
-
env
|
|
66
|
+
env,
|
|
67
|
+
true
|
|
60
68
|
)}${quote}`
|
|
61
69
|
).replace(
|
|
62
70
|
/(<img\b.*?srcset=)(['"])([^\2]*?)\2/gs,
|
|
@@ -66,7 +74,8 @@ var assetsPlugin = (md, { relativePathPrefix = "@source" } = {}) => {
|
|
|
66
74
|
(_2, url, descriptor = "") => `${resolveLink(
|
|
67
75
|
url.trim(),
|
|
68
76
|
relativePathPrefix,
|
|
69
|
-
env
|
|
77
|
+
env,
|
|
78
|
+
true
|
|
70
79
|
)}${descriptor.replace(/[ \n]+/g, " ").trimEnd()}`
|
|
71
80
|
)
|
|
72
81
|
).join(", ")}${quote}`
|
|
@@ -358,8 +367,8 @@ var importCodePlugin = (md, options = {}) => {
|
|
|
358
367
|
const { importFilePath, importCode } = resolveImportCode(token.meta, env);
|
|
359
368
|
token.content = importCode;
|
|
360
369
|
if (importFilePath) {
|
|
361
|
-
|
|
362
|
-
importedFiles.push(importFilePath);
|
|
370
|
+
;
|
|
371
|
+
(env.importedFiles ?? (env.importedFiles = [])).push(importFilePath);
|
|
363
372
|
}
|
|
364
373
|
return md.renderer.rules.fence(tokens, idx, options2, env, slf);
|
|
365
374
|
};
|
|
@@ -445,8 +454,7 @@ var linksPlugin = (md, options = {}) => {
|
|
|
445
454
|
hasOpenInternalLink = true;
|
|
446
455
|
}
|
|
447
456
|
hrefAttr[1] = `${normalizedPath}${rawHash}`;
|
|
448
|
-
|
|
449
|
-
links.push({
|
|
457
|
+
(env.links ?? (env.links = [])).push({
|
|
450
458
|
raw: hrefLink,
|
|
451
459
|
relative: relativePath,
|
|
452
460
|
absolute: absolutePath
|
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.62",
|
|
4
4
|
"description": "Markdown package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"markdown-it-anchor": "^8.6.7",
|
|
42
42
|
"markdown-it-emoji": "^2.0.2",
|
|
43
43
|
"mdurl": "^1.0.1",
|
|
44
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
45
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
44
|
+
"@vuepress/shared": "2.0.0-beta.62",
|
|
45
|
+
"@vuepress/utils": "2.0.0-beta.62"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/mdurl": "^1.0.2"
|