article-writer-cn
Version:
AI 驱动的智能写作系统 - 专注公众号/自媒体文章创作
82 lines • 2.16 kB
TypeScript
/**
* 微信公众号 Markdown 格式化器
* 基于 doocs/md 的核心渲染引擎
* 将 Markdown 转换为微信公众号可用的富文本 HTML
*/
export interface WechatTheme {
base: Record<string, string>;
block: Record<string, Record<string, string>>;
inline: Record<string, Record<string, string>>;
}
export interface FormatOptions {
theme?: 'default' | 'grace' | 'simple';
fontSize?: string;
primaryColor?: string;
fontFamily?: string;
isUseIndent?: boolean;
isUseJustify?: boolean;
isShowLineNumber?: boolean;
citeStatus?: boolean;
imageBedFactory?: any;
convertLocalImages?: boolean;
convertOnlineImagesToBase64?: boolean;
}
/**
* Wechat Formatter 类
*/
export declare class WechatFormatter {
private options;
private theme;
private footnotes;
private footnoteIndex;
private imageBedFactory;
private localImages;
private onlineImages;
private tempDir;
constructor(options?: FormatOptions);
/**
* 获取元素样式字符串
*/
private getStyles;
/**
* 创建带样式的元素
*/
private styledContent;
/**
* 添加脚注
*/
private addFootnote;
/**
* 构建脚注列表
*/
private buildFootnotes;
/**
* 判断是否为本地图片路径
*/
private isLocalImagePath;
/**
* 处理本地图片上传
*/
private processLocalImages;
/**
* 处理在线图片转 Base64
*/
private processOnlineImages;
/**
* 格式化 Markdown 为微信 HTML
*/
format(markdown: string): Promise<string>;
/**
* 导出为完整 HTML 文件(带一键复制功能)
*/
exportHtml(markdown: string, title?: string): Promise<string>;
}
/**
* 便捷函数:格式化 Markdown 为微信 HTML
*/
export declare function formatMarkdownForWechat(markdown: string, options?: FormatOptions): Promise<string>;
/**
* 便捷函数:导出为完整 HTML 文件
*/
export declare function exportWechatHtml(markdown: string, title?: string, options?: FormatOptions): Promise<string>;
//# sourceMappingURL=wechat-formatter.d.ts.map