import type { Inline, InlineRenderer } from "./inline.js"; import { renderInline } from "./inline.js"; import type { Table, TableRenderer } from "./table.js"; import { renderTable } from "./table.js"; export type Renderer = { (inline: Inline, options?: Options): I; (table: Table, options?: Options): T; (template: Inline | Table, options?: Options): I | T; }; export function makeRenderer( defaultOptions: Options, inline: | ((inline: Inline, options: Options) => I) | InlineRenderer, table: TableRenderer, ): Renderer { return function render(template, options = defaultOptions) { if (template.type === "table") { return renderTable(inline, table, template, options); } return renderInline(inline, template, options); } as Renderer; }