@vuepress/markdown 2.0.0-beta.45 → 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.replace(/(<img\b.*?src=")([^"]*)(")/gs, (_, prefix, link, suffix) => `${prefix}${(0, resolveLink_1.resolveLink)(link, relativePathPrefix, env)}${suffix}`);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/markdown",
3
- "version": "2.0.0-beta.45",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "Markdown package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -23,10 +23,10 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@types/markdown-it": "^12.2.3",
26
- "@vuepress/shared": "2.0.0-beta.45",
27
- "@vuepress/utils": "2.0.0-beta.45",
26
+ "@vuepress/shared": "2.0.0-beta.46",
27
+ "@vuepress/utils": "2.0.0-beta.46",
28
28
  "markdown-it": "^13.0.1",
29
- "markdown-it-anchor": "^8.6.3",
29
+ "markdown-it-anchor": "^8.6.4",
30
30
  "markdown-it-emoji": "^2.0.2",
31
31
  "mdurl": "^1.0.1"
32
32
  },