Skip to content

Commit

Permalink
Merge pull request #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 authored Feb 13, 2020
2 parents a20e2f7 + 4956bd3 commit a4c9c84
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" />');
});
});

1 comment on commit a4c9c84

@vercel
Copy link

@vercel vercel bot commented on a4c9c84 Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.