Skip to content

Commit

Permalink
fix(render): fix render link
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Feb 12, 2017
1 parent 38ea660 commit a866744
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export function init () {
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
}
renderer.link = function (href, title, text) {
if (!/[:|\/+]/.test(href)) {
if (!/:|(\/{2})/.test(href)) {
href = `#/${href}`.replace(/\/+/g, '/')
}

return `<a href="${href}" title="${title || ''}">${text}</a>`
}
renderer.paragraph = function (text) {
Expand All @@ -58,7 +57,7 @@ export function init () {
return `<p>${text}</p>`
}
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}"` : ''

return `<img src="${url}" alt="${text}"${titleHTML} />`
Expand Down

0 comments on commit a866744

Please sign in to comment.