Better diff!

This commit is contained in:
jaseg 2021-09-29 13:51:22 +02:00
parent c6fc46736d
commit a16f032fa7

View file

@ -23,8 +23,8 @@ def generate_git_tex_diff(texfile, bibliography, revision):
bib_proc = subprocess.run(['git', 'diff', f'-U{bib_lines+1}', '--word-diff', '--color=always', revision, bibliography],
check=True, capture_output=True)
ADDITION_RE_R = '\033\\[32m\\{\\+([^\033]*?)([^\\\\]%.*?)?\\+\\}\033\\[m'
DELETION_RE_R = '\033\\[31m\\[-([^\033]*?)([^\\\\]%.*?)?\\-]\033\\[m'
ADDITION_RE_R = '\033\\[32m\\{\\+([^\033]*?)\\+\\}\033\\[m'
DELETION_RE_R = '\033\\[31m\\[-([^\033]*?)\\-]\033\\[m'
addition_re = re.compile(ADDITION_RE_R)
deletion_re = re.compile(DELETION_RE_R)
combined_re = re.compile(f'{DELETION_RE_R}{ADDITION_RE_R}')
@ -68,7 +68,11 @@ def generate_git_tex_diff(texfile, bibliography, revision):
def suppress_small_changes(match):
nonlocal debug
old, _1, new, _2 = match.groups()
old, new = match.groups()
old, _, _rest = old.partition('%')
new, _, _rest = new.partition('%')
if debug:
print(f'old={repr(old)}, new={repr(new)}', file=sys.stderr)
@ -102,6 +106,7 @@ def generate_git_tex_diff(texfile, bibliography, revision):
def suppress_small_changes(match, action):
change = match.group(1)
change, _, _rest = change.partition('%')
if len(change) < 12 or change.count(' ') < 3 or '}' in change or '{' in change:
if action == 'addition':