UNPKG

marked-xhtml

Version:
38 lines (32 loc) 1.08 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markedXhtml = {})); })(this, (function (exports) { 'use strict'; function markedXhtml() { // extension code here return { useNewRenderer: true, renderer: { hr(...args) { return addSlash(this, 'hr', ...args); }, br(...args) { return addSlash(this, 'br', ...args); }, image(...args) { return addSlash(this, 'image', ...args); }, checkbox(...args) { return addSlash(this, 'checkbox', ...args); }, }, }; } function addSlash(renderer, name, ...args) { const html = renderer.constructor.prototype[name].call(renderer, ...args); // add slash before last `>` return html.replace(/>[^>]*$/, '/$&'); } exports.markedXhtml = markedXhtml; }));