离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
Word 转 HTML——本地抽取正文与图片,产出单文件网页Word to HTML locally — body and images in one file
mammoth 的设计取向值得先知道,因为它决定了产物的样子:它读的是"这段是标题 1"这样的语义,而不是"这行用了 16 磅加粗"这样的外观,然后按自己的映射写成 HTML 标签。好处是产物干净、可直接上网页或再转 Markdown;代价是 Word 里看到的排版不会跟过来——分栏、字号、颜色、页边距这些外观信息在这一步被有意丢掉。想要"看起来一样"的产物,请走 Word → PDF。mammoth’s design is worth knowing first because it sets what you get: it reads meaning — "this is Heading 1" — rather than appearance — "this line is 16pt bold" — and writes HTML tags from that mapping. The upside is clean output you can publish or convert on to Markdown. The cost is that your Word layout does not come along: columns, font sizes, colours and margins are deliberately dropped at this step. For an output that *looks* the same, take Word to PDF.
这条链路怎么走How the route runs
Word (.docx)Word (.docx) HTMLHTML
共 1 步,由扩展的路径搜索自动选出,中间产物不落盘。1 step, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 标题层级:样式名为 Heading 1–4 的段落映射为 `<h1>`–`<h4>`,标题(Title)与小标题(Subtitle)也各归其位Heading levels: paragraphs styled Heading 1–4 map to `<h1>`–`<h4>`, and Title and Subtitle each land where they belong
- 有序与无序列表、粗体与斜体(含以字符样式命名的 Strong / Emphasis)、超链接Ordered and unordered lists, bold and italics — including those applied by character style name — and hyperlinks
- 表格:mammoth 默认会把表格结构写成 `<table>`,单元格内容随行内格式一起过来Tables: mammoth writes table structure as `<table>` by default, with cell content travelling alongside its inline formatting
- 文档内的图片读成 data URI 内联进 HTML——所以这一个文件本身是完整的,不需要另附一个 images 目录Images inside the document are read out as data URIs inlined into the HTML, so the single file is complete and needs no companion images folder
- 输出前经 DOMPurify 的 html 白名单净化,脚本与事件属性不会进产物;`target` 属性被显式保留,链接仍可在新标签打开The output passes DOMPurify’s html profile before it is written, so scripts and event attributes do not reach the file; the `target` attribute is kept on purpose so links still open in a new tab
- 远程子资源在写文件前被剥掉:`<img src="http://…">`、样式里的 `url()` 与 `@import` 都不留,所以这张页面被打开时不会替你发请求(链接本身是正文,留着)Remote subresources are cut before the file is written — `<img src="http://…">`, `url()` and `@import` in styles — so the page issues no request on your behalf when you open it. A link is content, and stays
- 如果这份 .docx 里塞着内嵌的 MHT 块(altChunk——本扩展自己的 HTML → DOCX 产物就是这种形状),空结果时会识别并救回内嵌的那份 HTMLIf the .docx carries an embedded MHT part (an altChunk — which is exactly what this extension’s own HTML → DOCX output is), an empty result triggers recovery of that embedded HTML
如实说明的限制What it does not do
- 外观不进 HTML:字体、字号、颜色、行距、页边距、分栏与分页位置全部丢失,产物由浏览器排版Appearance does not enter the HTML: fonts, sizes, colours, leading, margins, columns and page breaks are lost, and the browser does the typesetting
- 页眉页脚、脚注与尾注、批注、修订记录、文本框、艺术字、图表与嵌入对象都不提取Headers and footers, footnotes and endnotes, comments, tracked changes, text boxes, WordArt, charts and embedded objects are not extracted
- 只读 .docx(Office Open XML 的 zip 包);97–2003 的旧版二进制 .doc 不支持,先在别处存成 .docx 再拿来Only .docx (the zipped Office Open XML package) is read; legacy binary .doc from 97–2003 is not, so save it as .docx first elsewhere
- 样式名不匹配默认映射时(比如自定义的"报告正文"样式),那段文字仍会输出,只是落在 `<p>` 而不是你以为的标签When a style name falls outside the default mapping — a custom "Report Body" style, say — the text still comes out, just into a `<p>` rather than the tag you expected
- 内联图片会让 HTML 明显变大:一本带几十张图的文档,产物体积接近原文档里的图片总和Inlined images make the HTML visibly larger: a document with dozens of pictures produces roughly the sum of those pictures in added bytes
- 跟得过去的位图类型是有限的几种(`png / jpeg / gif / webp / bmp / avif / ico`):TIFF、EMF、WMF 这类内嵌图在写出前会被剥掉 `src`,那一格空着,产物不为它计数Only a limited set of raster types comes across (`png / jpeg / gif / webp / bmp / avif / ico`): a TIFF, EMF or WMF inside the file loses its `src` on the way out, leaving an empty slot that the artifact does not count
实操提示Working with it
- 同一份 .docx 还能转 Markdown(同样是语义映射)、纯文本、PDF 与 PNG;四者取舍不同,见各自页面The same .docx can also go to Markdown on the same semantic mapping, or to plain text, PDF and PNG; each trade-off is spelled out on its own page
- 单个上限 100 MB,一批最多 200 个文件;单个文件失败只报该文件,其余继续100 MB per file and up to 200 files per batch; one unreadable file reports only itself while the rest continue
- 正文提不出任何内容时会明确报"文档没有可转换内容",而不是安静地给你一个空白页When nothing at all can be extracted the run says so as an empty document rather than handing you a quietly blank page
常见问题Questions people actually ask
为什么表格里的底纹和对齐没了?Why did the table shading and alignment disappear?
因为这条转换取结构不取外观:行列与单元格内容保留,`<table>` 因此成立;而底纹、列宽、单元格对齐属于 Word 的视觉层,不在语义映射范围内。要视觉上原样,走 Word → PDF。Because this route takes structure, not appearance: rows, cells and their content survive, which is what makes a `<table>` possible, while shading, column widths and cell alignment live in Word’s visual layer and are outside the semantic mapping. For visual fidelity, Word to PDF is the route.
HTML 能直接当网页发布吗?Can I publish the HTML as a web page?
可以,产物是自包含的单个文件:图片以内联数据存在,样式由外壳统一给。要注意的是它的排版由你的 CSS 而不是 Word 决定——发出去之前自己看一眼,尤其列表嵌套与宽表格。Yes — the file is a self-contained single document, with pictures carried as inline data and one shared style shell. What to check before publishing is that the layout is now yours rather than Word’s, especially nested lists and wide tables.
为什么有些内容我在 Word 里看得到,产物里却没有?Some of what I see in Word is missing from the output — why?
最常见的原因是那部分内容不住在正文流里:页眉页脚、脚注尾注、批注、文本框与图表都在正文之外,这条转换不提取它们。判断方法是看它在 Word 里是否随正文一起重排——不重排的多半就是这一类。The usual reason is that the content does not live in the text flow: headers and footers, footnotes and endnotes, comments, text boxes and charts all sit outside it, and this route does not read them. The test in Word is whether the content reflows with the body — what does not reflow is most likely in that excluded set.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub