[diffoscope] 01/01: Use <ins/> and <del/> in HTML output
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Dec 16 15:38:49 CET 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository diffoscope.
commit 72eab1b5d09845d07b20c439a47899280b7c22aa
Author: Mike Hommey <mh+diffoscope at glandium.org>
Date: Wed Dec 16 11:48:40 2015 +0000
Use <ins/> and <del/> in HTML output
This is semantically more correct and saves some bytes compared to the longer
'<span class="diffchanged2"></span>'.
---
diffoscope/presenters/html.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index d843f39..f425889 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -116,8 +116,9 @@ HEADER = """<!DOCTYPE html>
tr.diffchanged td {
background: #FFFFA0
}
- span.diffchanged2 {
- background: #E0C880
+ ins, del {
+ background: #E0C880;
+ text-decoration: none
}
span.diffponct {
color: #B08080
@@ -274,15 +275,15 @@ def linediff(s, t):
return ''.join(l1).replace(DIFFOFF + DIFFON, ''), ''.join(l2).replace(DIFFOFF + DIFFON, '')
-def convert(s, ponct=0):
+def convert(s, ponct=0, tag=''):
i = 0
t = StringIO()
for c in s:
# used by diffs
if c == DIFFON:
- t.write('<span class="diffchanged2">')
+ t.write('<%s>' % tag)
elif c == DIFFOFF:
- t.write('</span>')
+ t.write('</%s>' % tag)
# special highlighted chars
elif c == "\t" and ponct == 1:
@@ -348,7 +349,7 @@ def output_line(print_func, s1, s2):
if s1 is not None:
print_func(u'<td class="diffline">%d </td>' % line1)
print_func(u'<td class="diffpresent">')
- print_func(convert(s1, ponct=1))
+ print_func(convert(s1, ponct=1, tag='del'))
print_func(u'</td>')
else:
s1 = ""
@@ -357,7 +358,7 @@ def output_line(print_func, s1, s2):
if s2 is not None:
print_func(u'<td class="diffline">%d </td>' % line2)
print_func(u'<td class="diffpresent">')
- print_func(convert(s2, ponct=1))
+ print_func(convert(s2, ponct=1, tag='ins'))
print_func(u'</td>')
else:
s2 = ""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list