ts-markdown
Version:
An extensible TypeScript markdown generator that takes JSON and creates a markdown document.
35 lines (34 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sup = exports.supRenderer = void 0;
const rendering_1 = require("../rendering");
/**
* The renderer for superscript entries.
*
* @param entry The superscript entry.
* @param options Document-level render options.
* @returns Superscript markdown content.
*/
const supRenderer = (entry, options) => {
if ('sup' in entry) {
let useSuperscriptHtml = entry.html ?? options.useSuperscriptHtml ?? false;
let superscriptOpen = useSuperscriptHtml ? '<sup>' : '^';
let superscriptClose = useSuperscriptHtml ? '</sup>' : '^';
return `${superscriptOpen}${(0, rendering_1.getMarkdownString)(entry.sup, options)}${superscriptClose}`;
}
throw new Error('Entry is not an sup entry. Unable to render.');
};
exports.supRenderer = supRenderer;
/**
* Helper which creates a superscript text entry.
*
* @param options Entry-level options for this element.
* @returns a superscript text entry
*/
function sup(content, options) {
return {
sup: content,
...options,
};
}
exports.sup = sup;