diff options
author | jaseg <git@jaseg.de> | 2021-09-29 13:51:22 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-09-29 13:51:22 +0200 |
commit | a16f032fa7a42d5fa56f5ee71c15634f8b9e9949 (patch) | |
tree | 9b50ec5e2617d7d57bfafd722a7fa904ad90a40c | |
parent | c6fc46736d2e41466a52307ca748d7bed0597854 (diff) | |
download | ihsm-a16f032fa7a42d5fa56f5ee71c15634f8b9e9949.tar.gz ihsm-a16f032fa7a42d5fa56f5ee71c15634f8b9e9949.tar.bz2 ihsm-a16f032fa7a42d5fa56f5ee71c15634f8b9e9949.zip |
Better diff!
-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': |