From f2344b5cbc40416c40cc7bbb6553654fa5a217e9 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Mon, 4 Jan 2016 17:21:06 +0300 Subject: [PATCH] Add `content` property to image token close https://github.com/markdown-it/markdown-it/issues/184 --- lib/rules_inline/image.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rules_inline/image.js b/lib/rules_inline/image.js index 167b861..e189d51 100644 --- a/lib/rules_inline/image.js +++ b/lib/rules_inline/image.js @@ -12,6 +12,7 @@ var isSpace = require('../common/utils').isSpace; module.exports = function image(state, silent) { var attrs, code, + content, label, labelEnd, labelStart, @@ -136,8 +137,10 @@ module.exports = function image(state, silent) { // so all that's left to do is to call tokenizer. // if (!silent) { + content = state.src.slice(labelStart, labelEnd); + state.md.inline.parse( - state.src.slice(labelStart, labelEnd), + content, state.md, state.env, tokens = [] @@ -146,6 +149,8 @@ module.exports = function image(state, silent) { token = state.push('image', 'img', 0); token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ]; token.children = tokens; + token.content = content; + if (title) { attrs.push([ 'title', title ]); }