I m using mammoth js https://github.com/mwilliamson/mammoth.js to convert docs file to HTML this was working fine but i m not getting exactly copy the styling (font, text size, color, etc.). How to format the css style exactly?
var options = {
styleMap: [
"p[style-name='Section Title'] => h1:fresh",
"p[style-name='Subsection Title'] => h2:fresh"
]
};
function transformParagraph(element) {
if (element.alignment === "center" && !element.styleId) {
return {...element, styleId: "Heading2",
styleName: "color:red"};
} else {
return element;
}
}
var paragraph = {
transformDocument: mammoth.transforms.paragraph(transformParagraph),
}
I have tried by adding styleID and styleName but this is not working as expected, did not understand the styleMapping() what it is exactly and how can i use this to add custom css or format CSS as their in the document.
Obviously I'm doing something wrong,i have no idea about the issue,so any help would be much appreciated.This question need to be answered please,thanks in advance.