Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions html4docx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'em': 'italic',
'i': 'italic',
'u': 'underline',
'ins': 'underline', # HTML5 insertion element - underline like <u>
's': 'strike',
'sup': 'superscript',
'sub': 'subscript',
Expand Down
13 changes: 13 additions & 0 deletions html4docx/h4d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,19 @@ def handle_data(self, data):
font_name = constants.FONT_NAMES[tag]
self.run.font.name = font_name

# Handle <mark> tag with yellow background highlight
if tag == 'mark':
shd = OxmlElement('w:shd')
shd.set(qn('w:val'), 'clear')
shd.set(qn('w:color'), 'auto')
shd.set(qn('w:fill'), 'FFFF00') # Yellow - default <mark> color
r_pr = self.run._element.get_or_add_rPr()
# Remove existing shading if present
existing_shd = r_pr.find(qn('w:shd'))
if existing_shd is not None:
r_pr.remove(existing_shd)
r_pr.append(shd)

if 'style' in attrs and (tag in ['div', 'li', 'pre']):
style = utils.parse_dict_string(attrs['style'])
self.add_styles_to_run(style)
Expand Down