aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-03-22 20:34:49 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-03-22 20:36:11 -1000
commitbecf25bd53f5700bdab399c4814160be93b20d5d (patch)
treea195c674225a92cf599af9eaa68af9e2e79c3b50
parent36a30d07b0d94709cac2893f718449c34a55d883 (diff)
downloadpatchfoo-becf25bd53f5700bdab399c4814160be93b20d5d.tar.gz
patchfoo-becf25bd53f5700bdab399c4814160be93b20d5d.zip
Show audio/video alt text better
- Putting the alt text inside the audio/video tag makes it show up in dillo and w3m. - Remove redundant audio:/video: prefix
-rw-r--r--lib/render.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/render.js b/lib/render.js
index c0f3890..32be2ff 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -31,14 +31,12 @@ MdRenderer.prototype.image = function (ref, title, text) {
return (/^video:/.test(text) ? h('video', {
controls: 'controls',
src: this.render.toUrl(ref),
- alt: alt,
title: u.unescapeHTML(title) || undefined
- }) : /^audio:/.test(text) ? h('audio', {
+ }, '\n' + alt) : /^audio:/.test(text) ? h('audio', {
controls: 'controls',
src: this.render.toUrl(ref),
- alt: alt,
title: u.unescapeHTML(title) || undefined
- }) : h('img', {
+ }, '\n' + alt) : h('img', {
src: this.render.imageUrl(ref),
alt: alt,
title: u.unescapeHTML(title) || undefined
@@ -190,7 +188,8 @@ Render.prototype.imageUrl = function (ref) {
Render.prototype.getImageAlt = function (id, fallback) {
var link = this._mentionsByLink[id]
if (!link) return fallback
- var name = u.unescapeHTML(link.name || fallback)
+ var name = String(u.unescapeHTML(link.name || fallback))
+ .replace(/^(video|audio):/, '')
return name
+ (link.type && !/\.\S+$/.test(name) ? ' [' + link.type + ']' : '')
+ (link.size != null ? ' (' + this.formatSize(link.size) + ')' : '')