From 4d4a3f72892ee50207e50e447a03f61e5c267867 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 10 Nov 2014 10:52:11 -0800 Subject: Allow images to contain images. --- js/lib/html-renderer.js | 4 +++- js/lib/inlines.js | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'js/lib') diff --git a/js/lib/html-renderer.js b/js/lib/html-renderer.js index a676e3a..6eb96bc 100644 --- a/js/lib/html-renderer.js +++ b/js/lib/html-renderer.js @@ -43,7 +43,9 @@ var renderInline = function(inline) { return inTags('a', attrs, this.renderInlines(inline.label)); case 'Image': attrs = [['src', this.escape(inline.destination, true)], - ['alt', this.renderInlines(inline.label).replace(/\<[^>]*\>/g,'')]]; + ['alt', this.renderInlines(inline.label). + replace(/\<[^>]*alt="([^"]*)"[^>]*\>/g, '$1'). + replace(/\<[^>]*\>/g,'')]]; if (inline.title) { attrs.push(['title', this.escape(inline.title, true)]); } diff --git a/js/lib/inlines.js b/js/lib/inlines.js index cd60591..1f4d194 100644 --- a/js/lib/inlines.js +++ b/js/lib/inlines.js @@ -595,21 +595,23 @@ var parseCloseBracket = function(inlines) { } // processEmphasis will remove this and later delimiters. - // Now we also remove earlier ones of the same kind (so, - // no links in links, no images in images). - opener = this.delimiters; - closer_above = null; - while (opener !== null) { - if (opener.cc === (is_image ? C_BANG : C_OPEN_BRACKET)) { - if (closer_above) { - closer_above.previous = opener.previous; - } else { - this.delimiters = opener.previous; - } + // Now, for a link, we also remove earlier link openers. + // (no links in links) + if (!is_image) { + opener = this.delimiters; + closer_above = null; + while (opener !== null) { + if (opener.cc === C_OPEN_BRACKET) { + if (closer_above) { + closer_above.previous = opener.previous; + } else { + this.delimiters = opener.previous; + } } else { - closer_above = opener; + closer_above = opener; } opener = opener.previous; + } } inlines.push({t: is_image ? 'Image' : 'Link', -- cgit v1.2.3