Skip to content

Commit 087fa7e

Browse files
committed
Fixed run border for hyperlinks
1 parent 8c856ee commit 087fa7e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pydocx/export/border_and_shading.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,10 @@ def get_borders_property(self, only_between=False):
275275

276276
def export_close_paragraph_border(self):
277277
if self.current_border_item.get('Paragraph'):
278-
yield HtmlTag('div', closed=True)
278+
yield HtmlTag(self.TAGS['Paragraph'], closed=True)
279279
self.current_border_item['Paragraph'] = None
280+
281+
def export_close_run_border(self):
282+
if self.current_border_item.get('Run'):
283+
yield HtmlTag(self.TAGS['Run'], closed=True)
284+
self.current_border_item['Run'] = None

pydocx/export/html.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ def export_hyperlink(self, hyperlink):
518518
# the export underline function. There's got to be a better way.
519519
old = self.export_run_property_underline
520520
self.export_run_property_underline = lambda run, results: results
521+
522+
# Before starting new hyperlink we need to make sure that if there is any run
523+
# with border opened before, we need to close it here.
524+
for result in self.border_and_shading_builder.export_close_run_border():
525+
yield result
526+
521527
for result in results:
522528
yield result
523529
self.export_run_property_underline = old

0 commit comments

Comments
 (0)