[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-romansky--dom-to-semantic-markdown":3,"tool-romansky--dom-to-semantic-markdown":64},[4,17,25,39,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":10,"last_commit_at":23,"category_tags":24,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,15],{"id":26,"name":27,"github_repo":28,"description_zh":29,"stars":30,"difficulty_score":10,"last_commit_at":31,"category_tags":32,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[33,34,35,36,14,37,15,13,38],"图像","数据工具","视频","插件","其他","音频",{"id":40,"name":41,"github_repo":42,"description_zh":43,"stars":44,"difficulty_score":45,"last_commit_at":46,"category_tags":47,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,3,"2026-04-04T04:44:48",[14,33,13,15,37],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":45,"last_commit_at":54,"category_tags":55,"status":16},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",74913,"2026-04-05T10:44:17",[15,33,13,37],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":45,"last_commit_at":62,"category_tags":63,"status":16},2181,"OpenHands","OpenHands\u002FOpenHands","OpenHands 是一个专注于 AI 驱动开发的开源平台，旨在让智能体（Agent）像人类开发者一样理解、编写和调试代码。它解决了传统编程中重复性劳动多、环境配置复杂以及人机协作效率低等痛点，通过自动化流程显著提升开发速度。\n\n无论是希望提升编码效率的软件工程师、探索智能体技术的研究人员，还是需要快速原型验证的技术团队，都能从中受益。OpenHands 提供了灵活多样的使用方式：既可以通过命令行（CLI）或本地图形界面在个人电脑上轻松上手，体验类似 Devin 的流畅交互；也能利用其强大的 Python SDK 自定义智能体逻辑，甚至在云端大规模部署上千个智能体并行工作。\n\n其核心技术亮点在于模块化的软件智能体 SDK，这不仅构成了平台的引擎，还支持高度可组合的开发模式。此外，OpenHands 在 SWE-bench 基准测试中取得了 77.6% 的优异成绩，证明了其解决真实世界软件工程问题的能力。平台还具备完善的企业级功能，支持与 Slack、Jira 等工具集成，并提供细粒度的权限管理，适合从个人开发者到大型企业的各类用户场景。",70612,"2026-04-05T11:12:22",[15,14,13,36],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":78,"owner_location":79,"owner_email":80,"owner_twitter":78,"owner_website":78,"owner_url":81,"languages":82,"stars":95,"forks":96,"last_commit_at":97,"license":98,"difficulty_score":99,"env_os":100,"env_gpu":101,"env_ram":101,"env_deps":102,"category_tags":106,"github_topics":78,"view_count":10,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":107,"updated_at":108,"faqs":109,"releases":140},3398,"romansky\u002Fdom-to-semantic-markdown","dom-to-semantic-markdown","DOM to Semantic-Markdown for use with LLMs","dom-to-semantic-markdown 是一款专为大语言模型（LLM）设计的开源库，它能将网页的 HTML DOM 结构高效转换为语义清晰的 Markdown 格式。在处理网页数据时，原始 HTML 往往包含大量冗余标签和噪声，不仅消耗昂贵的 Token 资源，还干扰模型对核心内容的理解。这款工具正是为了解决这一痛点而生，它通过智能提取页面主干内容、保留\u003Cheader>等关键语义结构，并自动抓取标题、Open Graph 及 JSON-LD 等元数据，显著提升了信息的可读性与处理效率。\n\n其独特技术亮点在于“令牌优化”与“表格增强”：通过 URL 简化减少输入长度，并为表格列添加唯一标识符，帮助模型更精准地关联行内数据。无论是需要构建 RAG（检索增强生成）系统的后端开发者，还是致力于提升模型上下文理解能力的 AI 研究人员，都能从中受益。只需一行命令，即可将复杂的网页转化为模型友好的简洁文本，让数据预处理变得轻松而专业。","\u003Ch1 align=\"center\">\n    \u003Cimg width=\"100\" height=\"100\" src=\"d2m_color.svg\" alt=\"DOM to Semantic Markdown Logo\">\u003Cbr>\n    DOM to Semantic Markdown\n\u003C\u002Fh1>\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fromansku\u002Fdom-to-semantic-markdown\u002Factions\u002Fworkflows\u002Fci.yml)\n[![npm version](https:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fdom-to-semantic-markdown.svg)](https:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fdom-to-semantic-markdown)\n[![License: ISC](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\nThis library converts HTML DOM to a semantic Markdown format optimized for use with Large Language Models (LLMs). It\npreserves the semantic structure of web content, extracts essential metadata, and reduces token usage compared to raw\nHTML, making it easier for LLMs to understand and process information.\n\n## Key Features\n\n* **Semantic Structure Preservation:** Retains the meaning of HTML elements like `\u003Cheader>`, `\u003Cfooter>`, `\u003Cnav>`, and\n  more.\n* **Metadata Extraction:** Captures important metadata such as title, description, keywords, Open Graph tags, Twitter\n  Card tags, and JSON-LD data.\n* **Token Efficiency:** Optimizes for token usage through URL refification and concise representation of content.\n* **Main Content Detection:** Automatically identifies and extracts the primary content section of a webpage.\n* **Table Column Tracking:** Adds unique identifiers to table columns, improving LLM's ability to correlate data across\n  rows.\n\n## Special Feature Examples\n\nHere are examples showcasing the library's special features using the CLI tool:\n\n**1. Simple Content Extraction:**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com\n```\n\nThis command fetches `https:\u002F\u002Fxkcd.com` and converts it to Markdown\n\n\u003Cdetails>\n\u003Csummary>Click to view the output\u003C\u002Fsummary>\n\n```markdown\n- [Archive](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [About](\u002Fabout)\n- [Feed](\u002Fatom.xml) • [Email](\u002Fnewsletter\u002F)\n- [TW](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [FB](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [IG](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-Books-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com logo](\u002Fs\u002F0b7742.png)\u003C\u002Fa> A webcomic of romance,\n  sarcasm, math, and language. [Special 10th anniversary edition of WHAT IF?](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F) —revised and annotated with brand-new illustrations and answers to important questions you never thought to ask—out now. Order it [here](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! Renormalization\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\n![Renormalization](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\nPermanent link to this comic: [https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\nImage URL (for hotlinking\u002Fembedding): [https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![Selected Comics](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![Earth temperature timeline](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS Feed](\u002Frss.xml) - [Atom Feed](\u002Fatom.xml) - [Email](\u002Fnewsletter\u002F)\nComics I enjoy:\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F), [SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F), [Dinosaur Comics](https:\u002F\u002Fwww.qwantz.com\u002F), [Oglaf](https:\u002F\u002Foglaf.com\u002F) (nsfw), [A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F), [Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F), [Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F), [Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F), [Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F), [Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F), [Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\nOther things:\n[Tips on technology and government](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[Climate FAQ](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html), [Katharine Hayhoe](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com is best viewed with Netscape Navigator 4.0 or below on a Pentium 3±1 emulated in Javascript on an Apple IIGS\nat a screen resolution of 1024x1. Please enable your ad blockers, disable high-heat drying, and remove your device\nfrom Airplane Mode and set it to Boat Mode. For security reasons, please leave caps lock on while browsing. This work is licensed under a [Creative Commons Attribution-NonCommercial 2.5 License](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F).\n\nThis means you're free to copy and share these comics (but not to sell them). [More details](\u002Flicense.html).\n```\n\n\u003C\u002Fdetails>\n\n**2. Table Column Tracking:**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fsoftwareyoga.com\u002Flatency-numbers-everyone-should-know\u002F -t -e\n```\n\nThis command fetches and converts the main content from to Markdown and adds unique identifiers to table columns, aiding\nLLMs in understanding table structure.\n\n\u003Cdetails>\n\u003Csummary>Click to view the output\u003C\u002Fsummary>\n\n```markdown\n# Latency Numbers Everyone Should Know\n\n## Latency\n\nIn a computer network, latency is defined as the amount of time it takes for a packet of data to get from one designated point to another.\n\nIn more general terms, it is the amount of time between the cause and the observation of the effect.\n\nAs you would expect, latency is important, very important. As programmers, we all know reading from disk takes longer than reading from memory or the fact that L1 cache is faster than the L2 cache.\n\nBut do you know the orders of magnitude by which these aspects are faster\u002Fslower compared to others?\n\n## Latency for common operations\n\nJeff Dean from Google studied exactly that and came up with figures for latency in various situations.\n\nWith improving hardware, the latency at the higher ends of the spectrum are reducing, but not enough to ignore them completely! For instance, to read 1MB sequentially from disk might have taken 20,000,000 ns a decade earlier and with the advent of SSDs may probably take 1,000,000 ns today. But it is never going to surpass reading directly from memory.\n\nThe table below presents the latency for the most common operations on commodity hardware. These data are only approximations and will vary with the hardware and the execution environment of your code. However, they do serve their primary purpose, which is to enable us make informed technical decisions to reduce latency.\n\nFor better comprehension of  the multi-fold increase in latency, scaled figures in relation to L2 cache are also provided by assuming that the L1 cache reference is 1 sec.\n\n**Scroll horizontally on the table in smaller screens**\n\n| Operation \u003C!-- col-0 --> | Note \u003C!-- col-1 --> | Latency \u003C!-- col-2 --> | Scaled Latency \u003C!-- col-3 --> |\n| --- | --- | --- | --- |\n| L1 cache reference \u003C!-- col-0 --> | Level-1 cache, usually built onto the microprocessor chip itself. \u003C!-- col-1 --> | 0.5 ns \u003C!-- col-2 --> | Consider L1 cache reference duration is 1 sec \u003C!-- col-3 --> |\n| Branch mispredict \u003C!-- col-0 --> | During the execution of a program, CPU predicts the next set of instructions. Branch misprediction is when it makes the wrong prediction. Hence, the previous prediction has to be erased and new one calculated and placed on the execution stack. \u003C!-- col-1 --> | 5 ns \u003C!-- col-2 --> | 10 s \u003C!-- col-3 --> |\n| L2 cache reference \u003C!-- col-0 --> | Level-2 cache is memory built on a separate chip. \u003C!-- col-1 --> | 7 ns \u003C!-- col-2 --> | 14 s \u003C!-- col-3 --> |\n| Mutex lock\u002Funlock \u003C!-- col-0 --> | Simple synchronization method used to ensure exclusive access to resources shared between many threads. \u003C!-- col-1 --> | 25 ns \u003C!-- col-2 --> | 50 s \u003C!-- col-3 --> |\n| Main memory reference \u003C!-- col-0 --> | Time to reference main memory i.e. RAM. \u003C!-- col-1 --> | 100 ns \u003C!-- col-2 --> | 3m 20s \u003C!-- col-3 --> |\n| Compress 1K bytes with Snappy \u003C!-- col-0 --> | Snappy is a fast data compression and decompression library written in C++ by Google and used in many Google projects like BigTable, MapReduce and other open source projects. \u003C!-- col-1 --> | 3,000 ns \u003C!-- col-2 --> | 1h 40 m \u003C!-- col-3 --> |\n| Send 1K bytes over 1 Gbps network \u003C!-- col-0 --> |  \u003C!-- col-1 --> | 10,000 ns \u003C!-- col-2 --> | 5h 33m 20s \u003C!-- col-3 --> |\n| Read 1 MB sequentially from memory \u003C!-- col-0 --> | Read from RAM. \u003C!-- col-1 --> | 250,000 ns \u003C!-- col-2 --> | 5d 18h 53m 20s \u003C!-- col-3 --> |\n| Round trip within same datacenter \u003C!-- col-0 --> | We can assume that the DNS lookup will be much faster within a datacenter than it is to go over an external router. \u003C!-- col-1 --> | 500,000 ns \u003C!-- col-2 --> | 11d 13h 46m 40s \u003C!-- col-3 --> |\n| Read 1 MB sequentially from SSD disk \u003C!-- col-0 --> | Assumes SSD disk. SSD boasts random data access times of 100000 ns or less. \u003C!-- col-1 --> | 1,000,000 ns \u003C!-- col-2 --> | 23d 3h 33m 20s \u003C!-- col-3 --> |\n| Disk seek \u003C!-- col-0 --> | Disk seek is method to get to the sector and head in the disk where the required data exists. \u003C!-- col-1 --> | 10,000,000 ns \u003C!-- col-2 --> | 231d 11h 33m 20s \u003C!-- col-3 --> |\n| Read 1 MB sequentially from disk \u003C!-- col-0 --> | Assumes regular disk, not SSD. Check the difference in comparison to SSD! \u003C!-- col-1 --> | 20,000,000 ns \u003C!-- col-2 --> | 462d 23h 6m 40s \u003C!-- col-3 --> |\n| Send packet CA->Netherlands->CA \u003C!-- col-0 --> | Round trip for packet data from U.S.A to Europe and back. \u003C!-- col-1 --> | 150,000,000 ns \u003C!-- col-2 --> | 3472d 5h 20m \u003C!-- col-3 --> |\n\n### References:\n\n1. [Designs, Lessons and Advice from Building Large Distributed Systems](http:\u002F\u002Fwww.cs.cornell.edu\u002Fprojects\u002Fladis2009\u002Ftalks\u002Fdean-keynote-ladis2009.pdf)\n2. [Peter Norvig’s post on – Teach Yourself Programming in Ten Years](http:\u002F\u002Fnorvig.com\u002F21-days.html#answers)\n```\n\n\u003C\u002Fdetails>\n\n**3. Metadata Extraction (Basic):**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com -m basic\n```\n\nThis command extracts basic metadata (title, description, keywords) and includes it in the Markdown output.\n\n\u003Cdetails>\n\u003Csummary>Click to view the output\u003C\u002Fsummary>\n\n```markdown\n---\ntitle: \"xkcd: Renormalization\"\n---\n\n\n- [Archive](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [About](\u002Fabout)\n- [Feed](\u002Fatom.xml) • [Email](\u002Fnewsletter\u002F)\n- [TW](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [FB](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [IG](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-Books-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com logo](\u002Fs\u002F0b7742.png)\u003C\u002Fa> A webcomic of romance,\n  sarcasm, math, and language. [Special 10th anniversary edition of WHAT IF?](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F) —revised and annotated with brand-new illustrations and answers to important questions you never thought to ask—out now. Order it [here](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! Renormalization\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\n![Renormalization](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\nPermanent link to this comic: [https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\nImage URL (for hotlinking\u002Fembedding): [https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![Selected Comics](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![Earth temperature timeline](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS Feed](\u002Frss.xml) - [Atom Feed](\u002Fatom.xml) - [Email](\u002Fnewsletter\u002F)\nComics I enjoy:\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F), [SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F), [Dinosaur Comics](https:\u002F\u002Fwww.qwantz.com\u002F), [Oglaf](https:\u002F\u002Foglaf.com\u002F) (nsfw), [A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F), [Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F), [Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F), [Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F), [Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F), [Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F), [Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\nOther things:\n[Tips on technology and government](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[Climate FAQ](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html), [Katharine Hayhoe](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com is best viewed with Netscape Navigator 4.0 or below on a Pentium 3±1 emulated in Javascript on an Apple IIGS\nat a screen resolution of 1024x1. Please enable your ad blockers, disable high-heat drying, and remove your device\nfrom Airplane Mode and set it to Boat Mode. For security reasons, please leave caps lock on while browsing. This work is licensed under a [Creative Commons Attribution-NonCommercial 2.5 License](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F).\n\nThis means you're free to copy and share these comics (but not to sell them). [More details](\u002Flicense.html).\n```\n\n\u003C\u002Fdetails>\n\n**4. Metadata Extraction (Extended):**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com -m extended\n```\n\nThis command extracts extended metadata, including Open Graph, Twitter Card tags, and JSON-LD data, and includes it in\nthe Markdown output.\n\n\u003Cdetails>\n\u003Csummary>Click to view the output\u003C\u002Fsummary>\n\n```markdown\n---\ntitle: \"xkcd: Renormalization\"\nopenGraph:\n  site_name: \"xkcd\"\n  title: \"Renormalization\"\n  url: \"https:\u002F\u002Fxkcd.com\u002F3091\u002F\"\n  image: \"https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization_2x.png\"\ntwitter:\n  card: \"summary_large_image\"\n---\n\n\n- [Archive](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [About](\u002Fabout)\n- [Feed](\u002Fatom.xml) • [Email](\u002Fnewsletter\u002F)\n- [TW](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [FB](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [IG](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-Books-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com logo](\u002Fs\u002F0b7742.png)\u003C\u002Fa> A webcomic of romance,\n  sarcasm, math, and language. [Special 10th anniversary edition of WHAT IF?](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F) —revised and annotated with brand-new illustrations and answers to important questions you never thought to ask—out now. Order it [here](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! Renormalization\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\n![Renormalization](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C Prev](\u002F3090\u002F)\n- [Random](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [Next >](about:blank#)\n- [>|](\u002F)\n\nPermanent link to this comic: [https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\nImage URL (for hotlinking\u002Fembedding): [https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![Selected Comics](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![Earth temperature timeline](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS Feed](\u002Frss.xml) - [Atom Feed](\u002Fatom.xml) - [Email](\u002Fnewsletter\u002F)\nComics I enjoy:\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F), [SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F), [Dinosaur Comics](https:\u002F\u002Fwww.qwantz.com\u002F), [Oglaf](https:\u002F\u002Foglaf.com\u002F) (nsfw), [A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F), [Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F), [Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F), [Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F), [Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F), [Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F), [Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\nOther things:\n[Tips on technology and government](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[Climate FAQ](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html), [Katharine Hayhoe](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com is best viewed with Netscape Navigator 4.0 or below on a Pentium 3±1 emulated in Javascript on an Apple IIGS\nat a screen resolution of 1024x1. Please enable your ad blockers, disable high-heat drying, and remove your device\nfrom Airplane Mode and set it to Boat Mode. For security reasons, please leave caps lock on while browsing. This work is licensed under a [Creative Commons Attribution-NonCommercial 2.5 License](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F).\n\nThis means you're free to copy and share these comics (but not to sell them). [More details](\u002Flicense.html).\n```\n\n\u003C\u002Fdetails>\n\n## Installation\n\n### Using npm\n\n```bash\nnpm install dom-to-semantic-markdown\n```\n\n### Using npx (CLI)\n\n```bash\n> npx d2m@latest -h\nUsage: d2m [options]\n\nConvert DOM to Semantic Markdown\n\nOptions:\n  -V, --version                                   output the version number\n  -i, --input \u003Cfile>                              Input HTML file\n  -o, --output \u003Cfile>                             Output Markdown file\n  -e, --extract-main                              Extract main content\n  -u, --url \u003Curl>                                 URL to fetch HTML content from\n  -t, --track-table-columns                       Enable table column tracking for improved LLM data correlation\n  -m, --include-meta-data \u003C\"basic\" | \"extended\">  Include metadata extracted from the HTML head\n  -p, --use-playwright                            Use Playwright to fetch HTML from URL (handles dynamic content)\n  --playwright-wait-until \u003Cevent>                 Playwright page.goto waitUntil event. Allowed values: load, domcontentloaded, networkidle, commit. Default: load. (default: \"load\")\n  -h, --help                                      display help for command\n```\n\n## Usage\n\n### Browser\n\n```javascript\nimport {convertHtmlToMarkdown} from 'dom-to-semantic-markdown';\n\nconst markdown = convertHtmlToMarkdown(document.body);\nconsole.log(markdown);\n```\n\n### Node.js\n\n```javascript\nimport {convertHtmlToMarkdown} from 'dom-to-semantic-markdown';\nimport {JSDOM} from 'jsdom';\n\nconst html = '\u003Ch1>Hello, World!\u003C\u002Fh1>\u003Cp>This is a \u003Cstrong>test\u003C\u002Fstrong>.\u003C\u002Fp>';\nconst dom = new JSDOM(html);\nconst markdown = convertHtmlToMarkdown(html, {overrideDOMParser: new dom.window.DOMParser()});\nconsole.log(markdown);\n```\n\n### CLI\n\n```bash\nd2m -i input.html -o output.md # Convert input.html to output.md\nd2m -u https:\u002F\u002Fexample.com -o output.md # Fetch and convert a webpage to Markdown\nd2m -i input.html -e # Extract main content from input.html\nd2m -i input.html -t # Enable table column tracking\nd2m -i input.html -m basic # Include basic metadata\nd2m -i input.html -m extended # Include extended metadata\n```\n\n## API\n\n### `convertHtmlToMarkdown(html: string, options?: ConversionOptions): string`\n\nConverts an HTML string to semantic Markdown.\n\n### `convertElementToMarkdown(element: Element, options?: ConversionOptions): string`\n\nConverts an HTML Element to semantic Markdown.\n\n### `ConversionOptions`\n\n* `websiteDomain?: string`: The domain of the website being converted.\n* `extractMainContent?: boolean`: Whether to extract only the main content of the page.\n* `refifyUrls?: boolean`: Whether to convert URLs to reference-style links.\n* `debug?: boolean`: Enable debug logging.\n* `overrideDOMParser?: DOMParser`: Custom DOMParser for Node.js environments.\n* `enableTableColumnTracking?: boolean`: Adds unique identifiers to table columns.\n* `overrideElementProcessing?: (element: Element, options: ConversionOptions, indentLevel: number) => SemanticMarkdownAST[] | undefined`:\n  Custom processing for HTML elements.\n* `processUnhandledElement?: (element: Element, options: ConversionOptions, indentLevel: number) => SemanticMarkdownAST[] | undefined`:\n  Handler for unknown HTML elements.\n* `overrideNodeRenderer?: (node: SemanticMarkdownAST, options: ConversionOptions, indentLevel: number) => string | undefined`:\n  Custom renderer for AST nodes.\n* `renderCustomNode?: (node: CustomNode, options: ConversionOptions, indentLevel: number) => string | undefined`:\n  Renderer for custom AST nodes.\n* `includeMetaData?: 'basic' | 'extended'`: Controls whether to include metadata extracted from the HTML head.\n    - `'basic'`: Includes standard meta tags like title, description, and keywords.\n    - `'extended'`: Includes basic meta tags, Open Graph tags, Twitter Card tags, and JSON-LD data.\n\n## Using the Output with LLMs\n\nThe semantic Markdown produced by this library is optimized for use with Large Language Models (LLMs). To use it effectively:\n\n1. Extract the Markdown content using the library.\n2. Start with a brief instruction or context for the LLM.\n3. Wrap the extracted Markdown in triple backticks (```).\n4. Follow the Markdown with your question or prompt.\n\nExample:\n\n````\nThe following is a semantic Markdown representation of a webpage. Please analyze its content:\n\n```markdown\n{paste your extracted markdown here}\n```\n\n{your question, e.g., \"What are the main points discussed in this article?\"}\n````\n\nThis format helps the LLM understand its task and the context of the content, enabling more accurate and relevant responses to your questions.\n\n## Contributing\n\nContributions are welcome! See the [CONTRIBUTING.md](CONTRIBUTING.md) file for details.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","\u003Ch1 align=\"center\">\n    \u003Cimg width=\"100\" height=\"100\" src=\"d2m_color.svg\" alt=\"DOM to Semantic Markdown Logo\">\u003Cbr>\n    DOM到语义Markdown\n\u003C\u002Fh1>\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fromansku\u002Fdom-to-semantic-markdown\u002Factions\u002Fworkflows\u002Fci.yml)\n[![npm版本](https:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fdom-to-semantic-markdown.svg)](https:\u002F\u002Fbadge.fury.io\u002Fjs\u002Fdom-to-semantic-markdown)\n[![License: ISC](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\n该库将HTML DOM转换为针对大型语言模型（LLMs）优化的语义Markdown格式。它保留了网页内容的语义结构，提取了关键元数据，并且相比原始HTML减少了令牌使用量，从而使LLMs更容易理解和处理信息。\n\n## 主要特性\n\n* **语义结构保留：** 保留`\u003Cheader>`、`\u003Cfooter>`、`\u003Cnav>`等HTML元素的语义。\n* **元数据提取：** 捕获重要的元数据，如标题、描述、关键词、Open Graph标签、Twitter Card标签以及JSON-LD数据。\n* **令牌效率：** 通过URL引用化和内容的简洁表示来优化令牌使用。\n* **主要内容检测：** 自动识别并提取网页的主要内容部分。\n* **表格列跟踪：** 为表格列添加唯一标识符，提高LLMs对跨行数据关联的能力。\n\n## 特殊功能示例\n\n以下是使用CLI工具展示该库特殊功能的示例：\n\n**1. 简单内容提取：**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com\n```\n\n此命令抓取`https:\u002F\u002Fxkcd.com`并将其转换为Markdown\n\n\u003Cdetails>\n\u003Csummary>点击查看输出\u003C\u002Fsummary>\n\n```markdown\n- [存档](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [关于](\u002Fabout)\n- [订阅](\u002Fatom.xml) • [邮件](\u002Fnewsletter\u002F)\n- [TW](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [FB](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [IG](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-书籍-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com标志](\u002Fs\u002F0b7742.png)\u003C\u002Fa> 一部关于爱情、讽刺、数学和语言的网络漫画。[WHAT IF?特别10周年纪念版](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F)——经过修订并配有全新插图及对你从未想过的重要问题的答案——现已上市。请在此处订购[这里](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! 正规化\n- [|\u003C](\u002F1\u002F)\n- [\u003C上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n![正规化](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n此漫画的永久链接：[https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\n图片URL（用于热链\u002F嵌入）：[https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![精选漫画](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![地球温度时间线](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS订阅](\u002Frss.xml) - [Atom订阅](\u002Fatom.xml) - [邮件](\u002Fnewsletter\u002F)\n我喜欢的漫画：\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F)、[SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F)、[恐龙漫画](https:\u002F\u002Fwww.qwantz.com\u002F)、[Oglaf](https:\u002F\u002Foglaf.com\u002F)（成人向）、[A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F)、[Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F)、[Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F)、[Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F)、[Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F)、[Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F)、[Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\n其他内容：\n[关于技术和政府的建议](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[气候常见问题解答](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html), [凯瑟琳·海霍](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com最好在Apple IIGS上用JavaScript模拟的Pentium 3±1处理器，屏幕分辨率为1024x1，并使用Netscape Navigator 4.0或更早版本浏览。请启用广告拦截器，关闭高温烘干功能，并将设备从飞行模式切换至船模式。出于安全考虑，请在浏览时保持Caps Lock键开启。本作品采用[知识共享署名-非商业性使用2.5许可协议](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F)授权。\n\n这意味着您可以自由复制和分享这些漫画（但不得出售）。[更多详情](\u002Flicense.html)。\n```\n\n\u003C\u002Fdetails>\n\n**2. 表格列跟踪：**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fsoftwareyoga.com\u002Flatency-numbers-everyone-should-know\u002F -t -e\n```\n\n此命令抓取并转换主要内容为Markdown，并为表格列添加唯一标识符，以帮助LLMs理解表格结构。\n\n\u003Cdetails>\n\u003Csummary>点击查看输出\u003C\u002Fsummary>\n\n```markdown\n# 每个人都应该知道的延迟数值\n\n## 延迟\n\n在计算机网络中，延迟被定义为数据包从一个指定点传输到另一个指定点所需的时间。\n\n更广泛地说，它是原因发生与结果被观察到之间的时间间隔。\n\n正如你所料，延迟非常重要，非常非常重要。作为程序员，我们都知道从磁盘读取数据比从内存读取要慢，而且L1缓存的速度也比L2缓存快。\n\n但是，你知道这些操作在速度上相差多少个数量级吗？\n\n## 常见操作的延迟\n\n谷歌的杰夫·迪恩对此进行了深入研究，并给出了各种场景下的延迟数据。\n\n随着硬件性能的不断提升，高端硬件的延迟确实在降低，但仍然不可忽视！例如，十年前从磁盘顺序读取1MB数据可能需要20,000,000纳秒，而如今随着SSD的普及，这一时间可能缩短至1,000,000纳秒。然而，即便如此，它也永远无法超越直接从内存中读取的速度。\n\n下表展示了在通用硬件上最常见的操作所对应的延迟。这些数据仅为近似值，会因硬件配置和代码运行环境的不同而有所差异。不过，它们的主要作用在于帮助我们做出明智的技术决策，从而有效降低延迟。\n\n为了更直观地理解延迟数量级的巨大差异，表格中还以L2缓存为基准，将各项延迟按比例放大：假设L1缓存访问耗时1秒。\n\n**在小屏幕设备上，请横向滚动查看表格**\n\n| 操作 \u003C!-- col-0 --> | 备注 \u003C!-- col-1 --> | 延迟 \u003C!-- col-2 --> | 比例化延迟 \u003C!-- col-3 --> |\n| --- | --- | --- | --- |\n| L1缓存访问 \u003C!-- col-0 --> | 一级缓存，通常集成在微处理器芯片上。 \u003C!-- col-1 --> | 0.5纳秒 \u003C!-- col-2 --> | 假设L1缓存访问耗时1秒 \u003C!-- col-3 --> |\n| 分支预测失败 \u003C!-- col-0 --> | 在程序执行过程中，CPU会预测接下来要执行的指令序列。当预测错误时，就会发生分支预测失败，此时必须撤销之前的预测，重新计算并放入执行栈。 \u003C!-- col-1 --> | 5纳秒 \u003C!-- col-2 --> | 10秒 \u003C!-- col-3 --> |\n| L2缓存访问 \u003C!-- col-0 --> | 二级缓存是独立芯片上的存储器。 \u003C!-- col-1 --> | 7纳秒 \u003C!-- col-2 --> | 14秒 \u003C!-- col-3 --> |\n| 互斥锁加锁\u002F解锁 \u003C!-- col-0 --> | 一种简单的同步机制，用于确保多线程共享资源时的互斥访问。 \u003C!-- col-1 --> | 25纳秒 \u003C!-- col-2 --> | 50秒 \u003C!-- col-3 --> |\n| 主存访问 \u003C!-- col-0 --> | 访问主存（即RAM）所需的时间。 \u003C!-- col-1 --> | 100纳秒 \u003C!-- col-2 --> | 3分20秒 \u003C!-- col-3 --> |\n| 使用Snappy压缩1KB数据 \u003C!-- col-0 --> | Snappy是由Google用C++编写的快速数据压缩与解压缩库，广泛应用于BigTable、MapReduce等Google内部项目以及其他开源项目中。 \u003C!-- col-1 --> | 3,000纳秒 \u003C!-- col-2 --> | 1小时40分钟 \u003C!-- col-3 --> |\n| 通过1Gbps网络发送1KB数据 \u003C!-- col-0 --> |  \u003C!-- col-1 --> | 10,000纳秒 \u003C!-- col-2 --> | 5小时33分20秒 \u003C!-- col-3 --> |\n| 从内存顺序读取1MB数据 \u003C!-- col-0 --> | 从RAM中读取数据。 \u003C!-- col-1 --> | 250,000纳秒 \u003C!-- col-2 --> | 5天18小时53分20秒 \u003C!-- col-3 --> |\n| 同一数据中心内的往返通信 \u003C!-- col-0 --> | 可以假设，在数据中心内部进行DNS查询的速度远快于经过外部路由器的情况。 \u003C!-- col-1 --> | 500,000纳秒 \u003C!-- col-2 --> | 11天13小时46分40秒 \u003C!-- col-3 --> |\n| 从SSD顺序读取1MB数据 \u003C!-- col-0 --> | 假设使用SSD硬盘。SSD的随机访问时间通常在100,000纳秒以内或更短。 \u003C!-- col-1 --> | 1,000,000纳秒 \u003C!-- col-2 --> | 23天3小时33分20秒 \u003C!-- col-3 --> |\n| 磁盘寻道 \u003C!-- col-0 --> | 磁盘寻道是指将磁头移动到包含所需数据的扇区的操作。 \u003C!-- col-1 --> | 10,000,000纳秒 \u003C!-- col-2 --> | 231天11小时33分20秒 \u003C!-- col-3 --> |\n| 从普通磁盘顺序读取1MB数据 \u003C!-- col-0 --> | 假设使用传统机械硬盘，而非SSD。请对比与SSD的差异！ \u003C!-- col-1 --> | 20,000,000纳秒 \u003C!-- col-2 --> | 462天23小时6分40秒 \u003C!-- col-3 --> |\n| 数据包从美国往返荷兰再返回美国 \u003C!-- col-0 --> | 数据包在美国和欧洲之间往返一次。 \u003C!-- col-1 --> | 150,000,000纳秒 \u003C!-- col-2 --> | 3472天5小时20分钟 \u003C!-- col-3 --> |\n\n### 参考文献：\n\n1. [构建大型分布式系统的设计、经验与建议](http:\u002F\u002Fwww.cs.cornell.edu\u002Fprojects\u002Fladis2009\u002Ftalks\u002Fdean-keynote-ladis2009.pdf)\n2. [彼得·诺维格关于“自学编程需十年”的文章](http:\u002F\u002Fnorvig.com\u002F21-days.html#answers)\n```\n\n\u003C\u002Fdetails>\n\n**3. 元数据提取（基础）：**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com -m basic\n```\n\n此命令会提取基础元数据（标题、描述、关键词），并将其包含在 Markdown 输出中。\n\n\u003Cdetails>\n\u003Csummary>点击查看输出\u003C\u002Fsummary>\n\n```markdown\n---\ntitle: \"xkcd: 重整化\"\n---\n\n\n- [档案](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [关于](\u002Fabout)\n- [信息流](\u002Fatom.xml) • [邮件](\u002Fnewsletter\u002F)\n- [推特](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [脸书](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [Instagram](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-书籍-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com 标志](\u002Fs\u002F0b7742.png)\u003C\u002Fa> 一部关于爱情、讽刺、数学和语言的网络漫画。[WHAT IF? 十周年特别版](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F)——经过修订并配有全新插图及对那些你从未想过要问的重要问题的解答——现已上市。请在此处订购[这里](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! 重整化\n- [|\u003C](\u002F1\u002F)\n- [\u003C 上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n![重整化](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C 上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n此漫画的永久链接：[https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\n图片 URL（用于直接链接\u002F嵌入）：[https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![精选漫画](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![地球温度时间线](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS 订阅](\u002Frss.xml) - [Atom 订阅](\u002Fatom.xml) - [邮件](\u002Fnewsletter\u002F)\n我喜欢的漫画：\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F)、[SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F)、[Dinosaur Comics](https:\u002F\u002Fwww.qwantz.com\u002F)、[Oglaf](https:\u002F\u002Foglaf.com\u002F)（含成人内容）、[A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F)、[Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F)、[Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F)、[Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F)、[Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F)、[Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F)、[Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\n其他内容：\n[关于科技与政府的建议](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[气候常见问题解答](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html)、[凯瑟琳·海霍](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com 最佳浏览环境为 Netscape Navigator 4.0 或更低版本，在 Apple IIGS 上用 JavaScript 模拟的 Pentium 3±1 处理器，屏幕分辨率为 1024×1。请启用广告拦截器，关闭高温烘干功能，并将设备从飞行模式切换至船模式。出于安全考虑，请在浏览时保持大写锁定键开启。本作品采用 [知识共享署名-非商业性使用 2.5 许可证](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F)。\n\n这意味着您可以自由复制和分享这些漫画（但不得出售）。[更多详情](\u002Flicense.html)。\n```\n\n\u003C\u002Fdetails>\n\n**4. 元数据提取（扩展）：**\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com -m extended\n```\n\n此命令会提取扩展元数据，包括 Open Graph、Twitter Card 标签以及 JSON-LD 数据，并将其包含在 Markdown 输出中。\n\n\u003Cdetails>\n\u003Csummary>点击查看输出\u003C\u002Fsummary>\n\n```markdown\n---\ntitle: \"xkcd: 重整化\"\nopenGraph:\n  site_name: \"xkcd\"\n  title: \"重整化\"\n  url: \"https:\u002F\u002Fxkcd.com\u002F3091\u002F\"\n  image: \"https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization_2x.png\"\ntwitter:\n  card: \"summary_large_image\"\n---\n\n\n- [档案](\u002Farchive)\n- [What If?](https:\u002F\u002Fwhat-if.xkcd.com\u002F)\n- [关于](\u002Fabout)\n- [信息流](\u002Fatom.xml) • [邮件](\u002Fnewsletter\u002F)\n- [推特](https:\u002F\u002Ftwitter.com\u002Fxkcd\u002F) • [脸书](https:\u002F\u002Fwww.facebook.com\u002FTheXKCD\u002F) • [Instagram](https:\u002F\u002Fwww.instagram.com\u002Fxkcd\u002F)\n- [-书籍-](\u002Fbooks\u002F)\n- [What If? 2](\u002Fwhat-if-2\u002F)\n- [WI?](\u002Fwhat-if\u002F) • [TE](\u002Fthing-explainer\u002F) • [HT](\u002Fhow-to\u002F)\n  \u003Ca href=\"\u002F\">![xkcd.com 标志](\u002Fs\u002F0b7742.png)\u003C\u002Fa> 一部关于爱情、讽刺、数学和语言的网络漫画。[WHAT IF? 十周年特别版](https:\u002F\u002Fxkcd.com\u002Fwhat-if\u002F)——经过修订并配有全新插图及对那些你从未想过要问的重要问题的解答——现已上市。请在此处订购[这里](https:\u002F\u002Fbit.ly\u002FWhatIf10th)! 重整化\n- [|\u003C](\u002F1\u002F)\n- [\u003C 上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n![重整化](\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n\n- [|\u003C](\u002F1\u002F)\n- [\u003C 上一页](\u002F3090\u002F)\n- [随机](\u002F\u002Fc.xkcd.com\u002Frandom\u002Fcomic\u002F)\n- [下一页 >](about:blank#)\n- [>|](\u002F)\n\n此漫画的永久链接：[https:\u002F\u002Fxkcd.com\u002F3091\u002F](https:\u002F\u002Fxkcd.com\u002F3091)\n图片 URL（用于直接链接\u002F嵌入）：[https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png](https:\u002F\u002Fimgs.xkcd.com\u002Fcomics\u002Frenormalization.png)\n![精选漫画](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Fa899e84.jpg)\n\n\u003Ca href=\"\u002F\u002Fxkcd.com\u002F1732\u002F\">![地球温度时间线](\u002F\u002Fimgs.xkcd.com\u002Fs\u002Ftemperature.png)\u003C\u002Fa>\n[RSS 订阅](\u002Frss.xml) - [Atom 订阅](\u002Fatom.xml) - [邮件](\u002Fnewsletter\u002F)\n我喜欢的漫画：\n[Three Word Phrase](http:\u002F\u002Fthreewordphrase.com\u002F)、[SMBC](https:\u002F\u002Fwww.smbc-comics.com\u002F)、[Dinosaur Comics](https:\u002F\u002Fwww.qwantz.com\u002F)、[Oglaf](https:\u002F\u002Foglaf.com\u002F)（含成人内容）、[A Softer World](https:\u002F\u002Fwww.asofterworld.com\u002F)、[Buttersafe](https:\u002F\u002Fbuttersafe.com\u002F)、[Perry Bible Fellowship](https:\u002F\u002Fpbfcomics.com\u002F)、[Questionable Content](https:\u002F\u002Fquestionablecontent.net\u002F)、[Buttercup Festival](http:\u002F\u002Fwww.buttercupfestival.com\u002F)、[Homestuck](https:\u002F\u002Fwww.homestuck.com\u002F)、[Junior Scientist Power Hour](https:\u002F\u002Fwww.jspowerhour.com\u002F)\n其他内容：\n[关于科技与政府的建议](https:\u002F\u002Fmedium.com\u002Fcivic-tech-thoughts-from-joshdata\u002Fso-you-want-to-reform-democracy-7f3b1ef10597),\n[气候常见问题解答](https:\u002F\u002Fwww.nytimes.com\u002Finteractive\u002F2017\u002Fclimate\u002Fwhat-is-climate-change.html)、[凯瑟琳·海霍](https:\u002F\u002Ftwitter.com\u002FKHayhoe)\nxkcd.com 最佳浏览环境为 Netscape Navigator 4.0 或更低版本，在 Apple IIGS 上用 JavaScript 模拟的 Pentium 3±1 处理器，屏幕分辨率为 1024×1。请启用广告拦截器，关闭高温烘干功能，并将设备从飞行模式切换至船模式。出于安全考虑，请在浏览时保持大写锁定键开启。本作品采用 [知识共享署名-非商业性使用 2.5 许可证](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc\u002F2.5\u002F)。\n\n这意味着您可以自由复制和分享这些漫画（但不得出售）。[更多详情](\u002Flicense.html)。\n```\n\n\u003C\u002Fdetails>\n\n## 安装\n\n### 使用 npm\n\n```bash\nnpm install dom-to-semantic-markdown\n```\n\n### 使用 npx（CLI）\n\n```bash\n> npx d2m@latest -h\n用法：d2m [选项]\n\n将 DOM 转换为语义 Markdown\n\n选项：\n  -V, --version                                   输出版本号\n  -i, --input \u003C文件>                              输入 HTML 文件\n  -o, --output \u003C文件>                             输出 Markdown 文件\n  -e, --extract-main                              提取主要内容\n  -u, --url \u003Curl>                                 从指定 URL 获取 HTML 内容\n  -t, --track-table-columns                       启用表格列跟踪，以提高 LLM 的数据关联性\n  -m, --include-meta-data \u003C\"basic\" | \"extended\">  包含从 HTML head 中提取的元数据\n  -p, --use-playwright                            使用 Playwright 从 URL 获取 HTML（处理动态内容）\n  --playwright-wait-until \u003Cevent>                 Playwright page.goto 的 waitUntil 事件。允许值：load、domcontentloaded、networkidle、commit。默认值：load。（默认值：”load”）\n  -h, --help                                      显示命令帮助\n```\n\n## 使用方法\n\n### 浏览器\n\n```javascript\nimport {convertHtmlToMarkdown} from 'dom-to-semantic-markdown';\n\nconst markdown = convertHtmlToMarkdown(document.body);\nconsole.log(markdown);\n```\n\n### Node.js\n\n```javascript\nimport {convertHtmlToMarkdown} from 'dom-to-semantic-markdown';\nimport {JSDOM} from 'jsdom';\n\nconst html = '\u003Ch1>Hello, World!\u003C\u002Fh1>\u003Cp>This is a \u003Cstrong>test\u003C\u002Fstrong>.\u003C\u002Fp>';\nconst dom = new JSDOM(html);\nconst markdown = convertHtmlToMarkdown(html, {overrideDOMParser: new dom.window.DOMParser()});\nconsole.log(markdown);\n```\n\n### CLI\n\n```bash\nd2m -i input.html -o output.md # 将 input.html 转换为 output.md\nd2m -u https:\u002F\u002Fexample.com -o output.md # 获取网页并将其转换为 Markdown\nd2m -i input.html -e # 从 input.html 中提取主要内容\nd2m -i input.html -t # 启用表格列跟踪\nd2m -i input.html -m basic # 包含基础元数据\nd2m -i input.html -m extended # 包含扩展元数据\n```\n\n## API\n\n### `convertHtmlToMarkdown(html: string, options?: ConversionOptions): string`\n\n将 HTML 字符串转换为语义 Markdown。\n\n### `convertElementToMarkdown(element: Element, options?: ConversionOptions): string`\n\n将 HTML 元素转换为语义 Markdown。\n\n### `ConversionOptions`\n\n* `websiteDomain?: string`: 正在转换的网站的域名。\n* `extractMainContent?: boolean`: 是否仅提取页面的主要内容。\n* `refifyUrls?: boolean`: 是否将 URLs 转换为引用样式链接。\n* `debug?: boolean`: 启用调试日志。\n* `overrideDOMParser?: DOMParser`: 用于 Node.js 环境的自定义 DOMParser。\n* `enableTableColumnTracking?: boolean`: 为表格列添加唯一标识符。\n* `overrideElementProcessing?: (element: Element, options: ConversionOptions, indentLevel: number) => SemanticMarkdownAST[] | undefined`:\n  自定义 HTML 元素处理逻辑。\n* `processUnhandledElement?: (element: Element, options: ConversionOptions, indentLevel: number) => SemanticMarkdownAST[] | undefined`:\n  未知 HTML 元素的处理函数。\n* `overrideNodeRenderer?: (node: SemanticMarkdownAST, options: ConversionOptions, indentLevel: number) => string | undefined`:\n  自定义 AST 节点渲染器。\n* `renderCustomNode?: (node: CustomNode, options: ConversionOptions, indentLevel: number) => string | undefined`:\n  自定义 AST 节点的渲染器。\n* `includeMetaData?: 'basic' | 'extended'`: 控制是否包含从 HTML head 中提取的元数据。\n    - `'basic'`: 包括标准 meta 标签，如 title、description 和 keywords。\n    - `'extended'`: 包括基础 meta 标签、Open Graph 标签、Twitter Card 标签以及 JSON-LD 数据。\n\n## 将输出与 LLM 结合使用\n\n本库生成的语义 Markdown 经过优化，适合与大型语言模型（LLMs）配合使用。有效使用方法如下：\n\n1. 使用本库提取 Markdown 内容。\n2. 为 LLM 提供简短的指令或上下文。\n3. 将提取的 Markdown 放在三重反引号中（```）。\n4. 在 Markdown 后面加上你的问题或提示。\n\n示例：\n\n````\n以下是某网页的语义 Markdown 表示。请分析其内容：\n\n```markdown\n{在此粘贴你提取的 Markdown}\n```\n\n{你的问题，例如：“本文讨论了哪些主要观点？”}\n````\n\n这种格式有助于 LLM 理解任务和内容背景，从而更准确、更相关地回答你的问题。\n\n## 参与贡献\n\n欢迎参与贡献！详情请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 文件。\n\n## 许可证\n\n本项目采用 MIT 许可证。详细信息请参阅 [LICENSE](LICENSE) 文件。","# dom-to-semantic-markdown 快速上手指南\n\n`dom-to-semantic-markdown` 是一个将 HTML DOM 转换为语义化 Markdown 格式的开源工具。它专为大语言模型（LLM）优化，能够保留网页语义结构、提取关键元数据，并显著减少 Token 消耗，是构建 RAG 应用或进行网页内容分析的理想预处理工具。\n\n## 环境准备\n\n*   **系统要求**：支持 Windows、macOS 和 Linux。\n*   **前置依赖**：需安装 [Node.js](https:\u002F\u002Fnodejs.org\u002F) (建议版本 18.0 或更高)。\n    *   验证安装：在终端运行 `node -v` 和 `npm -v`。\n*   **网络提示**：由于该库托管在 npm 官方源，国内开发者若遇到下载缓慢问题，可临时切换至淘宝镜像源：\n    ```bash\n    npm config set registry https:\u002F\u002Fregistry.npmmirror.com\n    ```\n\n## 安装步骤\n\n本项目无需全局安装，推荐使用 `npx` 直接运行最新版本的 CLI 工具：\n\n```bash\nnpx d2m@latest --version\n```\n\n若需在项目中作为依赖包使用（用于 Node.js 开发）：\n\n```bash\nnpm install dom-to-semantic-markdown\n```\n\n## 基本使用\n\n### 1. 基础内容转换\n将指定 URL 的网页内容转换为简洁的 Markdown 格式，自动识别主要内容区域并清理无关噪声。\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com\n```\n\n### 2. 增强表格解析（推荐 LLM 使用）\n启用 `-t` 参数可为表格列添加唯一标识符，帮助 LLM 更准确地理解表格行列关系；`-e` 参数用于仅提取主要内容。\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fsoftwareyoga.com\u002Flatency-numbers-everyone-should-know\u002F -t -e\n```\n\n### 3. 提取元数据\n使用 `-m basic` 参数可在输出的 Markdown 头部包含标题、描述和关键词等基础元数据（Front Matter 格式）。\n\n```bash\nnpx d2m@latest -u https:\u002F\u002Fxkcd.com -m basic\n```\n\n**输出示例：**\n```markdown\n---\ntitle: \"xkcd: Renormalization\"\n---\n[后续为转换后的正文内容...]\n```","某内容分析团队需要构建一个自动化系统，从数千个新闻网站抓取文章并输入大语言模型（LLM）进行情感分析与摘要生成。\n\n### 没有 dom-to-semantic-markdown 时\n- **噪声干扰严重**：原始 HTML 包含大量导航栏、广告脚本和页脚信息，导致 LLM 难以区分正文与无关内容，分析结果经常跑偏。\n- **令牌成本高昂**：冗余的标签和属性消耗了巨额 Token 配额，使得单次处理成本过高，无法大规模并行运行。\n- **结构化数据丢失**：网页中的表格在纯文本转换后行列对应关系混乱，LLM 无法准确提取其中的财务数据或统计指标。\n- **关键元信息遗漏**：标题、作者、发布时间等藏在 `\u003Cmeta>` 标签中的核心元数据容易被忽略，导致生成的摘要缺乏上下文依据。\n\n### 使用 dom-to-semantic-markdown 后\n- **内容精准聚焦**：工具自动识别并提取主内容区域，过滤掉导航和广告，确保 LLM 只处理高价值的语义文本。\n- **令牌效率倍增**：通过 URL 简化和紧凑的 Markdown 表示，大幅减少 Token 消耗，在同等预算下可处理的网页数量提升数倍。\n- **表格逻辑清晰**：独有的列追踪功能为表格添加标识符，完美保留行列关联，让 LLM 能准确解读复杂的统计数据。\n- **元数据完整注入**：自动抽取并整合标题、描述及 JSON-LD 数据到文档头部，为 LLM 提供完整的背景信息以提升回答质量。\n\ndom-to-semantic-markdown 通过将杂乱的 DOM 树转化为高信噪比的语义 Markdown，显著降低了 LLM 的理解门槛与运行成本。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fromansky_dom-to-semantic-markdown_909959cc.png","romansky","Roman Landenband","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fromansky_31703336.png",null,"Israel","roman.land@gmail.com","https:\u002F\u002Fgithub.com\u002Fromansky",[83,87,91],{"name":84,"color":85,"percentage":86},"TypeScript","#3178c6",98.5,{"name":88,"color":89,"percentage":90},"JavaScript","#f1e05a",1.1,{"name":92,"color":93,"percentage":94},"OpenEdge ABL","#5ce600",0.4,966,24,"2026-04-04T15:29:39","MIT",1,"Linux, macOS, Windows","未说明",{"notes":103,"python":101,"dependencies":104},"该工具是基于 Node.js 的命令行工具（通过 npx 运行），并非 Python 项目，因此不需要 GPU、特定 Python 版本或深度学习框架。它主要用于将 HTML DOM 转换为语义化 Markdown，适用于任何支持 Node.js 和 npx 的环境。",[105],"Node.js (运行 npx 命令所需)",[15,34],"2026-03-27T02:49:30.150509","2026-04-06T07:14:01.367583",[110,115,120,125,130,135],{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},15616,"如何使用命令行工具（CLI）将 HTML 转换为 Markdown？","您可以直接使用 `npx` 运行该工具而无需手动安装。常用命令包括：\n1. 从 URL 获取内容并转换：`npx d2m@latest -u https:\u002F\u002Fexample.com`\n2. 从本地文件输入：`npx d2m@latest -i input.html -o output.md`\n3. 提取主要内容：添加 `-e` 或 `--extract-main` 参数。\n完整帮助信息可通过 `npx d2m@latest -h` 查看。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F1",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},15617,"如何在浏览器扩展或非 Node.js 环境（如 Service Worker）中使用此库？","在非 Node.js 环境中使用时，可能会遇到属性为空导致的错误。请确保升级到最新版本（如 v1.2.7 或更高），维护者已修复了在处理 null 属性时调用 `escapeMarkdownCharacters` 导致的崩溃问题。如果仍遇到问题，请检查 DOM 解析器是否正确初始化，并尝试更新到最新发行版以获取对缺失属性的兼容性修复。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F14",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},15618,"为什么使用 `-e` (extract-main) 选项时会返回空的 Markdown 内容？","这通常是因为特定网站的结构导致主要内容提取逻辑未能识别有效区域。维护者已在版本 `v1.3` 中对此进行了改进。如果您遇到此问题，请尝试升级工具到最新版本：`npx d2m@latest -u \u003C您的 URL>`。如果问题依旧，请提供完整的命令以便进一步排查。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F22",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},15619,"输出结果中包含大量多余的空白行，如何去除？","该库设计上会使用两个换行符来分隔不同部分，但在某些特定元素组合下可能会产生三个或更多换行符。目前库本身尚未默认合并这些多余空行。建议您在获取输出后自行进行后处理，例如使用正则表达式替换：`output.replace(\u002F\\n{2,}\u002Fg, '\\n')` 来将连续的多个换行符缩减为一个。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F18",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},15620,"当锚点（a 标签）内部包含块级元素（如 div）时，生成的 Markdown 格式为何看起来奇怪？","这通常不是错误，而是取决于您使用的 Markdown 渲染器。生成的类似 `[](url) \u003Ca href=\"url\">... \u003C\u002Fa>` 的结构在 GitHub 和 IntelliJ 等主流渲染器中通常能正常显示。如果内部包含标题等块级元素，渲染器会正确解析其层级结构。如果当前输出不符合您的预期，建议检查目标渲染器的兼容性，这通常属于渲染层面的表现差异而非转换逻辑错误。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F10",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},15621,"如何处理库无法识别的自定义 HTML 标签或 XML 命名空间元素？","虽然用户提出了添加钩子（hooks）来处理未识别元素的功能请求，但目前的标准做法是确保您的 HTML 结构尽可能符合标准语义化标签。对于重度依赖自定义命名空间的页面，建议在预处理阶段将这些自定义标签映射为标准 HTML 标签，或者等待未来版本可能加入的 `processUnhandledElement` 回调支持。目前库会尝试忽略或按文本处理未知标签，具体行为视版本而定。","https:\u002F\u002Fgithub.com\u002Fromansky\u002Fdom-to-semantic-markdown\u002Fissues\u002F4",[]]