Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for colors #63

Open
sam-huang1223 opened this issue Jul 23, 2018 · 10 comments
Open

Support for colors #63

sam-huang1223 opened this issue Jul 23, 2018 · 10 comments

Comments

@sam-huang1223
Copy link

Hi! Is there any functionality to allow for colors of text to be transferred over to the output html? If there's no such functionality - how trivial would it be to implement? It's important for my current project that I am able to use have colors in the output. Thanks in advance for your help :)

@GitBruno
Copy link
Contributor

GitBruno commented Jul 24, 2018

Not at the moment, you could hack style maps?

r[style-name='Red'] => span.red

@sam-huang1223
Copy link
Author

Hmm I'll give that a try - thanks for the pointer! The final hurdle is making it work with PowerPoint - I know the xml structures are quite different - how much work do you think it would take? I just need it to work with text in a text box - no need for tables/animations/or anything else unique to PowerPoint

@GitBruno
Copy link
Contributor

I would consider that a big job.

@mwilliamson
Copy link
Owner

Mammoth is intended to be used by mapping styles rather than trying to copy the exact formatting of the original document, so your best bet is to define and use Word styles that have the desired colours, and then map those styles to CSS classes.

Mammoth doesn't support Powerpoint, and as you say the XML is different, so adding support is unlikely.

@kingctan
Copy link

set this line:
r[style-name='Red'] => span.red

not work..
any advice please.
Thanks.

@GitBruno
Copy link
Contributor

Hey @kingctan read the info about style mapping. If you still have trouble, please open a new issue and attach doc, style map and command used. The current issue is about support for colour extraction. Which is not the same as style mapping. Thanks!

@zt50tz
Copy link

zt50tz commented Feb 13, 2019

I have the same need. And i don't have one template on all files i'd like to process. So i can't use style maps feature.

Take a look: https://github.com/zt50tz/python-mammoth/blob/master/recipes/html_attributes.py
There is two new parameters for "run" and "paragraph" classes — "xml_properties" and "html_attributes". So, you can read some data from xml and then set some data to html attributes.

Hope it helps. And try to use style maps if it possible.

@renatosousafilho
Copy link

@zt50tz Will you submit your changes to a pull request for project?

@caramdache
Copy link

@zt50tz Will you submit your changes to a pull request for project?

I just did.

@caramdache
Copy link

Whilst at it, I also implement support for table cell fill colour.

#117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants