Skip to content

Commit 6112ef1

Browse files
author
Magnus C. Halle
committed
add - function to get ratio from HTMLDiffer object
1 parent 58681d3 commit 6112ef1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

htmldiffer/diff.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, html_a, html_b, encoding=None, autojunk=False):
2424
else:
2525
self.html_b = html_b
2626

27-
self.deleted_diff, self.inserted_diff, self.combined_diff = self.diff(autojunk=autojunk)
27+
self.deleted_diff, self.inserted_diff, self.combined_diff, self.s = self.diff(autojunk=autojunk)
2828

2929
def diff(self, autojunk=False):
3030
"""Takes in strings a and b and returns HTML diffs: deletes, inserts, and combined."""
@@ -70,8 +70,11 @@ def diff(self, autojunk=False):
7070
# using BeautifulSoup to fix any potentially broken tags
7171
# see https://github.com/anastasia/htmldiffer/issues/28
7272
combined_diff = str(BeautifulSoup(''.join(out[2]), 'html.parser'))
73-
74-
return deleted_diff, inserted_diff, combined_diff
73+
74+
return deleted_diff, inserted_diff, combined_diff, s
75+
76+
def ratio(self):
77+
return self.s.ratio()
7578

7679

7780
def add_diff_tag(diff_type, text):

0 commit comments

Comments
 (0)