diff options
-rw-r--r-- | paper/diffinator.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/paper/diffinator.py b/paper/diffinator.py index 70907d5..53f9439 100644 --- a/paper/diffinator.py +++ b/paper/diffinator.py @@ -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': |