marked-bidi
Version:
marked bidirectional text support
28 lines (22 loc) • 681 B
JavaScript
;
var marked = require('marked');
function index() {
return {
useNewRenderer: true,
renderer: {
heading(...args) {
const html = marked.marked.Renderer.prototype.heading.call(this, ...args);
return html.replace(/^<(h\d)/, '<$1 dir="auto"');
},
list(...args) {
const html = marked.marked.Renderer.prototype.list.call(this, ...args);
return html.replace(/^<(ol|ul)/, '<$1 dir="auto"');
},
paragraph(...args) {
const html = marked.marked.Renderer.prototype.paragraph.call(this, ...args);
return html.replace(/^<p/, '<p dir="auto"');
},
},
};
}
module.exports = index;