summaryrefslogtreecommitdiff
path: root/paper
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-09-27 18:50:33 +0200
committerjaseg <git@jaseg.de>2021-09-27 18:50:33 +0200
commitfffef5e79470759bf3c8f9d2d90dce32702da14e (patch)
treeae514a3480d114ced279f1effb3015bb9b053b9d /paper
parent2219846a12157d351d35965cd1ad2d1635e8762b (diff)
downloadihsm-fffef5e79470759bf3c8f9d2d90dce32702da14e.tar.gz
ihsm-fffef5e79470759bf3c8f9d2d90dce32702da14e.tar.bz2
ihsm-fffef5e79470759bf3c8f9d2d90dce32702da14e.zip
Diff export
Diffstat (limited to 'paper')
-rw-r--r--paper/Makefile2
-rw-r--r--paper/diffinator.py32
-rw-r--r--paper/ihsm_paper.tex1
3 files changed, 29 insertions, 6 deletions
diff --git a/paper/Makefile b/paper/Makefile
index e230536..271964f 100644
--- a/paper/Makefile
+++ b/paper/Makefile
@@ -8,7 +8,7 @@ SHELL := bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
-DIFF_VERSION ?= v2.0
+DIFF_VERSION ?= v3.0
main_tex ?= ihsm_paper
brief_tex ?= ihsm_tech_report
diff --git a/paper/diffinator.py b/paper/diffinator.py
index 5ba4fdc..be856e6 100644
--- a/paper/diffinator.py
+++ b/paper/diffinator.py
@@ -2,6 +2,7 @@
import re
import subprocess
+import string
import click
@@ -21,9 +22,11 @@ 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 = re.compile('\033\\[32m\\{\\+(.*?)([^\\\\]%.*?)?\\+\\}\033\\[m')
- deletion_re = re.compile('\033\\[31m\\[-(.*?)([^\\\\]%.*?)?\\-]\033\\[m')
+ ADDITION_RE_R = '\033\\[32m\\{\\+(.*?)([^\\\\]%.*?)?\\+\\}\033\\[m'
+ DELETION_RE_R = '\033\\[31m\\[-(.*?)([^\\\\]%.*?)?\\-]\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}')
csi_re = re.compile('\033\\[.*?m')
bibtex_entry_def_re = re.compile('@.*?{(.*?),')
@@ -57,6 +60,26 @@ def generate_git_tex_diff(texfile, bibliography, revision):
line = line.rstrip()
if document_started: # diff results in preamble
+
+ def suppress_small_changes(match):
+ old, _1, new, _2 = match.groups()
+
+ new_chars = list(new)
+ for char in old:
+ if char not in string.ascii_letters:
+ continue
+
+ if char not in new_chars:
+ return match.group(0) # return original text
+
+ new_chars.remove(char)
+
+ if any(char in string.ascii_letters for char in new_chars):
+ return match.group(0) # return original text
+
+ return new
+
+ line = combined_re.sub(suppress_small_changes, line)
line = addition_re.sub(r' \\color{diffgreen}\1 \\color{black}', line)
line = deletion_re.sub(r' \\color{diffred}\1 \\color{black}', line)
@@ -67,9 +90,8 @@ def generate_git_tex_diff(texfile, bibliography, revision):
print('\\definecolor{diffgreen}{HTML}{1e8449}')
print('\\definecolor{diffred}{HTML}{cb4335}')
-
line = addition_re.sub(r'\1', line)
- line = deletion_re.sub(r'\1', line)
+ line = deletion_re.sub(r'', line)
line = csi_re.sub('', line)
print(line)
diff --git a/paper/ihsm_paper.tex b/paper/ihsm_paper.tex
index d52543a..b9d73ec 100644
--- a/paper/ihsm_paper.tex
+++ b/paper/ihsm_paper.tex
@@ -31,6 +31,7 @@
\usepackage{subcaption}
\usepackage{array}
\usepackage{hyperref}
+\usepackage{xcolor}
\renewcommand{\floatpagefraction}{.8}
\newcommand{\degree}{\ensuremath{^\circ}}