{"id":15292111,"url":"https://github.com/ihwf/mammoth-plus","last_synced_at":"2025-10-07T04:32:03.873Z","repository":{"id":64497767,"uuid":"573383910","full_name":"ihwf/mammoth-plus","owner":"ihwf","description":"Convert Word documents (.docx files) to HTML, support math and style","archived":false,"fork":true,"pushed_at":"2022-12-13T06:54:21.000Z","size":1884,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-16T00:31:56.698Z","etag":null,"topics":["docx2html","mathml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mwilliamson/mammoth.js","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ihwf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-02T10:35:55.000Z","updated_at":"2024-12-03T22:30:17.000Z","dependencies_parsed_at":"2023-01-28T08:31:11.558Z","dependency_job_id":null,"html_url":"https://github.com/ihwf/mammoth-plus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihwf%2Fmammoth-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihwf%2Fmammoth-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihwf%2Fmammoth-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihwf%2Fmammoth-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ihwf","download_url":"https://codeload.github.com/ihwf/mammoth-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586525,"owners_count":19014035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docx2html","mathml"],"created_at":"2024-09-30T16:16:34.597Z","updated_at":"2025-10-07T04:31:58.107Z","avatar_url":"https://github.com/ihwf.png","language":"JavaScript","readme":"# mammoth-plus .docx to HTML converter\n\nmammoth-plus is inspired by [Mammoth](https://github.com/mwilliamson/mammoth.js) and based on [Mammoth(v1.5.1)](https://github.com/mwilliamson/mammoth.js).\n\nmammoth-plus expands some features that [Mammoth](https://github.com/mwilliamson/mammoth.js) do not have, such as support math, styling, image size...\n\nThe following features are currently supported:\n\n-   Headings.\n\n-   Lists.\n\n-   Customisable mapping from your own docx styles to HTML.\n    For instance, you could convert `WarningHeading` to `h1.warning` by providing an appropriate style mapping.\n\n-   Tables.\n    The formatting of the table itself, such as borders, is currently ignored,\n    but the formatting of the text is treated the same as in the rest of the document.\n\n-   Footnotes and endnotes.\n\n-   Images.\n\n-   Bold, italics, underlines, strikethrough, superscript, subscript, font color, text highlight color and text align.\n\n-   Links.\n\n-   Line breaks.\n\n-   Text boxes. The contents of the text box are treated as a separate paragraph\n    that appears after the paragraph containing the text box.\n\n-   Comments.\n\n-   math.\n\n## Web demo\n\nTry in [here](https://ihwf.github.io/mammoth-plus/)\n\n## Installation\n\n    npm install mammoth-plus\n\n## Usage\n\n### Library\n\nmammoth-plus can be required/import in the usual way:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n// or\nimport mammothPlus from 'mammoth-plus'\n```\n\nIf not use module system,\nto generate a standalone JavaScript file for the browser,\nuse `mammoth-plus.min.js` (generate using `make setup` if it is not already present).\n`mammothPlus` is set as a window global.\n\n#### Basic conversion\n\nTo convert an existing .docx file to HTML, use `mammothPlus.convertToHtml`:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nmammothPlus\n    .convertToHtml({\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    })\n    .then(function (result) {\n        var html = result.value // The generated HTML\n        var messages = result.messages // Any messages, such as warnings during conversion\n    })\n    .done()\n```\n\nNote that `mammothPlus.convertToHtml` returns a [promise](http://promises-aplus.github.io/promises-spec/).\n\nYou can also extract the raw text of the document by using `mammothPlus.extractRawText`.\nThis will ignore all formatting in the document.\nEach paragraph is followed by two newlines.\n\n```javascript\nmammothPlus\n    .extractRawText({\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    })\n    .then(function (result) {\n        var text = result.value // The raw text\n        var messages = result.messages\n    })\n    .done()\n```\n\n#### Custom style map\n\nBy default,\nmammoth-plus maps some common .docx styles to HTML elements.\nFor instance,\na paragraph with the style name `Heading 1` is converted to a `h1` element.\nYou can pass in a custom map for styles by passing an options object with a `styleMap` property as a second argument to `convertToHtml`.\nA description of the syntax for style maps can be found in the section [\"Writing style maps\"](#writing-style-maps).\nFor instance, if paragraphs with the style name `Section Title` should be converted to `h1` elements,\nand paragraphs with the style name `Subsection Title` should be converted to `h2` elements:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: [\n        \"p[style-name='Section Title'] =\u003e h1:fresh\",\n        \"p[style-name='Subsection Title'] =\u003e h2:fresh\"\n    ]\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\nTo more easily support style maps stored in text files,\n`styleMap` can also be a string.\nEach line is treated as a separate style mapping,\nignoring blank lines and lines starting with `#`:\n\n```javascript\nvar options = {\n    styleMap:\n        \"p[style-name='Section Title'] =\u003e h1:fresh\\n\" +\n        \"p[style-name='Subsection Title'] =\u003e h2:fresh\"\n}\n```\n\nUser-defined style mappings are used in preference to the default style mappings.\nTo stop using the default style mappings altogether,\nset `options.includeDefaultStyleMap` to `false`:\n\n```javascript\nvar options = {\n    styleMap: [\n        \"p[style-name='Section Title'] =\u003e h1:fresh\",\n        \"p[style-name='Subsection Title'] =\u003e h2:fresh\"\n    ],\n    includeDefaultStyleMap: false\n}\n```\n\n#### Custom image handlers\n\nBy default, images are converted to `\u003cimg\u003e` elements with the source included inline in the `src` attribute.\nThis behaviour can be changed by setting the `convertImage` option to an [image converter](#image-converters) .\n\nFor instance, the following would replicate the default behaviour:\n\n```javascript\nvar options = {\n    convertImage: mammothPlus.images.imgElement(function (image) {\n        return image.read('base64').then(function (imageBuffer) {\n            return {\n                src: 'data:' + image.contentType + ';base64,' + imageBuffer\n            }\n        })\n    })\n}\n```\n\n#### Bold\n\nBy default, bold text is wrapped in `\u003cstrong\u003e` tags.\nThis behaviour can be changed by adding a style mapping for `b`.\nFor instance, to wrap bold text in `\u003cem\u003e` tags:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: ['b =\u003e em']\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\n#### Italic\n\nBy default, italic text is wrapped in `\u003cem\u003e` tags.\nThis behaviour can be changed by adding a style mapping for `i`.\nFor instance, to wrap italic text in `\u003cstrong\u003e` tags:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: ['i =\u003e strong']\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\n#### Underline\n\nBy default, the underlining of any text is ignored since underlining can be confused with links in HTML documents.\nThis behaviour can be changed by adding a style mapping for `u`.\nFor instance, suppose that a source document uses underlining for emphasis.\nThe following will wrap any explicitly underlined source text in `\u003cem\u003e` tags:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: ['u =\u003e em']\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\n#### Strikethrough\n\nBy default, strikethrough text is wrapped in `\u003cs\u003e` tags.\nThis behaviour can be changed by adding a style mapping for `strike`.\nFor instance, to wrap strikethrough text in `\u003cdel\u003e` tags:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: ['strike =\u003e del']\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\n#### Comments\n\nBy default, comments are ignored.\nTo include comments in the generated HTML,\nadd a style mapping for `comment-reference`.\nFor instance:\n\n```javascript\nvar mammothPlus = require('mammoth-plus')\n\nvar options = {\n    styleMap: ['comment-reference =\u003e sup']\n}\nmammothPlus.convertToHtml(\n    {\n        path: 'path/to/document.docx', // in node.js\n        arrayBuffer: 'array buffer containing a .docx file' // in browser\n    },\n    options\n)\n```\n\nComments will be appended to the end of the document,\nwith links to the comments wrapped using the specified style mapping.\n\n### CLI\n\nYou can convert docx files by passing the path to the docx file and the output file.\nFor instance:\n\n    mammoth-plus document.docx output.html\n\nIf no output file is specified, output is written to stdout instead.\n\nThe output is an HTML fragment, rather than a full HTML document, encoded with UTF-8.\nSince the encoding is not explicitly set in the fragment,\nopening the output file in a web browser may cause Unicode characters to be rendered incorrectly if the browser doesn't default to UTF-8.\n\n#### Images\n\nBy default, images are included inline in the output HTML.\nIf an output directory is specified by `--output-dir`,\nthe images are written to separate files instead.\nFor instance:\n\n    mammoth-plus document.docx --output-dir=output-dir\n\nExisting files will be overwritten if present.\n\n#### Styles\n\nA custom style map can be read from a file using `--style-map`.\nFor instance:\n\n    mammoth-plus document.docx output.html --style-map=custom-style-map\n\nWhere `custom-style-map` looks something like:\n\n    p[style-name='Aside Heading'] =\u003e div.aside \u003e h2:fresh\n    p[style-name='Aside Text'] =\u003e div.aside \u003e p:fresh\n\nA description of the syntax for style maps can be found in the section [\"Writing style maps\"](#writing-style-maps).\n\n#### Markdown\n\nMarkdown support is deprecated.\nGenerating HTML and using a separate library to convert the HTML to Markdown is recommended,\nand is likely to produce better results.\n\nUsing `--output-format=markdown` will cause Markdown to be generated.\nFor instance:\n\n    mammoth-plus document.docx --output-format=markdown\n\n### API\n\n#### `mammothPlus.convertToHtml(input, options)`\n\nConverts the source document to HTML.\n\n-   `input`: an object describing the source document.\n    On node.js, the following inputs are supported:\n\n    -   `{path: path}`, where `path` is the path to the .docx file.\n    -   `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file.\n\n    In the browser, the following inputs are supported:\n\n    -   `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file.\n\n-   `options` (optional): options for the conversion.\n    May have the following properties:\n\n    -   `styleMap`: controls the mapping of Word styles to HTML.\n        If `options.styleMap` is a string,\n        each line is treated as a separate style mapping,\n        ignoring blank lines and lines starting with `#`:\n        If `options.styleMap` is an array,\n        each element is expected to be a string representing a single style mapping.\n        See [\"Writing style maps\"](#writing-style-maps) for a reference to the syntax for style maps.\n\n    -   `includeEmbeddedStyleMap`: by default,\n        if the document contains an embedded style map, then it is combined with the default style map.\n        To ignore any embedded style maps,\n        set `options.includeEmbeddedStyleMap` to `false`.\n\n    -   `includeDefaultStyleMap`: by default,\n        the style map passed in `styleMap` is combined with the default style map.\n        To stop using the default style map altogether,\n        set `options.includeDefaultStyleMap` to `false`.\n\n    -   `convertImage`: by default, images are converted to `\u003cimg\u003e` elements with the source included inline in the `src` attribute.\n        Set this option to an [image converter](#image-converters) to override the default behaviour.\n\n    -   `ignoreEmptyParagraphs`: by default, empty paragraphs are ignored.\n        Set this option to `false` to preserve empty paragraphs in the output.\n\n    -   `idPrefix`:\n        a string to prepend to any generated IDs,\n        such as those used by bookmarks, footnotes and endnotes.\n        Defaults to an empty string.\n\n    -   `transformDocument`: if set,\n        this function is applied to the document read from the docx file before the conversion to HTML.\n        The API for document transforms should be considered unstable.\n        See [document transforms](#document-transforms).\n\n-   Returns a promise containing a result.\n    This result has the following properties:\n\n    -   `value`: the generated HTML\n\n    -   `messages`: any messages, such as errors and warnings, generated during the conversion\n\n#### `mammothPlus.convertToMarkdown(input, options)`\n\nMarkdown support is deprecated.\nGenerating HTML and using a separate library to convert the HTML to Markdown is recommended,\nand is likely to produce better results.\n\nConverts the source document to Markdown.\nThis behaves the same as `convertToHtml`,\nexcept that the `value` property of the result contains Markdown rather than HTML.\n\n#### `mammothPlus.extractRawText(input)`\n\nExtract the raw text of the document.\nThis will ignore all formatting in the document.\nEach paragraph is followed by two newlines.\n\n-   `input`: an object describing the source document.\n    On node.js, the following inputs are supported:\n\n    -   `{path: path}`, where `path` is the path to the .docx file.\n    -   `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file.\n\n    In the browser, the following inputs are supported:\n\n    -   `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file.\n\n-   Returns a promise containing a result.\n    This result has the following properties:\n\n    -   `value`: the raw text\n\n    -   `messages`: any messages, such as errors and warnings\n\n#### `mammothPlus.embedStyleMap(input, styleMap)`\n\nGiven an existing docx file,\n`embedStyleMap` will generate a new docx file with the passed style map embedded.\nWhen the new docx file is read by mammoth-plus,\nit will use the embedded style map.\n\n-   `input`: an object describing the source document.\n    On node.js, the following inputs are supported:\n\n    -   `{path: path}`, where `path` is the path to the .docx file.\n    -   `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file.\n\n    In the browser, the following inputs are supported:\n\n    -   `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file.\n\n-   `styleMap`: the style map to embed.\n\n-   Returns a promise.\n    Call `toBuffer()` on the value inside the promise to get a `Buffer` representing the new document.\n\nFor instance:\n\n```javascript\nmammothPlus\n    .embedStyleMap(\n        { path: sourcePath },\n        \"p[style-name='Section Title'] =\u003e h1:fresh\"\n    )\n    .then(function (docx) {\n        fs.writeFile(destinationPath, docx.toBuffer(), callback)\n    })\n```\n\n#### Messages\n\nEach message has the following properties:\n\n-   `type`: a string representing the type of the message, such as `\"warning\"` or\n    `\"error\"`\n\n-   `message`: a string containing the actual message\n\n-   `error` (optional): the thrown exception that caused this message, if any\n\n#### Image converters\n\nAn image converter can be created by calling `mammothPlus.images.imgElement(func)`.\nThis creates an `\u003cimg\u003e` element for each image in the original docx.\n`func` should be a function that has one argument `image`.\nThis argument is the image element being converted,\nand has the following properties:\n\n-   `read([encoding])`: read the image file with the specified encoding.\n    If no encoding is specified, a `Buffer` is returned.\n\n-   `contentType`: the content type of the image, such as `image/png`.\n\n`func` should return an object (or a promise of an object) of attributes for the `\u003cimg\u003e` element.\nAt a minimum, this should include the `src` attribute.\nIf any alt text is found for the image,\nthis will be automatically added to the element's attributes.\n\nFor instance, the following replicates the default image conversion:\n\n```javascript\nmammothPlus.images.imgElement(function (image) {\n    return image.read('base64').then(function (imageBuffer) {\n        return {\n            src: 'data:' + image.contentType + ';base64,' + imageBuffer\n        }\n    })\n})\n```\n\n`mammothPlus.images.dataUri` is the default image converter.\n\n### Document transforms\n\n**The API for document transforms should be considered unstable,\nand may change between any versions.\nIf you rely on this behaviour,\nyou should pin to a specific version of mammoth-plus.js,\nand test carefully before updating.**\n\nmammoth-plus allows a document to be transformed before it is converted.\nFor instance,\nsuppose that document has not been semantically marked up,\nbut you know that any centre-aligned paragraph should be a heading.\nYou can use the `transformDocument` argument to modify the document appropriately:\n\n```javascript\nfunction transformElement(element) {\n    if (element.children) {\n        var children = _.map(element.children, transformElement)\n        element = { ...element, children: children }\n    }\n\n    if (element.type === 'paragraph') {\n        element = transformParagraph(element)\n    }\n\n    return element\n}\n\nfunction transformParagraph(element) {\n    if (element.alignment === 'center' \u0026\u0026 !element.styleId) {\n        return { ...element, styleId: 'Heading2' }\n    } else {\n        return element\n    }\n}\n\nvar options = {\n    transformDocument: transformElement\n}\n```\n\nThe return value of `transformDocument` is used during HTML generation.\n\nThe above can be written more succinctly using the helper `mammothPlus.transforms.paragraph`:\n\n```javascript\nfunction transformParagraph(element) {\n    if (element.alignment === 'center' \u0026\u0026 !element.styleId) {\n        return { ...element, styleId: 'Heading2' }\n    } else {\n        return element\n    }\n}\n\nvar options = {\n    transformDocument: mammothPlus.transforms.paragraph(transformParagraph)\n}\n```\n\nOr if you want paragraphs that have been explicitly set to use monospace fonts to represent code:\n\n```javascript\nconst monospaceFonts = ['consolas', 'courier', 'courier new']\n\nfunction transformParagraph(paragraph) {\n    var runs = mammothPlus.transforms.getDescendantsOfType(paragraph, 'run')\n    var isMatch =\n        runs.length \u003e 0 \u0026\u0026\n        runs.every(function (run) {\n            return (\n                run.font \u0026\u0026\n                monospaceFonts.indexOf(run.font.toLowerCase()) !== -1\n            )\n        })\n    if (isMatch) {\n        return {\n            ...paragraph,\n            styleId: 'code',\n            styleName: 'Code'\n        }\n    } else {\n        return paragraph\n    }\n}\n\nvar options = {\n    transformDocument: mammothPlus.transforms.paragraph(transformParagraph),\n    styleMap: [\"p[style-name='Code'] =\u003e pre:separator('\\n')\"]\n}\n```\n\n#### `mammothPlus.transforms.paragraph(transformParagraph)`\n\nReturns a function that can be used as the `transformDocument` option.\nThis will apply the function `transformParagraph` to each paragraph element.\n`transformParagraph` should return the new paragraph.\n\n#### `mammothPlus.transforms.run(transformRun)`\n\nReturns a function that can be used as the `transformDocument` option.\nThis will apply the function `transformRun` to each run element.\n`transformRun` should return the new run.\n\n#### `mammothPlus.transforms.getDescendants(element)`\n\nGets all descendants of an element.\n\n#### `mammothPlus.transforms.getDescendantsOfType(element, type)`\n\nGets all descendants of a particular type of an element.\nFor instance, to get all runs within an element `paragraph`:\n\n```javascript\nvar runs = mammothPlus.transforms.getDescendantsOfType(paragraph, 'run')\n```\n\n## Writing style maps\n\nA style map is made up of a number of style mappings separated by new lines.\nBlank lines and lines starting with `#` are ignored.\n\nA style mapping has two parts:\n\n-   On the left, before the arrow, is the document element matcher.\n-   On the right, after the arrow, is the HTML path.\n\nWhen converting each paragraph,\nmammoth-plus finds the first style mapping where the document element matcher matches the current paragraph.\nmammoth-plus then ensures the HTML path is satisfied.\n\n### Freshness\n\nWhen writing style mappings, it's helpful to understand mammoth-plus's notion of freshness.\nWhen generating, mammoth-plus will only close an HTML element when necessary.\nOtherwise, elements are reused.\n\nFor instance, suppose one of the specified style mappings is `p[style-name='Heading 1'] =\u003e h1`.\nIf mammoth-plus encounters a .docx paragraph with the style name `Heading 1`,\nthe .docx paragraph is converted to a `h1` element with the same text.\nIf the next .docx paragraph also has the style name `Heading 1`,\nthen the text of that paragraph will be appended to the _existing_ `h1` element,\nrather than creating a new `h1` element.\n\nIn most cases, you'll probably want to generate a new `h1` element instead.\nYou can specify this by using the `:fresh` modifier:\n\n`p[style-name='Heading 1'] =\u003e h1:fresh`\n\nThe two consecutive `Heading 1` .docx paragraphs will then be converted to two separate `h1` elements.\n\nReusing elements is useful in generating more complicated HTML structures.\nFor instance, suppose your .docx contains asides.\nEach aside might have a heading and some body text,\nwhich should be contained within a single `div.aside` element.\nIn this case, style mappings similar to `p[style-name='Aside Heading'] =\u003e div.aside \u003e h2:fresh` and\n`p[style-name='Aside Text'] =\u003e div.aside \u003e p:fresh` might be helpful.\n\n### Document element matchers\n\n#### Paragraphs, runs and tables\n\nMatch any paragraph:\n\n```\np\n```\n\nMatch any run:\n\n```\nr\n```\n\nMatch any table:\n\n```\ntable\n```\n\nTo match a paragraph, run or table with a specific style,\nyou can reference the style by name.\nThis is the style name that is displayed in Microsoft Word or LibreOffice.\nFor instance, to match a paragraph with the style name `Heading 1`:\n\n```\np[style-name='Heading 1']\n```\n\nYou can also match a style name by prefix.\nFor instance, to match a paragraph where the style name starts with `Heading`:\n\n```\np[style-name^='Heading']\n```\n\nStyles can also be referenced by style ID.\nThis is the ID used internally in the .docx file.\nTo match a paragraph or run with a specific style ID,\nappend a dot followed by the style ID.\nFor instance, to match a paragraph with the style ID `Heading1`:\n\n```\np.Heading1\n```\n\n#### Bold\n\nMatch explicitly bold text:\n\n```\nb\n```\n\nNote that this matches text that has had bold explicitly applied to it.\nIt will not match any text that is bold because of its paragraph or run style.\n\n#### Italic\n\nMatch explicitly italic text:\n\n```\ni\n```\n\nNote that this matches text that has had italic explicitly applied to it.\nIt will not match any text that is italic because of its paragraph or run style.\n\n#### Underline\n\nMatch explicitly underlined text:\n\n```\nu\n```\n\nNote that this matches text that has had underline explicitly applied to it.\nIt will not match any text that is underlined because of its paragraph or run style.\n\n#### Strikethough\n\nMatch explicitly struckthrough text:\n\n```\nstrike\n```\n\nNote that this matches text that has had strikethrough explicitly applied to it.\nIt will not match any text that is struckthrough because of its paragraph or run style.\n\n#### All caps\n\nMatch explicitly all caps text:\n\n```\nall-caps\n```\n\nNote that this matches text that has had all caps explicitly applied to it.\nIt will not match any text that is all caps because of its paragraph or run style.\n\n#### Small caps\n\nMatch explicitly small caps text:\n\n```\nsmall-caps\n```\n\nNote that this matches text that has had small caps explicitly applied to it.\nIt will not match any text that is small caps because of its paragraph or run style.\n\n#### Ignoring document elements\n\nUse `!` to ignore a document element.\nFor instance, to ignore any paragraph with the style `Comment`:\n\n```\np[style-name='Comment'] =\u003e !\n```\n\n### HTML paths\n\n#### Single elements\n\nThe simplest HTML path is to specify a single element.\nFor instance, to specify an `h1` element:\n\n```\nh1\n```\n\nTo give an element a CSS class,\nappend a dot followed by the name of the class:\n\n```\nh1.section-title\n```\n\nTo require that an element is fresh, use `:fresh`:\n\n```\nh1:fresh\n```\n\nModifiers must be used in the correct order:\n\n```\nh1.section-title:fresh\n```\n\n#### Separators\n\nTo specify a separator to place between the contents of paragraphs that are collapsed together,\nuse `:separator('SEPARATOR STRING')`.\n\nFor instance, suppose a document contains a block of code where each line of code is a paragraph with the style `Code Block`.\nWe can write a style mapping to map such paragraphs to `\u003cpre\u003e` elements:\n\n```\np[style-name='Code Block'] =\u003e pre\n```\n\nSince `pre` isn't marked as `:fresh`,\nconsecutive `pre` elements will be collapsed together.\nHowever, this results in the code all being on one line.\nWe can use `:separator` to insert a newline between each line of code:\n\n```\np[style-name='Code Block'] =\u003e pre:separator('\\n')\n```\n\n#### Nested elements\n\nUse `\u003e` to specify nested elements.\nFor instance, to specify `h2` within `div.aside`:\n\n```\ndiv.aside \u003e h2\n```\n\nYou can nest elements to any depth.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihwf%2Fmammoth-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fihwf%2Fmammoth-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihwf%2Fmammoth-plus/lists"}