Browse Source

Add `content` property to image token

close https://github.com/markdown-it/markdown-it/issues/184
pull/186/head
Alex Kocharin 9 years ago
parent
commit
f2344b5cbc
  1. 7
      lib/rules_inline/image.js

7
lib/rules_inline/image.js

@ -12,6 +12,7 @@ var isSpace = require('../common/utils').isSpace;
module.exports = function image(state, silent) { module.exports = function image(state, silent) {
var attrs, var attrs,
code, code,
content,
label, label,
labelEnd, labelEnd,
labelStart, labelStart,
@ -136,8 +137,10 @@ module.exports = function image(state, silent) {
// so all that's left to do is to call tokenizer. // so all that's left to do is to call tokenizer.
// //
if (!silent) { if (!silent) {
content = state.src.slice(labelStart, labelEnd);
state.md.inline.parse( state.md.inline.parse(
state.src.slice(labelStart, labelEnd), content,
state.md, state.md,
state.env, state.env,
tokens = [] tokens = []
@ -146,6 +149,8 @@ module.exports = function image(state, silent) {
token = state.push('image', 'img', 0); token = state.push('image', 'img', 0);
token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ]; token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
token.children = tokens; token.children = tokens;
token.content = content;
if (title) { if (title) {
attrs.push([ 'title', title ]); attrs.push([ 'title', title ]);
} }

Loading…
Cancel
Save