前言介紹
- 這款 WordPress 外掛「Mammoth .docx converter」是 2013-05-11 上架。
- 目前有 30000 個安裝啟用數。
- 上一次更新是 2024-02-24,距離現在已有 435 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.0 以上版本才可以安裝。
- 有 61 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
docx | html | word | paste | office |
內容簡介
Mammoth 設計用於將 .docx 文件(如 Microsoft Word、Google Docs 和 LibreOffice 創建的文件)轉換為 HTML。Mammoth 旨在利用文檔中的語義信息生成簡單和清晰的 HTML,忽略其他細節。例如,Mammoth 將具有樣式 Heading1 的任何段落轉換為 h1 元素,而不是嘗試精確複製標題的樣式(字體、文本大小、顏色等)。這使您可以從 Word 文檔中輕鬆粘貼文本而不會出現混亂。
.docx 使用的結構與 HTML 的結構存在很大的不匹配,這意味著轉換對於較複雜的文檔可能不完美。如果您只使用樣式對文檔進行語義式標記,Mammoth 的效果會更好。
目前支持以下功能:
標題。
列表。
表格。目前忽略表格本身的格式(例如邊框),但文本的格式與文檔中的內容相同。
腳注和尾注。
圖像。
粗體、斜體、上標和下標。
連結。
文本框。文本框的內容被視為獨立的段落,位於包含文本框的段落之後。
內嵌樣式映射
默認情況下,Mammoth 將一些常見的 .docx 樣式映射到 HTML 元素。例如,樣式名為 Heading 1 的段落被轉換為 h1 元素。如果您有自己的自定義樣式文檔,您可以使用內嵌樣式映射告訴 Mammoth 如何映射這些樣式。例如,您可以使用以下樣式映射將樣式名為 WarningHeading 的段落轉換為帶有 class="warning" 的 h1 元素:
p[style-name='WarningHeading'] => h1.warning:fresh
線上工具 可用於將樣式映射嵌入現有文檔中。有關如何編寫樣式映射的細節,請參閱 mammoth.js 文檔。
可以通過配置 Mammoth 來設置用於所有文檔的樣式映射(見下文)。
配置
Mammoth 可通過編寫插件來進行配置。例如,此示例插件 添加了一個自定義樣式映射,並使用文檔變換檢測等寬文本段落並將其轉換為帶有樣式“代碼塊”的段落。
作為 WordPress 外掛,Mammoth 使用 JavaScript 库 mammoth.js 來轉換文檔。每次調用 mammoth.js 時,Mammoth 將使用 JavaScript 全局變量 MAMMOTH_OPTIONS,這允許進行一些定制。應將 MAMMOTH_OPTIONS 定義為返回選項對象的函數。然後,該選項對象將作為 options 參數傳遞給 convertToHtml。mammoth.js 文檔描述了各種可用選項。
MAMMOTH_OPTIONS 將使用 mammoth 作為第一個參數調用。如果需要使用 mammoth.js 中的功能(例如 mammoth.transforms.getDescendantsOfType),這可能很有用。
常見問題解答
原文外掛簡介
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.
Donations
If you’d like to say thanks, feel free to make a donation through Ko-fi.
If you use Mammoth as part of your business, please consider supporting the ongoing maintenance of Mammoth by making a weekly donation through Liberapay.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Mammoth .docx converter」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1.0 | 0.1.1 | 0.1.2 | 0.1.5 | 0.1.6 | 0.1.7 | 0.1.8 | 0.1.9 | 1.0.0 | 1.1.0 | 1.2.0 | 1.3.0 | 1.4.0 | 1.5.0 | 1.6.0 | 1.7.0 | 1.8.0 | 1.9.0 | trunk | 0.1.10 | 0.1.11 | 0.1.12 | 0.1.13 | 0.1.14 | 0.1.15 | 0.1.16 | 0.1.17 | 0.1.18 | 0.1.19 | 0.1.20 | 0.1.21 | 0.1.22 | 0.1.23 | 0.1.24 | 0.1.25 | 1.10.0 | 1.11.0 | 1.12.0 | 1.13.0 | 1.14.0 | 1.15.0 | 1.16.0 | 1.17.0 | 1.18.0 | 1.19.0 | 1.20.0 | 1.21.0 |
延伸相關外掛(你可能也想知道)
ONLYOFFICE Docs 》ONLYOFFICE整合外掛可讓WordPress管理員使用ONLYOFFICE Docs(線上文檔編輯器)協作編輯文件、試算表和簡報。在發佈文章中,編輯器僅以嵌入模式對所有WordPre...。
Faculty Weekly Schedule 》建立一個學期的時間表,以週期格式顯示教職員的辦公時間與課程給網站訪客。, , 主要特色, , 無限制的時間表, 在時間表中設定無限制的辦公時間方塊, 在時間表...。
UORS External Course List 》這款外掛會在 WordPress 網誌的側欄上增加一個「快速預定」小工具。透過此小工具,您可以在側欄上顯示您提供的服務列表,讓顧客能夠在線上預約。在開發此外掛...。
Storehours 》此外掛程式增加了一個商店營業時間的搜尋框。藉由填入「什麼?」和「在哪?」的資訊,使用者可以獲得所有營業時間、聯絡詳細資料等等。, 數百萬家商店的營業...。
Office Visits Logbook Plugin for WordPress 》你的公司還在使用紙張訪客登記表嗎?現在已經普及了數字化和無紙化的方式。無紙化也能節省樹木並保護環境。我們為您的公司提供了一款高效的外掛程式,用於辦...。
lobbycal2press for wordpress 》這個外掛可以在 WordPress 的任何頁面上顯示從 Lobbycal 伺服器上發佈的會議列表。 , 如果您希望使用此外掛顯示您的會議,您需要知道您的 Lobbycal 網址。。
Convert Docx2post 》將 Microsoft Word docx 或文本檔轉換為 WordPress 文章、頁面或自訂文章類型。支援多個上傳和自訂類別。
Cloudapps Course Manager 》**Cloudapps Course Manager 外掛介紹**, , Cloudapps Course Manager 是一個全面的 WordPress 外掛,將 Cloudapps 強大的課程管理功能直接整合到您的 WordPr...。
Doc Mitayo 》### 總結:, 這個 WordPress 外掛可以幫助管理在文章截止日期後的檢視情況,並透過 Slack 傳送通知。通過安裝不同的 shortcode,可以為每篇文章建立獨立的「檢...。
Quotepro Office Widget 》此外掛可在你的 WordPress 網站上直接尋找辦公室的位置。, 我們的辦公室定位器透過 WordPress Widgets API 來悄悄地加入你的網站中,確保對於你的客戶及網站...。
Opening Times UK 》這個外掛程式增加了一個商店營業時間的搜尋框,只要填寫 "什麼?" 和 "在哪裡?" 的資訊,使用者就可以得到所有的營業時間、聯絡詳細資料及更多資訊。, 百萬...。
CPD Search 》這個外掛程式可以作為您英國商業房地產經紀人所使用的 WordPress 佈景主題與 CPD 強大的商業房地產搜尋引擎之間的薄膜,提供全英國最新物業的詳細資訊。換句...。