import { isMarkdownFile } from "$lib/markup/format"; import type { MarkupContext } from "$lib/markup/paths"; import { SOURCE_LIMIT, renderMarkdown } from "$lib/markup/markdown"; const render = async (contents: string, ctx: MarkupContext): Promise => { if (contents.length > SOURCE_LIMIT) return null; return `
${await renderMarkdown(contents, ctx)}
`; }; export const renderDocument = async ( filename: string, contents: string, ctx: MarkupContext ): Promise => (isMarkdownFile(filename) ? render(contents, ctx) : null); export const renderMarkup = (contents: string, ctx: MarkupContext): Promise => render(contents, { ...ctx, collapseCode: true });