aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-04-08 09:36:53 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-04-08 09:36:53 -1000
commit5c782b79a38d0ec6a29c019a55ef66a1b6000acf (patch)
tree3917eb6c535daeab9a53278de5581fb6c62e5380
parent3fbee1e4502f377cce08d67b443aab5f950f2c8d (diff)
downloadpatchfoo-5c782b79a38d0ec6a29c019a55ef66a1b6000acf.tar.gz
patchfoo-5c782b79a38d0ec6a29c019a55ef66a1b6000acf.zip
Add markdown link for unnamed markdown blob mentions
-rw-r--r--lib/render.js15
1 files 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) {