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

Underline not converting into docx #68

Open
jacovanderlaan opened this issue Apr 12, 2024 · 2 comments
Open

Underline not converting into docx #68

jacovanderlaan opened this issue Apr 12, 2024 · 2 comments

Comments

@jacovanderlaan
Copy link

Hi there,

The html2doc module works perfect for me, manu thanks for it.
There is just one issue I do not get to work and that is the conversion of italic.
Below is a HTML section with text-decoration:underline.
Any idee why this is not converting into a underline property in python-docx?

Thx!

jaco

BDV:

@cyy-2024
Copy link

Hello! Is your question regarding italics or underlining? I want to improve this functionality. If you're referring to underlining, based on my tests, it works as expected. I can provide you with a code example that might help! Let me know how I can assist further.
from docx import Document
from htmldocx import HtmlToDocx

document = Document()
html_parser = HtmlToDocx()

html_content = '''

<title>Underline Text Example</title>

This is a sample text with underlined words.

Here is another line with multiple underlined words in a sentence.

'''

html_parser.add_html_to_document(html_content, document)
document.save('output_with_underline.docx')
print("HTML to DOCX conversion complete!")

@cyy-2024
Copy link

you can try the code below!

from docx import Document
from htmldocx import HtmlToDocx

document = Document()
html_parser = HtmlToDocx()

html_content = '''

<title>Underline and Italic Text Example</title>

This is underlined and italic text.

Here is a combination of underlined and italic text.

'''

html_parser.add_html_to_document(html_content, document)
document.save('output_with_underline.docx')
print("HTML to DOCX conversion complete!")

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