@vuepress/markdown
Advanced tools
Comparing version 1.0.0-alpha.38 to 1.0.0-alpha.39
@@ -5,2 +5,4 @@ // markdown-it plugin for: | ||
const url = require('url') | ||
const indexRE = /(^|.*\/)(index|readme).md(#?.*)$/i | ||
@@ -13,2 +15,3 @@ | ||
md.renderer.rules.link_open = (tokens, idx, options, env, self) => { | ||
const { relPath } = env | ||
const token = tokens[idx] | ||
@@ -30,3 +33,3 @@ const hrefIndex = token.attrIndex('href') | ||
hasOpenRouterLink = true | ||
tokens[idx] = toRouterLink(token, link) | ||
tokens[idx] = toRouterLink(token, link, relPath) | ||
} | ||
@@ -37,3 +40,3 @@ } | ||
function toRouterLink (token, link) { | ||
function toRouterLink (token, link, relPath) { | ||
link[0] = 'to' | ||
@@ -46,2 +49,9 @@ let to = link[1] | ||
// relative path usage. | ||
if (!to.startsWith('/')) { | ||
to = relPath | ||
? url.resolve('/' + relPath, to) | ||
: ensureBeginningDotSlash(to) | ||
} | ||
const indexMatch = to.match(indexRE) | ||
@@ -57,7 +67,2 @@ if (indexMatch) { | ||
// relative path usage. | ||
if (!to.startsWith('/')) { | ||
to = ensureBeginningDotSlash(to) | ||
} | ||
// markdown-it encodes the uri | ||
@@ -64,0 +69,0 @@ link[1] = decodeURI(to) |
{ | ||
"name": "@vuepress/markdown", | ||
"version": "1.0.0-alpha.38", | ||
"version": "1.0.0-alpha.39", | ||
"description": "markdown for vuepress", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vuepress/shared-utils": "^1.0.0-alpha.38", | ||
"@vuepress/shared-utils": "^1.0.0-alpha.39", | ||
"markdown-it": "^8.4.1", | ||
@@ -44,3 +44,3 @@ "markdown-it-anchor": "^5.0.2", | ||
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/markdown#readme", | ||
"gitHead": "2e0da50150850bf27c95791c3cac4c05275a703d" | ||
"gitHead": "170cf6e4b9d826c0692a9c14002d7b0dd5dd1cbe" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20400
515