fix: 修复预览与 PDF 渲染边界问题

This commit is contained in:
SkyJourney
2026-07-27 00:33:56 +08:00
parent d93728bb8b
commit b459def232
10 changed files with 413 additions and 85 deletions
+13 -3
View File
@@ -13,6 +13,15 @@ import sanitizeHtml from "sanitize-html";
export const RENDERER_VERSION = 1;
export class MarkdownDocumentParseError extends Error {
readonly code = "INVALID_FRONT_MATTER";
constructor(message: string, options?: ErrorOptions) {
super(message, options);
this.name = "MarkdownDocumentParseError";
}
}
export interface MarkdownDocumentMetadata {
title: string;
author: string;
@@ -198,9 +207,10 @@ function parseFrontMatter(source: string) {
return matter(source);
} catch (error) {
const message = error instanceof Error ? error.message : "未知错误";
throw new Error(`无法解析 Markdown Front Matter${message}`, {
cause: error
});
throw new MarkdownDocumentParseError(
`无法解析 Markdown Front Matter${message}`,
{ cause: error }
);
}
}