From becf25bd53f5700bdab399c4814160be93b20d5d Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 22 Mar 2019 20:34:49 -1000 Subject: 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 --- lib/render.js | 9 ++++----- 1 file 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) + ')' : '') -- cgit v1.2.3