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

Underlining doesn't work when color isn't also specified #36

Closed
andalman opened this issue Jan 25, 2023 · 3 comments
Closed

Underlining doesn't work when color isn't also specified #36

andalman opened this issue Jan 25, 2023 · 3 comments

Comments

@andalman
Copy link
Contributor

If you have an attributed string and apply NSAttributedString.Key.underlineStyle to it, the generated docx will not include that underline. This is because DocX requires that foregroundColor must be set, otherwise the <w:u> element won't be output.

Since the w:color value is optional in the docx, I don't think this should be required. I have a fix ready that makes the color argument Optional in the underlineElement function.

That said, I'm not sure using the foregroundColor is correct either, since NSAttributedString.Key.underlineColor exists for the purpose. If existing code relies on this behavior, though, we could have DocX check for the underlineColor and, if that isn't found, then use the foregroundColor if it exists. Thoughts?

@shinjukunian
Copy link
Owner

Hi
thank you for catching this. It seems my original implementation of underlines was a bit lackadaisical. I guess I was not aware that the color was optional for the <w:u> element.
I agree with your second suggestion - drop the requirement for a backgroundcolor and use NSAttributedString.Key. underlineColor for user-specified colors. We should test if the fallback to foregroundColor is required in DocX or if Word does this automatically.

@andalman
Copy link
Contributor Author

andalman commented Jan 26, 2023 via email

@shinjukunian
Copy link
Owner

Fixed in #37 . Thank you for addressing this!

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

No branches or pull requests

2 participants