Repository navigation
feat(content): 正文提取改为 Markdown 输出 - #11
Merged
Merged
Conversation
ZouZhao321
force-pushed
the
feat/markdown-output
branch
from
October 9, 2026 10:47
aa51315 to
40d3670
Compare
Owner
Author
ocr 评审与处理命令:
1.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联
无对应 issue。
做了什么
content命令的正文提取,从「取#js_content纯文本、按空白切行」改为「HTML → Markdown」:turndown+@joplin/turndown-plugin-gfm转换,保留标题、列表、代码块、图片、引用与表格。data-src(微信懒加载的真实地址),跳过data:占位图。script/style移除,只取#js_content。split(/\s+/).join("\n")造成的正文断行:Claude code以前会被切成两行。依赖选型说明:
microsoft/markitdown是 Python 包(pyproject.toml依赖beautifulsoup4、markdownify),Node CLI 用不了;npm 上的markitdown-ts是社区移植(0.0.10,2026-02 停更),依赖jsdom、mammoth、pdf-parse、xlsx、ai,而它自己的src/converters/html.ts就是 jsdom + turndown。所以只引入 turndown 与 GFM 插件这两个库。JSON 外壳保持不动:结果仍在 stdout 的
{ url, content },错误仍在 stderr +{"error":...}+ 退出码 1。验收
pnpm format:check && pnpm lint && pnpm build && pnpm test,结果:全绿,6 个文件 37 条测试通过(新增 4 条)node dist/index.js content "https://mp.weixin.qq.com/s/s_AmjWIB57b7fQY_3VNkoQ",结果:exit 0,17076 字符;###13 处、####35 处、图片 15 处、表格行 15 处、引用 24 处、列表项 42 处,与页面 HTML 里的 h3 13 / h4 35 / img 15 一致#、**、代码围栏、图片语法均不出现)影响面与回滚
content字段的值由纯文本变为 Markdown,字段名与 JSON 外壳不变,退出码与错误分支不变;MCP 的content工具返回同一份载荷,随之变化。回滚:git revert本提交。检查清单
type(scope): 中文描述docs/(README、docs/README.zh-CN.md)