aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-20 22:25:35 -0500
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-20 22:25:35 -0500
commita48b542363b582519083db1537bef7c776efa174 (patch)
tree99d0a8a99d3bca63a4788c2a5f1d18c3b70897ad /lib/render.js
parent206f10486251d32a41f31419de77ce12033d5ba5 (diff)
downloadpatchfoo-a48b542363b582519083db1537bef7c776efa174.tar.gz
patchfoo-a48b542363b582519083db1537bef7c776efa174.zip
Set suggested filename for blob download
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/render.js b/lib/render.js
index 16bd7bc..fa4359c 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -24,13 +24,29 @@ MdRenderer.prototype.urltransform = function (href) {
}
MdRenderer.prototype.image = function (href, title, text) {
+ href = this.render.imageUrl(href)
+ var name = title || text
+ if (name) href += '?name=' + encodeURIComponent(name)
return h('img', {
- src: this.render.imageUrl(href),
+ src: href,
alt: text,
title: title || undefined
}).outerHTML
}
+MdRenderer.prototype.link = function(href, title, text) {
+ href = this.urltransform(href)
+ var name = href && /^\/(&|%26)/.test(href) && (title || text)
+ if (name) href += '?name=' + encodeURIComponent(name)
+ return '<a'
+ + (href !== false
+ ? ' href="' + href + '"'
+ : ' class="bad"')
+ + (title ? ' title="' + title + '"' : '')
+ + '>' + text + '</a>'
+};
+
+
function lexerRenderEmoji(emoji) {
var el = this.renderer.render.emoji(emoji)
return el && el.outerHTML || el