refactor: 收敛渲染链路共享抽象

This commit is contained in:
SkyJourney
2026-07-27 00:46:16 +08:00
parent b459def232
commit ad18149c10
17 changed files with 480 additions and 255 deletions
+8 -14
View File
@@ -2,7 +2,11 @@ import { anchor } from "@mdit/plugin-anchor";
import { footnote } from "@mdit/plugin-footnote";
import { katex } from "@mdit/plugin-katex";
import { tasklist } from "@mdit/plugin-tasklist";
import type { ThemeFeature } from "@md-to-pdf/core";
import type {
MarkdownDocumentMetadata,
RenderedMarkdownDocument,
ThemeFeature
} from "@md-to-pdf/core";
import matter from "gray-matter";
import hljs from "highlight.js";
import MarkdownIt from "markdown-it";
@@ -22,25 +26,15 @@ export class MarkdownDocumentParseError extends Error {
}
}
export interface MarkdownDocumentMetadata {
title: string;
author: string;
subject: string;
keywords: string[];
language: string;
}
export type { MarkdownDocumentMetadata } from "@md-to-pdf/core";
export interface RenderMarkdownOptions {
language?: string;
}
export interface RenderedMarkdown {
export interface RenderedMarkdown
extends Omit<RenderedMarkdownDocument, "rendererVersion"> {
rendererVersion: typeof RENDERER_VERSION;
articleHtml: string;
bodyHtml: string;
metadata: MarkdownDocumentMetadata;
features: ThemeFeature[];
warnings: string[];
}
const markdownOptions: MarkdownItOptions = {