Skip to content

Commit

Permalink
Merge pull request markedjs#1602 from UziTech/render-inline-html
Browse files Browse the repository at this point in the history
send inline html to renderer
  • Loading branch information
joshbruce committed Feb 13, 2020
2 parents 75ec5ab + a6787ce commit 60ea17c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/InlineLexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ module.exports = class InlineLexer {
}

src = src.substring(cap[0].length);
out += this.options.sanitize
? this.options.sanitizer
out += this.renderer.html(this.options.sanitize
? (this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0];
: escape(cap[0]))
: cap[0]);
continue;
}

Expand Down
11 changes: 11 additions & 0 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@ describe('changeDefaults', () => {
expect(require('../../src/defaults').defaults.test).toBe(true);
});
});

describe('inlineLexer', () => {
it('should send html to renderer.html', () => {
const renderer = new marked.Renderer();
spyOn(renderer, 'html').and.callThrough();
const md = 'HTML Image: <img alt="MY IMAGE" src="example.png" />';
marked(md, { renderer });

expect(renderer.html).toHaveBeenCalledWith('<img alt="MY IMAGE" src="example.png" />');
});
});

0 comments on commit 60ea17c

Please sign in to comment.