feat: 完善导出设置与打印预览
This commit is contained in:
@@ -33,6 +33,21 @@ const answer = 42;
|
||||
);
|
||||
});
|
||||
|
||||
it("保留 Markdown 表格的列对齐语义", () => {
|
||||
const result = renderMarkdown(`
|
||||
| 左对齐 | 居中 | 右对齐 |
|
||||
| :--- | :---: | ---: |
|
||||
| A | B | C |
|
||||
`);
|
||||
|
||||
expect(result.bodyHtml).toContain('<th style="text-align:left">左对齐</th>');
|
||||
expect(result.bodyHtml).toContain('<th style="text-align:center">居中</th>');
|
||||
expect(result.bodyHtml).toContain('<th style="text-align:right">右对齐</th>');
|
||||
expect(result.bodyHtml).toContain('<td style="text-align:left">A</td>');
|
||||
expect(result.bodyHtml).toContain('<td style="text-align:center">B</td>');
|
||||
expect(result.bodyHtml).toContain('<td style="text-align:right">C</td>');
|
||||
});
|
||||
|
||||
it("读取并规范化 Front Matter 元数据", () => {
|
||||
const result = renderMarkdown(`---
|
||||
title: 项目报告
|
||||
@@ -74,6 +89,29 @@ flowchart LR
|
||||
);
|
||||
});
|
||||
|
||||
it("完整保留 Mermaid 区块内的 config frontmatter", () => {
|
||||
const result = renderMarkdown(`
|
||||
\`\`\`mermaid
|
||||
---
|
||||
title: Frontmatter 示例
|
||||
config:
|
||||
theme: forest
|
||||
look: handDrawn
|
||||
flowchart:
|
||||
curve: basis
|
||||
---
|
||||
flowchart LR
|
||||
A[开始] --> B[结束]
|
||||
\`\`\`
|
||||
`);
|
||||
|
||||
expect(result.bodyHtml).toContain("title: Frontmatter 示例");
|
||||
expect(result.bodyHtml).toContain("theme: forest");
|
||||
expect(result.bodyHtml).toContain("look: handDrawn");
|
||||
expect(result.bodyHtml).toContain("curve: basis");
|
||||
expect(result.bodyHtml).toContain("flowchart LR");
|
||||
});
|
||||
|
||||
it("阻止原始 HTML 和危险链接形成可执行内容", () => {
|
||||
const result = renderMarkdown(`
|
||||
<script>alert("xss")</script>
|
||||
|
||||
Reference in New Issue
Block a user