Support for color property
See original GitHub issueIt seems that the color property could not convert from docx.
<span style="#ff0000">red</span> or <font color="#ff0000">red</font>
But just found another library that fork from you could.(https://github.com/sbabushkin/mammoth-colors.js)
Thanks for sharing this amazing library. 😍
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
color - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The color CSS property sets the foreground color value of an element's text and text decorations, and sets the currentcolor value.
Read more >CSS property: color-scheme | Can I use... Support ... - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web ... CSS property: color-scheme....
Read more >CSS color property - W3Schools
The color property specifies the color of text. Tip: Use a background color combined with a text color that makes the text easy...
Read more >CSS/Properties/color/keywords - W3C Wiki
Color name Hex rgb Decimal
aliceblue #f0f8ff 240,248,255
antiquewhite #faebd7 250,235,215
aqua #00ffff 0,255,255
Read more >Improved dark mode default styling with the color-scheme ...
The color-scheme CSS property and the corresponding meta tag allow developers to opt their pages in to theme-specific defaults of the user ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

By imitate @mahendra119 solution, found out how to convert highlight(bg-color, I think is same)
mammoth/lib/documents.js in function Run()
mammoth/lib/document-to-html.js in function convertRun()
mammoth/lib/docx/body-reader.js in function readRunProperties()
Plugin Maker did not provided any text color parsing. but i have changed some code inside this package to get color parsing work. I am using version 1.4.6 go to mammoth/lib/documents.js and update this code function Run(children, properties) { properties = properties || {}; return { type: types.run, children: children, styleId: properties.styleId || null, styleName: properties.styleName || null, isBold: properties.isBold, isUnderline: properties.isUnderline, isItalic: properties.isItalic, isStrikethrough: properties.isStrikethrough, isSmallCaps: properties.isSmallCaps, verticalAlignment: properties.verticalAlignment || verticalAlignment.baseline, font: properties.font || null, color: properties.color }; } I have added only last line for color property
go to mammoth/lib/document-to-html.js and find convertRun function and add these lines- if (run.color) { paths.push(htmlPaths.element(‘span’, {color : run.color}, {fresh: false})); } i have added span tag here but you can add any tag.
Next, go to mammoth/lib/docx/body-reader.js and find readRunProperties function and add this line- color: element.firstOrEmpty(“w:color”).attributes[“w:val”]
And that’s it. you will get final result like this after parsing <span color="FF0000">Hello</span> but we know this is not valid so we need to convert it in valid CSS like below (result).replace(/color="/g, ‘style="color:#’);
I didn’t got any support for background-color. hopefully plugin maker will provide support for this in next version and give an option whether user want to turn on color parsing or not, instead of disabling by default.