sn-md-to-html-report
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkdown 转 HTML 报告
Markdown to HTML Report
默认目标
Default Objectives
生成“长篇研究报告阅读版”HTML:正文舒展、图片自然插入、表格清晰、目录可用、可离线打开。优先保持内容可信和阅读舒服,不做营销页、不做炫技页面。
Generate HTML for "long-form research report reading version": with spacious body text, naturally inserted images, clear tables, usable directory, and offline accessibility. Prioritize content credibility and reading comfort; avoid marketing pages or overly flashy pages.
推荐路径
Recommended Workflow
优先使用内置脚本生成稳定结果:
bash
python3 /path/to/sn-md-to-html-report/scripts/render_report.py input.md output.html常用参数:
- :将本地图片嵌入 HTML,适合单文件分享。默认开启。
--embed-images - :保留相对图片路径,适合文件夹整体发布。
--no-embed-images - :加入阅读进度、目录高亮、返回顶部等轻量交互。
--with-js - :保留 Markdown 正文中已有的目录;默认会移除正文目录,避免和侧边栏目录重复。
--keep-inline-toc - :渲染 Markdown 中的 Mermaid 代码块。默认
--mermaid-source auto|cdn|local|none,检测到 ```mermaid 代码块时使用 CDN;auto会引用输出 HTML 同目录下的local;mermaid.min.js保留为普通代码块。none - :默认舒适报告模板。
--title-style comfortable
生成后运行图片检查:
bash
python3 /path/to/sn-md-to-html-report/scripts/check_image_refs.py output.html当输出使用 时,检查结果中的本地图片引用数通常为 0,这是正常的。
--embed-imagesPrioritize using built-in scripts to generate stable results:
bash
python3 /path/to/sn-md-to-html-report/scripts/render_report.py input.md output.htmlCommon parameters:
- : Embed local images into HTML, suitable for single-file sharing. Enabled by default.
--embed-images - : Keep relative image paths, suitable for folder-wide publication.
--no-embed-images - : Add lightweight interactions such as reading progress, directory highlighting, and back-to-top button.
--with-js - : Keep the existing directory in the Markdown body; by default, the body directory is removed to avoid duplication with the sidebar directory.
--keep-inline-toc - : Render Mermaid code blocks in Markdown. Default is
--mermaid-source auto|cdn|local|none, uses CDN when ```mermaid code blocks are detected;autoreferenceslocalin the same directory as the output HTML;mermaid.min.jskeeps it as a regular code block.none - : Default comfortable report template.
--title-style comfortable
Run image check after generation:
bash
python3 /path/to/sn-md-to-html-report/scripts/check_image_refs.py output.htmlWhen using for output, it is normal for the number of local image references in the check result to be 0.
--embed-images工作流程
Workflow
- 确定输入 Markdown 和输出 HTML。
- 用户只给输入路径时,在同目录生成同名 。
.html - 若同名 HTML 已存在,优先换新文件名,除非用户明确要求覆盖。
- 用户只给输入路径时,在同目录生成同名
- 转换前检查 Markdown。
- 以 Markdown 所在目录作为相对图片基准。
- 将误用的全角表格竖线 修正为半角
|,避免表格错列。| - 对“说明文字:”后紧跟 、
-或数字编号列表但中间缺空行的常见写法,转换前补空行,让分点输出渲染为真正列表。* - 如果 Markdown 已有 且内容是章节锚点列表,默认从正文中移除;侧边栏目录已经提供导航,正文目录会重复占空间。
## 目录 - 保留原文内容,不总结、不改写、不新增事实。
- 生成完整 HTML5。
- CSS 内联到 ,不依赖 CDN、在线字体、外部 CSS。
<style> - 默认不需要 JavaScript;只有用户想要阅读进度、目录高亮、返回顶部时加少量原生 JS。
- Markdown 中的 ```mermaid 代码块会转换为 Mermaid 图表容器;如需完全离线分享,使用 并将
--mermaid-source local放在输出 HTML 同目录。mermaid.min.js - 图片默认嵌入为 ,让 HTML 单文件可独立打开。
data:image/...
- CSS 内联到
- 自检输出。
- 检查标题、目录、表格数量、图片数量是否与源文档大体一致。
- 检查宽表在移动端可横向滚动,图片不撑破页面。
- 检查 HTML 属性、闭合标签、目录锚点和 CSS 语法。
- Determine input Markdown and output HTML.
- When only the input path is provided by the user, generate a same-named file in the same directory.
.html - If a same-named HTML already exists, prefer to use a new file name unless the user explicitly requests overwriting.
- When only the input path is provided by the user, generate a same-named
- Check Markdown before conversion.
- Use the directory where the Markdown is located as the base for relative image paths.
- Correct misused full-width table vertical lines to half-width
|to avoid table misalignment.| - Add blank lines before lists starting with ,
-or numbered lists that follow "explanatory text:" without a blank line, so that the bullet points are rendered as actual lists.* - If the Markdown already has (Table of Contents) with chapter anchor lists, it is removed from the body by default; the sidebar directory already provides navigation, and the body directory would take up redundant space.
## 目录 - Keep the original content, do not summarize, rewrite, or add new facts.
- Generate complete HTML5.
- CSS is inlined into , no dependencies on CDN, online fonts, or external CSS.
<style> - No JavaScript is required by default; only add a small amount of native JS when the user wants reading progress, directory highlighting, or back-to-top functionality.
- ```mermaid code blocks in Markdown are converted to Mermaid chart containers; for fully offline sharing, use and place
--mermaid-source localin the same directory as the output HTML.mermaid.min.js - Images are embedded as by default, allowing the HTML single file to be opened independently.
data:image/...
- CSS is inlined into
- Self-check the output.
- Check if the number of titles, directories, tables, and images is roughly consistent with the source document.
- Check that wide tables can scroll horizontally on mobile devices, and images do not break the page layout.
- Check HTML attributes, closed tags, directory anchors, and CSS syntax.
视觉原则
Visual Principles
从这次效果中沉淀的默认偏好:
- 页面像“干净的研究报告”,不是后台表格页,也不是营销落地页。
- 使用浅灰页面背景和白色正文纸张区,正文有明确边界但不过度卡片化。
- 桌面端左侧使用粘性目录,正文在右侧;移动端目录放到正文上方或可折叠。
- 正文中已有的 Markdown 目录默认不保留,除非用户明确需要正文目录或使用 。
--keep-inline-toc - H1 可以使用克制的蓝绿渐变标题区,正文标题保持清晰层级。
- 正文留白要舒适:段落、表格、图片之间要让读者有停顿。
- 图片作为图表节点自然出现:居中、最大宽度 100%、轻边框、轻阴影、与上下文留足间距。
- 表格适合研究报告扫描:表头浅色或深色皆可,但要稳定、可横向滚动、单元格内边距足够。
- 配色避免单一深蓝/紫色压满页面;推荐蓝绿主色配少量蓝色链接。
Default preferences derived from this effect:
- The page should look like a "clean research report", not a backend table page or a marketing landing page.
- Use a light gray page background and white body paper area, with clear boundaries for the body but not overly card-style.
- On desktop, use a sticky directory on the left and the body on the right; on mobile, place the directory above the body or make it collapsible.
- Existing Markdown directories in the body are not kept by default unless the user explicitly needs a body directory or uses .
--keep-inline-toc - H1 can use a restrained blue-green gradient title area, while body titles maintain clear hierarchy.
- Comfortable white space in the body: sufficient pauses between paragraphs, tables, and images for readers.
- Images appear naturally as chart nodes: centered, maximum width 100%, light border, light shadow, and sufficient spacing with context.
- Tables suitable for research report scanning: header can be light or dark, but must be stable, horizontally scrollable, and have sufficient cell padding.
- Avoid filling the page with a single dark blue/purple color; recommend blue-green main color with a small amount of blue links.
舒适模板要点
Comfort Template Key Points
默认 CSS 应接近以下参数,可按内容微调:
- :
body,浅灰背景,系统中文字体。line-height: 1.75 - :桌面端
.layout,最大宽度约grid-template-columns: minmax(220px, 280px) minmax(0, 1fr),页面外边距约1480px。28px - :粘性、半透明白底、细边框、轻阴影;目录项字号约
.toc-panel。13px - :白色正文容器、
main圆角、细边框、轻阴影。8px - :桌面端内边距约
article。46px min(6vw, 76px) 68px - :标题区可用
h1,字号linear-gradient(135deg, #0f766e, #155e75, #1d4ed8)。clamp(30px, 4vw, 52px) - :上方留足空间,顶部细分割线,字号
h2。clamp(22px, 2.3vw, 30px) - :字号约
h3,颜色比正文更深。21px - :用浅蓝绿背景和左侧强调线,可承载图注或注释。
blockquote - :作为表格外层滚动容器,
.table-scroll、width:100%、细边框和圆角。overflow-x:auto - :保持原生
table和display:table,不要用width:100%;短表要自然铺满正文宽度,宽表由display:block横向滚动。.table-scroll - :
img。display:block; max-width:100%; height:auto; margin:24px auto 8px; border:1px solid var(--line); border-radius:8px; box-shadow:0 12px 28px rgba(15,23,42,.08)
The default CSS should be close to the following parameters, and can be adjusted slightly according to content:
- :
body, light gray background, system Chinese fonts.line-height: 1.75 - : On desktop,
.layout, maximum width aroundgrid-template-columns: minmax(220px, 280px) minmax(0, 1fr), page margin around1480px.28px - : Sticky, semi-transparent white background, thin border, light shadow; directory item font size around
.toc-panel.13px - : White body container,
mainborder-radius, thin border, light shadow.8px - : On desktop, padding around
article.46px min(6vw, 76px) 68px - : Title area can use
h1, font sizelinear-gradient(135deg, #0f766e, #155e75, #1d4ed8).clamp(30px, 4vw, 52px) - : Sufficient space above, thin top divider, font size
h2.clamp(22px, 2.3vw, 30px) - : Font size around
h3, darker color than body text.21px - : Use light blue-green background and left emphasis line, can carry captions or annotations.
blockquote - : As the outer scroll container for tables,
.table-scroll,width:100%, thin border and border-radius.overflow-x:auto - : Keep native
tableanddisplay:table, do not usewidth:100%; short tables should naturally fill the body width, wide tables are scrolled horizontally bydisplay:block..table-scroll - :
img.display:block; max-width:100%; height:auto; margin:24px auto 8px; border:1px solid var(--line); border-radius:8px; box-shadow:0 12px 28px rgba(15,23,42,.08)
图片规则
Image Rules
- 默认嵌入本地图片,适合给别人发一个 HTML 文件。
- 用户要求保持文件较小、图片可替换、或已有发布目录时,使用 保留相对路径。
--no-embed-images - 不要使用绝对本地路径写入 HTML,除非用户明确要求。
- Markdown 图片后的引用块若明显是图注,保留为图下说明或 blockquote,不改变文字。
- 缺失图片要在最终回复里说明路径。
- Embed local images by default, suitable for sending a single HTML file to others.
- Use to keep relative paths when the user requires smaller file size, replaceable images, or an existing publication directory.
--no-embed-images - Do not write absolute local paths into HTML unless explicitly requested by the user.
- If the reference block after a Markdown image is clearly a caption, keep it as an under-image description or blockquote without changing the text.
- Missing images should be explained with their paths in the final response.
表格规则
Table Rules
- 修复全角竖线 。
| - 修复列表前缺空行导致的 Markdown 分点不渲染问题;不要碰代码块里的内容。
- 使用 Markdown 解析器或结构化转换,不用脆弱的字符串拼 HTML 表格。
- 宽表必须可横向滚动,不能挤压正文,也不能在移动端撑破页面。
- 短表不要在右侧留下大片空白;表格元素保持 ,滚动只放在外层容器。
width:100% - 不要为了美化删列、合并列或改写单元格内容。
- Fix full-width vertical lines .
| - Fix the issue where Markdown bullet points are not rendered due to missing blank lines before lists; do not modify content in code blocks.
- Use a Markdown parser or structured conversion, do not use fragile string concatenation to build HTML tables.
- Wide tables must be horizontally scrollable, cannot squeeze the body, and cannot break the page layout on mobile devices.
- Short tables should not leave large blank spaces on the right; table elements should keep , and scrolling is only placed in the outer container.
width:100% - Do not delete columns, merge columns, or rewrite cell content for beautification purposes.
交互规则
Interaction Rules
默认静态 HTML 已足够。只有在用户要求“导航更方便”“像原报告一样有进度条”或文档特别长时,加入 :
--with-js- 阅读进度条。
- 当前目录项高亮。
- 返回顶部按钮。
- 移动端目录展开/收起。
所有交互使用原生 JavaScript,不依赖外部库;脚本要先检查元素存在。
Static HTML is sufficient by default. Only add when the user requests "more convenient navigation", "progress bar like the original report", or when the document is particularly long:
--with-js- Reading progress bar.
- Current directory item highlighting.
- Back-to-top button.
- Mobile directory expand/collapse.
All interactions use native JavaScript, no dependencies on external libraries; scripts should check for element existence first.
打印规则
Print Rules
添加 :
@media print- 隐藏目录、进度条、返回顶部等辅助 UI。
- 页面背景改白,去掉阴影。
- 尽量避免表格、图片、引用块被不自然截断。
- 打印时标题不依赖深色渐变背景。
Add :
@media print- Hide auxiliary UI such as directories, progress bars, and back-to-top buttons.
- Change page background to white, remove shadows.
- Try to avoid unnatural truncation of tables, images, and blockquotes.
- Titles do not rely on dark gradient backgrounds when printing.
质量自检
Quality Self-Check
生成后至少确认:
- HTML 文件存在且可读。
- 、
<table>数量与源文档大体一致。<img> - 分点内容应渲染为 和
<ul>/<ol>,不要保留成带连字符的普通段落。<li> - 表格应由 包裹,
.table-scroll自身不要使用table。display:block - 嵌入图片时包含 ;非嵌入时
data:image/无缺失图片。check_image_refs.py - 目录链接均为 且目标 ID 存在。
href="#..." - 正文不应同时出现一份原始 Markdown 目录和一份侧边栏目录,除非用户明确要求保留。
- 不出现破损标签、空 、重复明显 ID、非法
href或损坏 CSS。calc()
At least confirm the following after generation:
- The HTML file exists and is readable.
- The number of and
<table>elements is roughly consistent with the source document.<img> - Bullet point content should be rendered as and
<ul>/<ol>, not kept as regular paragraphs with hyphens.<li> - Tables should be wrapped by , and
.table-scrollitself should not usetable.display:block - Embedded images include ; when not embedded,
data:image/shows no missing images.check_image_refs.py - All directory links are and the target ID exists.
href="#..." - The body should not contain both an original Markdown directory and a sidebar directory unless explicitly requested by the user.
- No broken tags, empty , duplicate obvious IDs, invalid
href, or damaged CSS.calc()
最终回复
Final Response
简洁说明:
- 输出 HTML 路径。
- 是否嵌入图片,或图片引用检查结果。
- 修复了哪些格式问题,例如全角表格竖线。
- 未能完成的校验,如有。
Brief explanation:
- Output HTML path.
- Whether images are embedded, or the result of image reference check.
- Fixed formatting issues, such as full-width table vertical lines.
- Uncompleted verifications, if any.