Skip to content

Commit

Permalink
Mark unknown formatting tags with attribute instead of wrapping content
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Sep 18, 2018
1 parent 0088593 commit 41396b6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_data/complex-text-update.expected.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<body xmlns:diff="http://namespaces.shoobx.com/diff">
<div id="id">
<p><diff:insert>Let's see. </diff:insert>This is some simple text demonstrating the features of the <b diff:delete-formatting="">human text differ</b>. This <u diff:delete-formatting=""><em diff:delete-formatting=""><b diff:insert-formatting=""><i diff:insert-formatting="">feature</i></b></em></u> attempts to make changelog nice &amp; readable for humans.<br diff:insert=""/> The <i diff:insert-formatting="">human text differ</i> uses sentences as its first order matching. <diff:delete>Let's see.</diff:delete><invalid><diff:insert>It should handle unknown tags &amp; such just fine.</diff:insert></invalid></p>
<p><diff:insert>Let's see. </diff:insert>This is some simple text demonstrating the features of the <b diff:delete-formatting="">human text differ</b>. This <u diff:delete-formatting=""><em diff:delete-formatting=""><b diff:insert-formatting=""><i diff:insert-formatting="">feature</i></b></em></u> attempts to make changelog nice &amp; readable for humans.<br diff:insert=""/> The <i diff:insert-formatting="">human text differ</i> uses sentences as its first order matching. <diff:delete>Let's see.</diff:delete><invalid diff:insert="">It should handle unknown tags &amp; such just fine.</invalid></p>
</div>
</body>
8 changes: 1 addition & 7 deletions xmldiff/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,7 @@ def mark_diff(self, ph, action):
if self.is_formatting(elem):
# Formatting element, add a diff attribute
action += '-formatting'
elem.attrib['{%s}%s' % (DIFF_NS, action)] = ''
elif elem.text:
# Not formatting, but it has content, wrap content
elem.text = self.wrap_diff(elem.text, action)
else:
# No content, not formatting
elem.attrib['{%s}%s' % (DIFF_NS, action)] = ''
elem.attrib['{%s}%s' % (DIFF_NS, action)] = ''

# And make a new placeholder for this new entry:
return self.get_placeholder(elem, entry.ttype, entry.close_ph)
Expand Down

0 comments on commit 41396b6

Please sign in to comment.