Skip to content

Commit a4c9c84

Browse files
authored
Merge pull request #1602 from UziTech/render-inline-html
send inline html to renderer
2 parents a20e2f7 + 4956bd3 commit a4c9c84

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/InlineLexer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ module.exports = class InlineLexer {
8282
}
8383

8484
src = src.substring(cap[0].length);
85-
out += this.options.sanitize
86-
? this.options.sanitizer
85+
out += this.renderer.html(this.options.sanitize
86+
? (this.options.sanitizer
8787
? this.options.sanitizer(cap[0])
88-
: escape(cap[0])
89-
: cap[0];
88+
: escape(cap[0]))
89+
: cap[0]);
9090
continue;
9191
}
9292

test/unit/marked-spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,14 @@ describe('changeDefaults', () => {
8080
expect(require('../../src/defaults').defaults.test).toBe(true);
8181
});
8282
});
83+
84+
describe('inlineLexer', () => {
85+
it('should send html to renderer.html', () => {
86+
const renderer = new marked.Renderer();
87+
spyOn(renderer, 'html').and.callThrough();
88+
const md = 'HTML Image: <img alt="MY IMAGE" src="example.png" />';
89+
marked(md, { renderer });
90+
91+
expect(renderer.html).toHaveBeenCalledWith('<img alt="MY IMAGE" src="example.png" />');
92+
});
93+
});

0 commit comments

Comments
 (0)