Readme

Display Markdown

Takes a markdown document (as a string) and returns an http handler that renders it.

1
2
3
4
5
6
7
8
9
import { gfm } from "https://esm.town/v/saolsen/gfm";
export async function displayMarkdown(markdown: string): Promise<(req: Request) => Response> {
const html = await gfm(markdown);
function handler(req: Request): Response {
return new Response(html, { headers: { "content-type": "text/html" } });
}
return handler;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.