Markdown -> EPUB/MOBI 单文件在线转换器
面向日常文档与技术笔记,把一份 Markdown 直接导出为电子书格式,并保持常见语法渲染一致。
英文 Prompt:
You are a senior full-stack engineer. Build a production-ready web app "md2ebook" that converts a single Markdown file to EPUB and MOBI.
Requirements:
- Tech stack: Node.js 20 + Type + Vite + React, API server with Fastify.
- UI: upload .md, preview rendered Markdown, set data ( /author/language), choose output (EPUB/MOBI), download.
- Conversion: use pandoc in a Docker- d runtime (do not require local pandoc). Provide a container image and call it from the server.
- Support: code blocks with syntax highlight, tables, task lists, internal anchor s, images by URL.
- Output: generate both ebook files and a conversion log.
Deliverables:
1) Full repository file tree.
2) Complete source code for frontend + backend.
3) Dev/run commands (pnpm), and Docker compose for one-command start.
4) Deployment guide for a small VPS.
5) Tests: at least 5 automated tests (API + conversion) and a QA checklist.
中文释义:请产出一个可部署的在线 Markdown 转电子书工具:带预览、可配元信息、可下载 EPUB/MOBI,并把转换过程日志暴露出来,便于排查失败原因。
Markdown 批量转换(ZIP 批处理 + 失败重试)
适合把一批章节文件或多篇文章批量打包输出,要求能定位到失败文件并支持重试。
英文 Prompt:
Build a batch conversion feature for md2ebook.
Functional requirements:
- Accept a ZIP upload containing multiple .md files and optional assets folder.
- Convert each Markdown to EPUB and/or MOBI.
- Provide a progress UI with per-file status (queued/running/success/failed).
- Failed items must include actionable error messages and a "retry failed" button.
- Produce a downloadable ZIP that contains outputs and a JSON report with timings and errors.
Engineering requirements:
- Backend job queue with concurrency control.
- Persist jobs in SQLite (for demo) with an abstraction for Postgres.
- Strict limits: max ZIP size, max file count, timeout per conversion.
Deliverables: full code changes, migrations, and tests for batch flow.
中文释义:为在线工具增加 ZIP 批处理:上传一个压缩包,逐个转换并展示进度,失败要可重试且有清晰错误信息,最终输出包含结果与报告的 ZIP 包。
电子书目录与章节结构生成(按标题层级)
把 Markdown 的标题层级映射为目录,保证阅读器里章节跳转准确。
英文 Prompt:
Implement robust TOC and chapter splitting.
Rules:
- Parse Markdown headings (H1-H4) and build a table of contents.
- Split into chapters by H1/H2 with stable anchors.
- Ensure internal s (#anchors) still work after splitting.
- Provide options: "single chapter" vs "split by H2".
Deliverables: code, configuration UI, and tests using sample Markdown fixtures.
中文释义:让工具能把标题层级稳定映射成电子书目录,并支持按章节拆分;拆分后内部锚点链接仍然可跳转,避免目录错乱。
主题模板与样式自定义(CSS 注入 + 字体回退)
用于品牌化输出或阅读体验优化,允许选择模板与注入 CSS,但要保证兼容性。
英文 Prompt:
Add theming support.
Features:
- Provide 3 built-in themes (light, sepia, dark) for EPUB.
- Allow users to paste custom CSS.
- Validate CSS size and block unsafe URLs.
- Implement font fallback rules and a "no external assets" mode.
Deliverables: UI, backend validation, and e2e tests.
中文释义:为输出的 EPUB 增加主题与自定义 CSS:内置多主题,支持粘贴 CSS 注入,并做安全与体积校验,确保不引入不可信外链资源。
链接与资源检查(图片可达性、死链报告)
在转换前做资源健康检查,减少转换后才发现图片失效或链接断裂的情况。
英文 Prompt:
Create a preflight validator.
Checks:
- Validate image URLs (HEAD/GET) with timeouts and size limits.
- Detect broken internal anchors.
- Detect invalid Markdown syntax patterns that break conversion.
Output:
- Render a preflight report in UI.
- Allow "convert anyway" with warnings.
Deliverables: implementation + tests with mocked HTTP responses.
中文释义:增加转换前检查:验证图片链接可达、内部锚点是否存在、常见语法问题提示;输出可读报告,并允许带警告继续转换。
转换日志与可观测性(结构化日志 + 下载)
让用户能自己定位问题:把关键步骤与错误栈做结构化记录,并支持下载。
英文 Prompt:
Add observability.
Requirements:
- Structured logs with requestId/jobId.
- Capture pandoc stdout/stderr and store per-job logs.
- Add an API endpoint to download logs.
- Add a basic metrics page (queue depth, success rate) for admins.
Deliverables: code changes and tests.
中文释义:为在线转换流程补齐可观测性:每次任务都有 jobId;保存并可下载转换日志;提供简单的管理指标页,便于排查失败与性能瓶颈。
一键部署与环境自检(Docker Compose + 健康检查)
面向小团队或个人部署,提供可复制的部署流程和自检脚本,减少踩坑。
英文 Prompt:
Provide production deployment artifacts.
Requirements:
- docker-compose.yml with reverse proxy (Caddy or Nginx) and HTTPS instructions.
- Health endpoints for web and worker.
- Startup self-check: verifies container can run conversion and write to temp storage.
- Clear docs: env vars, storage paths, limits.
Deliverables: files + documentation + smoke test instructions.
中文释义:输出可直接落地的部署方案:Compose + 反代 + 健康检查 + 启动自检,明确环境变量、存储路径与限制,给出烟囱测试步骤。
测试用例与 QA 清单生成(覆盖边界输入)
保证工具在真实输入下稳定:长文、复杂表格、代码块、图片、中文路径等都要覆盖。
英文 Prompt:
Write a comprehensive test plan and implement automated tests.
Must include:
- Fixtures: long Markdown, tables, nested lists, fenced code blocks, Unicode filenames, images.
- At least 5 automated tests (unit + API integration).
- A QA checklist for manual verification (download, rendering, TOC s, errors, batch retry).
Deliverables: test code, commands to run, and CI configuration (GitHub Actions).
中文释义:给出可执行的测试与 QA:提供多种 Markdown 夹具与边界场景,至少 5 个自动化测试,并补齐人工验收清单与 CI 配置。