aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js18
-rw-r--r--lib/serve.js2
2 files changed, 19 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
diff --git a/lib/serve.js b/lib/serve.js
index d739659..5386cbc 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -486,6 +486,8 @@ Serve.prototype.blob = function (id) {
else return self.respond(500, err.message || err)
}
if (!has) return self.respond(404, 'Not found')
+ if (self.query.name) self.res.setHeader('Content-Disposition',
+ 'inline; filename='+encodeURIComponent(self.query.name))
pull(
blobs.get(id),
pull.map(Buffer),