export * as gfm from "https://deno.land/x/gfm@0.2.5/mod.ts";
import "https://esm.sh/prismjs@1.29.0/components/prism-jsx.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-typescript.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-tsx.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-diff.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-json.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-bash.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-yaml.js?no-check";
export { extract as frontMatter } from "$std/front_matter/yaml.ts";
import Prism from "https://esm.sh/prismjs@1.29.0";
import * as Marked from "https://esm.sh/marked@7.0.2";
import { escape as escapeHtml } from "$std/html/entities.ts";
import { mangle } from "$marked-mangle";
Marked.marked.use(mangle());
class DefaultRenderer extends Marked.Renderer {
text(text: string): string {
// Smartypants typography enhancement
return text
.replaceAll("...", "…")
.replaceAll("--", "—")
.replaceAll("---", "–")
.replaceAll(/(\w)'(\w)/g, "$1’$2")
.replaceAll(/s'/g, "s’")
.replaceAll("'", "’")
.replaceAll(/["](.*?)["]/g, "“$1”")
.replaceAll(/"(.*?)"/g, "“$1”")
.replaceAll(/['](.*?)[']/g, "‘$1’");
}
heading(
text: string,
level: 1 | 2 | 3 | 4 | 5 | 6,
raw: string,
slugger: Marked.Slugger,
): string {
const slug = slugger.slug(raw);
return ``;
}
code(code: string, info: string | undefined): string {
// format: tsx
// format: tsx my/file.ts
// format: tsx "This is my title"
let lang = "";
let title = "";
const match = info?.match(/^(\w+)\s*(.*)?$/);
if (match) {
lang = match[1].toLocaleLowerCase();
title = match[2] ?? "";
}
let out = `
${escapeHtml(code)}`;
} else {
const html = Prism.highlight(code, grammar, lang);
out +=
`${html}`;
}
out += `