diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-02-04 16:55:08 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-02-13 09:38:46 -1000 |
commit | 1e17aa3e9da47309ccf008004bd9dff9d15ef4da (patch) | |
tree | 9ba79cb4c4f5b62f67119e551d7e0d1d33119894 /lib | |
parent | 3c4896aafaf3b024a1d74c19cc9b0f393a3f8f50 (diff) | |
download | patchfoo-1e17aa3e9da47309ccf008004bd9dff9d15ef4da.tar.gz patchfoo-1e17aa3e9da47309ccf008004bd9dff9d15ef4da.zip |
Linkify markdown blob links
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/render.js b/lib/render.js index 0e2f95f..c0f3890 100644 --- a/lib/render.js +++ b/lib/render.js @@ -64,6 +64,15 @@ MdRenderer.prototype.link = function (ref, title, text) { var html = a.outerHTML // href is already html-escaped if (hrefToken) html = html.replace(hrefToken, href) + + var link = this.render._mentionsByLink[ref] + if (link && link.type === 'text/x-markdown') { + html += h('sup', ' [', h('a', { + href: this.render.toUrl('/markdown/' + encodeURIComponent(ref)), + title: 'view rendered markdown' + }, 'md'), ']').outerHTML + } + return html } @@ -158,7 +167,7 @@ Render.prototype.markdown = function (text, mentions) { if (!link) return else if (link.emoji) mentionsObj[':' + link.name + ':'] = link - else if (link.name) + else if (link.name && link.link && link.link[0] === '@') mentionsObj['@' + link.name] = link.link else if (link.host === 'http://localhost:7777') mentionsObj[link.href] = link.link |