ts-markdown
Version:
An extensible TypeScript markdown generator that takes JSON and creates a markdown document.
35 lines (34 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.blockquote = exports.blockquoteRenderer = void 0;
const rendering_1 = require("../rendering");
/**
* The renderer for blockquote entries.
*
* @param entry The blockquote entry.
* @param options Document-level render options.
* @returns Block-level blockquote markdown content.
*/
const blockquoteRenderer = (entry, options) => {
if ('blockquote' in entry) {
return {
markdown: (0, rendering_1.renderEntries)(Array.isArray(entry.blockquote) ? entry.blockquote : [entry.blockquote], { ...options, prefix: '> ' }),
blockLevel: true,
};
}
throw new Error('Entry is not a blockquote entry. Unable to render.');
};
exports.blockquoteRenderer = blockquoteRenderer;
/**
* Helper which creates a blockquote entry.
*
* @param options Entry-level options for this element.
* @returns a blockquote entry
*/
function blockquote(content, options) {
return {
blockquote: content,
...options,
};
}
exports.blockquote = blockquote;