Fixed small changes diff
This commit is contained in:
parent
a16f032fa7
commit
9c10f393bc
1 changed files with 13 additions and 8 deletions
|
|
@ -76,24 +76,28 @@ def generate_git_tex_diff(texfile, bibliography, revision):
|
|||
if debug:
|
||||
print(f'old={repr(old)}, new={repr(new)}', file=sys.stderr)
|
||||
|
||||
if len(old) < 12 and len(new) < 12:
|
||||
return new
|
||||
#if len(old) < 5 and len(new) < 5:
|
||||
# return new
|
||||
|
||||
if old.count(' ') < 3 and new.count(' ') < 3:
|
||||
return new
|
||||
#if old.count(' ') < 2 and new.count(' ') < 2:
|
||||
# return new
|
||||
|
||||
if '}' in old or '{' in old or '{' in new or '}' in new:
|
||||
if old.count('{') != old.count('}') or new.count('{') != new.count('}'):
|
||||
return new
|
||||
|
||||
new_chars = list(new)
|
||||
hits = 0
|
||||
for char in old:
|
||||
if char not in string.ascii_letters:
|
||||
continue
|
||||
|
||||
if char not in new_chars:
|
||||
return r' \color{diffred}' + old + r' \color{diffgreen}' + new + ' \color{black}'
|
||||
hits += 1
|
||||
if hits >= 3:
|
||||
return r' \color{diffred}' + old + r' \color{diffgreen}' + new + ' \color{black}'
|
||||
|
||||
new_chars.remove(char)
|
||||
else:
|
||||
new_chars.remove(char)
|
||||
|
||||
if any(char in string.ascii_letters for char in new_chars):
|
||||
return r' \color{diffred}' + old + r' \color{diffgreen}' + new + ' \color{black}'
|
||||
|
|
@ -108,7 +112,8 @@ def generate_git_tex_diff(texfile, bibliography, revision):
|
|||
change = match.group(1)
|
||||
change, _, _rest = change.partition('%')
|
||||
|
||||
if len(change) < 12 or change.count(' ') < 3 or '}' in change or '{' in change:
|
||||
#if len(change) <= 3 or change.count(' ') < 2 or change.count('{') != change.count('}'):
|
||||
if change.count('{') != change.count('}'):
|
||||
if action == 'addition':
|
||||
return change
|
||||
else: # deletion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue