From 913c3abb44bd52320198441e6ffe7bfa9b95f0c5 Mon Sep 17 00:00:00 2001 From: sirily11 <32106111+sirily11@users.noreply.github.com> Date: Fri, 15 May 2026 18:27:46 +0800 Subject: [PATCH] fix: release note rendering issue --- website/app/lib/release.ts | 74 +--------------- website/app/release/page.tsx | 20 +++-- website/bun.lock | 159 +++++++++++++++++++++++++++++++++++ website/package.json | 3 +- 4 files changed, 179 insertions(+), 77 deletions(-) diff --git a/website/app/lib/release.ts b/website/app/lib/release.ts index 8800c60f..4299e354 100644 --- a/website/app/lib/release.ts +++ b/website/app/lib/release.ts @@ -99,6 +99,7 @@ export type SparkleRelease = SparkleItem & { export type AppReleaseNote = SparkleRelease & { tag: string; isPrerelease: boolean; + releaseNotesMarkdown: string | null; }; function pickTag(xml: string, tag: T): string | null { @@ -199,74 +200,6 @@ export async function getSparkleReleases(): Promise { } } -function escapeHtml(value: string): string { - return value - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """); -} - -function inlineMarkdownToHtml(value: string): string { - return escapeHtml(value) - .replace(/\*\*([^*]+)\*\*/g, "$1") - .replace(/`([^`]+)`/g, "$1"); -} - -function releaseMarkdownToHtml(markdown: string): string { - const lines = markdown.split(/\r?\n/); - const html: string[] = []; - let inList = false; - - const closeList = () => { - if (inList) { - html.push(""); - inList = false; - } - }; - - for (const line of lines) { - const trimmed = line.trim(); - if (!trimmed) { - closeList(); - continue; - } - - if (trimmed.startsWith("### ")) { - closeList(); - html.push(`

${inlineMarkdownToHtml(trimmed.slice(4))}

`); - continue; - } - - if (trimmed.startsWith("## ")) { - closeList(); - html.push(`

${inlineMarkdownToHtml(trimmed.slice(3))}

`); - continue; - } - - if (trimmed.startsWith("# ")) { - closeList(); - html.push(`

${inlineMarkdownToHtml(trimmed.slice(2))}

`); - continue; - } - - if (trimmed.startsWith("- ")) { - if (!inList) { - html.push("