From ca8e6824eaa711105f4092365792720c9dde026b Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 18 Jun 2026 19:21:59 +0100 Subject: remove Astro website --- website/src/renderGemtextToHtml.ts | 71 -------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 website/src/renderGemtextToHtml.ts (limited to 'website/src/renderGemtextToHtml.ts') diff --git a/website/src/renderGemtextToHtml.ts b/website/src/renderGemtextToHtml.ts deleted file mode 100644 index 1c01072..0000000 --- a/website/src/renderGemtextToHtml.ts +++ /dev/null @@ -1,71 +0,0 @@ -import * as Gemtext from "gemtext"; - -export function renderGemtextToHtml(gemtext: string, title?: string): string { - gemtext = title ? gemtext.replace(`# ${title}`, "") : gemtext; - return postProcessGemtextToHtml( - Gemtext.parse(gemtext).generate(GemtextHTMLRenderer), - ); -} - -const GemtextHTMLRenderer: Gemtext.Renderer = { - preamble: function (): string { - return ""; - }, - - postamble: function (): string { - return ""; - }, - - text: function (content: string): string { - content = content.trim(); - if (content === "") { - return ""; - } - return `

${htmlEscape(content)}

`; - }, - - link: function (url: string, alt: string): string { - const imgExtensions: (string | undefined)[] = [ - "webp", - "png", - "svg", - "gif", - "jpg", - "jpeg", - "apng", - ]; - if (imgExtensions.includes(url.split(".").at(-1)?.toLowerCase())) { - return `${alt}`; - } - return `

=> ${alt}

`; - }, - - preformatted: function (content: string[], alt: string): string { - return `
${htmlEscape(content.join("\n"))}
`; - }, - - heading: function (level: number, text: string): string { - return `${htmlEscape(text)}`; - }, - - unorderedList: function (content: string[]): string { - return ``; - }, - - quote: function (content: string): string { - return `
${htmlEscape(content)}
`; - }, -}; - -function htmlEscape(str: string) { - return str.replace(/&/g, "&").replace(//g, ">"); -} - -function postProcessGemtextToHtml(html: string): string { - html = mergeAdjacentBlockquotes(html); - return html; -} - -function mergeAdjacentBlockquotes(html: string): string { - return html.replaceAll(/\<\/blockquote\>\/gm, "
"); -} -- cgit v1.2.3