From 5c782b79a38d0ec6a29c019a55ef66a1b6000acf Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 8 Apr 2019 09:36:53 -1000 Subject: Add markdown link for unnamed markdown blob mentions --- lib/render.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/render.js b/lib/render.js index 69666a5..055d3d2 100644 --- a/lib/render.js +++ b/lib/render.js @@ -77,12 +77,21 @@ MdRenderer.prototype.link = function (ref, title, text) { MdRenderer.prototype.mention = function (preceding, id) { var href = this.urltransform(id) var myName = this.render.app.getNameSync(id) - if (id.length > 50) id = id.slice(0, 8) + '…' - return (preceding||'') + h('a', { + var html = (preceding||'') + h('a', { class: href === false ? 'bad' : undefined, href: href !== false ? href : undefined, title: myName || undefined, - }, id).outerHTML + }, id.length > 50 ? id.slice(0, 8) + '…' : id).outerHTML + + var link = this.render._mentionsByLink[id] + if (link && link.type === 'text/x-markdown') { + html += h('sup', ' [', h('a', { + href: this.render.toUrl('/markdown/' + encodeURIComponent(id)), + title: 'view rendered markdown' + }, 'md'), ']').outerHTML + } + + return html } MdRenderer.prototype.code = function (code, lang, escaped) { -- cgit v1.2.3