[WordPress] 外掛分享: Mammoth .docx converter

首頁外掛目錄 › Mammoth .docx converter
30,000+
安裝啟用
★★★★
4.8/5 分(62 則評價)
6 天前
最後更新
0%
問題解決
WordPress 4.0+ v1.22.0 上架:2013-05-11

內容簡介

Mammoth .docx converter 外掛旨在將 .docx 文件(如 Microsoft Word、Google Docs 和 LibreOffice 創建的文件)轉換為簡潔的 HTML。透過語意化的資訊,Mammoth 能夠有效去除多餘的格式,讓使用者輕鬆從 Word 文件中貼上內容,而不會產生混亂的排版。

【主要功能】
• 支援標題、列表和表格的轉換
• 處理註腳和尾註
• 支援圖片、粗體、斜體等文本格式
• 轉換連結和文本框內容
• 支援自訂樣式映射

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.22.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Mammoth .docx converter」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Mammoth is designed to convert .docx documents, such as those created by Microsoft Word, Google Docs and LibreOffice, and convert them to HTML. Mammoth aims to produce simple and clean HTML by using semantic information in the document, and ignoring other details. For instance, Mammoth converts any paragraph with the style Heading1 to h1 elements, rather than attempting to exactly copy the styling (font, text size, colour, etc.) of the heading. This allows you to paste from Word documents without the usual mess.
There’s a large mismatch between the structure used by .docx and the structure of HTML, meaning that the conversion is unlikely to be perfect for more complicated documents. Mammoth works best if you only use styles to semantically mark up your document.
The following features are currently supported:

Headings.

Lists.

Tables. The formatting of the table itself, such as borders, is currently ignored, but the formatting of the text is treated the same as in the rest of the document.

Footnotes and endnotes.

Images.

Bold, italics, superscript and subscript.

Links.

Text boxes. The contents of the text box are treated as a separate paragraph that appears after the paragraph containing the text box.

Embedded style maps
By default, Mammoth maps some common .docx styles to HTML elements. For instance, a paragraph with the style name Heading 1 is converted to a h1 element. If you have a document with your own custom styles, you can use an embedded style map to tell Mammoth how those styles should be mapped. For instance, you could convert paragraphs with the style named WarningHeading to h1 elements with class="warning" with the style mapping:
p[style-name='WarningHeading'] => h1.warning:fresh

An online tool can be used to embed style maps into an existing document. Details of how to write style maps can be found on the mammoth.js documentation.
A style map to be used for all documents can be set by configuring Mammoth (see below).
Configuration
Mammoth can be configured by writing a separate plugin. For instance, this example plugin adds a custom style map, and uses a document transform to detect paragraphs of monospace text and converts them to paragraphs with the style “Code Block”.
As a WordPress plugin, Mammoth uses the JavaScript library mammoth.js to convert documents. Mammoth will use the JavaScript global MAMMOTH_OPTIONS whenever calling mammoth.js, which allows for some customisation. MAMMOTH_OPTIONS should be defined as a function that returns an options object. This options object will then be passed in as the options argument to convertToHtml. The mammoth.js docs describe the various options available.
The global MAMMOTH_OPTIONS will be called with mammoth as the first argument. This can be useful if you need to use a function from mammoth.js, such as mammoth.transforms.getDescendantsOfType.
FAQs
Answers to some frequently asked questions about Mammoth.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon