Mike's corner of the web.


Frequently asked questions

How can I donate?

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.

Why does Mammoth ignore some formatting, such as fonts and colours?

Mammoth aims to produce simple and clean HTML by using semantic information in the document, such as the styles that have been applied to paragraphs. For instance, a paragraph that uses the style "Heading 1" will be mapped to an h1 element in the resulting HTML. This means that you can use the generated HTML on a platform such as WordPress, and it will use the same styling as the rest of the site, making it easier to keep a consistent design.

If you need a tool that will copy the exact formatting of the original document, Mammoth isn't the right tool for the job.

How do I map custom styles in the document?

If you have custom styles in your document, you can map these to the appropriate HTML by using a style map. For instance, if you have a custom heading style called "Warning Heading", and you want to map them to h1 elements with a class of warning, you can use the following style map:

p[style-name='Warning Heading'] => h1.warning:fresh

Details of how to write style maps can be found on the mammoth.js documentation.

When using Mammoth as a CLI or a library, you can specify a custom style map by setting an argument. The specifics are described in the docs for the specific implementation of Mammoth you're using.

You can also embed a style map into a document. This will be used by default whenever Mammoth converts the document. You can use an online tool to do so. You can also do so when using Mammoth as a library, as described in the docs for the implementation of Mammoth you're using.