-
Notifications
You must be signed in to change notification settings - Fork 647
Open
Description
Hi, we are using the WordPress plugin version of Mammoth and trying to add:
.footnotesclass to the endnotes<ol>element.footnoteclass to each<li>element
but not sure how to accomplish this. My current code for the mammoth-options custom WordPress plugin:
function MAMMOTH_OPTIONS(mammoth) {
var styleMap = [
"p[style-name='endnote text'] => span.footnotes > span.footnote", // custom
"r[style-name='endnote reference'] =>",
];
function setEndnoteTextListClass(styleName) {
return mammoth.transforms.paragraph(function(footnote) {
var runs = mammoth.transforms.getDescendantsOfType(footnote, "run");
var isMatch = runs.length > 0 && runs.every(function(run) {
// add .footnotes class to the <ol> element
// add .footnote class to each <li> element
});
if (isMatch) {
return // updated html doc.
} else {
return footnote;
}
});
}
return {
styleMap: styleMap,
// If a endnotes <ol> element add .footnotes class to the element
transformDocument: setEndnoteTextListClass(
"Endnote Text",
)
};
}Our workaround was to use the styleMap:
"p[style-name='endnote text'] => span.footnotes > span.footnote"and this works, but would prefer to add the .footnotes class to the <ol> parent and .footnote class to each
HTML output that you'd expect:
<ol class="footnotes">
<li class="footnote" id="post-23140-endnote-1">
Footnote 1 text
</li>
<li class="footnote" id="post-23140-endnote-2">
Footnote 2 text
</li>
</ol>Thank you for the help!
- the operating system and version: M1 Mac OS
- if running in the browser: Google Chrome
- the browser and version: Version 129.0.6668.59 (Official Build) (arm64)
- whether you get the same issue in other browsers: yes
- if running on node.js, the version you're using: WordPress Plugin version
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels