@vuepress/markdown 2.0.0-rc.13 → 2.0.0-rc.15

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 (2) hide show
  1. package/dist/index.js +14 -14
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -29,8 +29,7 @@ var resolveLink = (link, {
29
29
  relativePathPrefix,
30
30
  strict = false
31
31
  }) => {
32
- if (link.startsWith("data:"))
33
- return link;
32
+ if (link.startsWith("data:")) return link;
34
33
  let resolvedLink = decode(link);
35
34
  const isRelativePath = strict ? (
36
35
  // in strict mode, only link that starts with `./` or `../` is considered as relative path
@@ -70,7 +69,7 @@ var assetsPlugin = (md, {
70
69
  };
71
70
  const createHtmlRule = (rawHtmlRule) => (tokens, idx, options, env, self) => {
72
71
  tokens[idx].content = tokens[idx].content.replace(
73
- /(<img\b.*?src=)(['"])([^\2]*?)\2/gs,
72
+ /(<img\b.*?src=)(['"])(.*?)\2/gs,
74
73
  (_, prefix, quote, src) => `${prefix}${quote}${resolveLink(src.trim(), {
75
74
  env,
76
75
  absolutePathPrependBase,
@@ -78,7 +77,7 @@ var assetsPlugin = (md, {
78
77
  strict: true
79
78
  })}${quote}`
80
79
  ).replace(
81
- /(<img\b.*?srcset=)(['"])([^\2]*?)\2/gs,
80
+ /(<img\b.*?srcset=)(['"])(.*?)\2/gs,
82
81
  (_, prefix, quote, srcset) => `${prefix}${quote}${srcset.split(",").map(
83
82
  (item) => item.trim().replace(
84
83
  /^([^ ]*?)([ \n].*)?$/,
@@ -106,30 +105,31 @@ import { full as emojiPlugin } from "markdown-it-emoji";
106
105
  import { path as path2 } from "@vuepress/utils";
107
106
  var MIN_LENGTH = 9;
108
107
  var START_CODES = [64, 91, 99, 111, 100, 101];
109
- var SYNTAX_RE = /^@\[code(?:{(?:(\d+)?-(\d+)?)})?(?: ([^\]]+))?\]\(([^)]*)\)/;
108
+ var SYNTAX_RE = /^@\[code(?:{(?:(?:(?<lineStart>\d+)?-(?<lineEnd>\d+)?)|(?<lineSingle>\d+))})?(?: (?<info>[^\]]+))?\]\((?<importPath>[^)]*)\)/;
109
+ var parseLineNumber = (line) => line ? Number.parseInt(line, 10) : void 0;
110
110
  var createImportCodeBlockRule = ({ handleImportPath = (str) => str }) => (state, startLine, endLine, silent) => {
111
111
  if (state.sCount[startLine] - state.blkIndent >= 4) {
112
112
  return false;
113
113
  }
114
114
  const pos = state.bMarks[startLine] + state.tShift[startLine];
115
115
  const max = state.eMarks[startLine];
116
- if (pos + MIN_LENGTH > max)
117
- return false;
116
+ if (pos + MIN_LENGTH > max) return false;
118
117
  for (let i = 0; i < START_CODES.length; i += 1) {
119
118
  if (state.src.charCodeAt(pos + i) !== START_CODES[i]) {
120
119
  return false;
121
120
  }
122
121
  }
123
122
  const match = state.src.slice(pos, max).match(SYNTAX_RE);
124
- if (!match)
125
- return false;
126
- if (silent)
127
- return true;
128
- const [, lineStart, lineEnd, info, importPath] = match;
123
+ if (!match?.groups) return false;
124
+ if (silent) return true;
125
+ const { info, importPath } = match.groups;
126
+ const lineSingle = parseLineNumber(match.groups.lineSingle);
127
+ const lineStart = lineSingle ?? parseLineNumber(match.groups.lineStart) ?? 0;
128
+ const lineEnd = lineSingle ?? parseLineNumber(match.groups.lineEnd);
129
129
  const meta = {
130
130
  importPath: handleImportPath(importPath),
131
- lineStart: lineStart ? Number.parseInt(lineStart, 10) : 0,
132
- lineEnd: lineEnd ? Number.parseInt(lineEnd, 10) : void 0
131
+ lineStart,
132
+ lineEnd
133
133
  };
134
134
  const token = state.push("import_code", "code", 0);
135
135
  token.info = info ?? path2.extname(meta.importPath).slice(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/markdown",
3
- "version": "2.0.0-rc.13",
3
+ "version": "2.0.0-rc.15",
4
4
  "description": "Markdown package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -35,14 +35,14 @@
35
35
  "@mdit-vue/plugin-toc": "^2.1.3",
36
36
  "@mdit-vue/shared": "^2.1.3",
37
37
  "@mdit-vue/types": "^2.1.0",
38
- "@types/markdown-it": "^14.1.1",
38
+ "@types/markdown-it": "^14.1.2",
39
39
  "@types/markdown-it-emoji": "^3.0.1",
40
40
  "markdown-it": "^14.1.0",
41
41
  "markdown-it-anchor": "^9.0.1",
42
42
  "markdown-it-emoji": "^3.0.0",
43
43
  "mdurl": "^2.0.0",
44
- "@vuepress/shared": "2.0.0-rc.13",
45
- "@vuepress/utils": "2.0.0-rc.13"
44
+ "@vuepress/utils": "2.0.0-rc.15",
45
+ "@vuepress/shared": "2.0.0-rc.15"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/mdurl": "^2.0.0"