aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-16 08:11:28 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-16 08:11:41 -1000
commit36dd4c128fa2b5b789542cb0a3f2b16231980fb4 (patch)
tree9c0d98a55a28e3a813ecfcb700ed64b54bfbccc7
parentf8b516671c8a45fb1453fd20d42d692f8040d7a5 (diff)
downloadpatchfoo-36dd4c128fa2b5b789542cb0a3f2b16231980fb4.tar.gz
patchfoo-36dd4c128fa2b5b789542cb0a3f2b16231980fb4.zip
Use hyperscript to generate markdown link html
-rw-r--r--lib/render.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/render.js b/lib/render.js
index 1cd92e6..74b4f4f 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -37,13 +37,12 @@ MdRenderer.prototype.image = function (ref, title, text) {
MdRenderer.prototype.link = function(href, title, text) {
href = this.urltransform(href)
var name = href && /^\/(&|%26)/.test(href) && (title || text)
- return '<a'
- + (href !== false
- ? ' href="' + href + '"'
- : ' class="bad"')
- + (title ? ' title="' + title + '"' : '')
- + (name ? ' download="' + encodeURIComponent(name) + '"' : '')
- + '>' + text + '</a>'
+ return h('a', {
+ class: href === false ? 'bad' : undefined,
+ href: href !== false ? href : undefined,
+ title: title || undefined,
+ download: name ? encodeURIComponent(name) : undefined
+ }, text).outerHTML
};