From 1e17aa3e9da47309ccf008004bd9dff9d15ef4da Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 4 Feb 2019 16:55:08 -1000 Subject: Linkify markdown blob links --- lib/render.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3