fix(render): fix render link
This commit is contained in:
parent
38ea660b78
commit
a866744c45
1 changed files with 2 additions and 3 deletions
|
|
@ -43,10 +43,9 @@ export function init () {
|
||||||
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
||||||
}
|
}
|
||||||
renderer.link = function (href, title, text) {
|
renderer.link = function (href, title, text) {
|
||||||
if (!/[:|\/+]/.test(href)) {
|
if (!/:|(\/{2})/.test(href)) {
|
||||||
href = `#/${href}`.replace(/\/+/g, '/')
|
href = `#/${href}`.replace(/\/+/g, '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<a href="${href}" title="${title || ''}">${text}</a>`
|
return `<a href="${href}" title="${title || ''}">${text}</a>`
|
||||||
}
|
}
|
||||||
renderer.paragraph = function (text) {
|
renderer.paragraph = function (text) {
|
||||||
|
|
@ -58,7 +57,7 @@ export function init () {
|
||||||
return `<p>${text}</p>`
|
return `<p>${text}</p>`
|
||||||
}
|
}
|
||||||
renderer.image = function (href, title, text) {
|
renderer.image = function (href, title, text) {
|
||||||
const url = /[:|\/+]/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/')
|
const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/')
|
||||||
const titleHTML = title ? ` title="${title}"` : ''
|
const titleHTML = title ? ` title="${title}"` : ''
|
||||||
|
|
||||||
return `<img src="${url}" alt="${text}"${titleHTML} />`
|
return `<img src="${url}" alt="${text}"${titleHTML} />`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue