summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/changes/pyMergeChanges.py
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/changes/pyMergeChanges.py')
-rw-r--r--macros/latex/contrib/changes/pyMergeChanges.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/macros/latex/contrib/changes/pyMergeChanges.py b/macros/latex/contrib/changes/pyMergeChanges.py
index 37209bdc64..39c8b22007 100644
--- a/macros/latex/contrib/changes/pyMergeChanges.py
+++ b/macros/latex/contrib/changes/pyMergeChanges.py
@@ -30,6 +30,7 @@ Options:
If no option is given, runs interactively.
Created on Wed Dec 5 20:28:40 2018
+Revised on Tue Aug 27 17:51:58 2019
"""
@@ -131,11 +132,11 @@ if INPUTFILE == OUTPUTFILE:
print('Input File and Output File must be different.')
sys.exit(1)
-RE_ADDED = re.compile(r'\\added(\[[^\]]*\]){0,1}\{([^\}]*)\}')
-RE_DELETED = re.compile(r'\\deleted(\[[^\]]*\]){0,1}\{([^\}]*)\}')
-RE_REPLACED = re.compile(r'\\replaced(\[[^\]]*\]){0,1}\{([^\}]*)\}\{([^\}]*)\}')
-RE_HIGHLIGHT = re.compile(r'\\highlight(\[[^\]]*\]){0,1}\{([^\}]*)\}')
-RE_COMMENT = re.compile(r'\\comment(\[[^\]]*\]){0,1}\{([^\}]*)\}')
+RE_ADDED = re.compile(r'(\\added)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}')
+RE_DELETED = re.compile(r'(\\deleted)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}')
+RE_REPLACED = re.compile(r'(\\replaced)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}\{(([^\}]?(\{[^\}]*\})?)*)\}')
+RE_HIGHLIGHT = re.compile(r'(\\highlight)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}')
+RE_COMMENT = re.compile(r'(\\comment)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}')
codecs.open(OUTPUTFILE, mode='w', encoding='utf8').close()
with codecs.open(INPUTFILE, mode='r', encoding='utf8') as fin, \
@@ -164,9 +165,9 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout:
answer = ask1()
if answer == 'a':
lineout = (lineout[:matchAdded.start(0)]
- + matchAdded.group(2) + lineout[matchAdded.end(0):])
+ + matchAdded.group(3) + lineout[matchAdded.end(0):])
lineout = trim_space(lineout, matchAdded.start(0)
- + len(matchAdded.group(2)))
+ + len(matchAdded.group(3)))
lineout = trim_space(lineout, matchAdded.start(0))
elif answer == 'r':
lineout = (lineout[:matchAdded.start(0)] + lineout[matchAdded.end(0):])
@@ -189,7 +190,7 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout:
lineout = (lineout[:matchDeleted.start(0)] + lineout[matchDeleted.end(0):])
lineout = trim_space(lineout, matchDeleted.start(0))
elif answer == 'r':
- lineout = (lineout[:matchDeleted.start(0)] + matchDeleted.group(2)
+ lineout = (lineout[:matchDeleted.start(0)] + matchDeleted.group(3)
+ lineout[matchDeleted.end(0):])
elif answer == 'k':
lineout = lineout
@@ -207,15 +208,15 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout:
answer = ask1()
if answer == 'a':
lineout = (lineout[:matchReplaced.start(0)]
- + matchReplaced.group(2) + lineout[matchReplaced.end(0):])
+ + matchReplaced.group(3) + lineout[matchReplaced.end(0):])
lineout = trim_space(lineout, matchReplaced.start(0)
- + len(matchReplaced.group(2)))
+ + len(matchReplaced.group(3)))
lineout = trim_space(lineout, matchReplaced.start(0))
elif answer == 'r':
lineout = (lineout[:matchReplaced.start(0)]
- + matchReplaced.group(3) + lineout[matchReplaced.end(0):])
+ + matchReplaced.group(6) + lineout[matchReplaced.end(0):])
lineout = trim_space(lineout, matchReplaced.start(0)
- + len(matchReplaced.group(3)))
+ + len(matchReplaced.group(6)))
lineout = trim_space(lineout, matchReplaced.start(0))
elif answer == 'k':
lineout = lineout
@@ -233,9 +234,9 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout:
answer = ask2()
if answer == 'r':
lineout = (lineout[:matchHighlight.start(0)]
- + matchHighlight.group(2) + lineout[matchHighlight.end(0):])
+ + matchHighlight.group(3) + lineout[matchHighlight.end(0):])
lineout = trim_space(lineout, matchHighlight.start(0)
- + len(matchHighlight.group(2)))
+ + len(matchHighlight.group(3)))
lineout = trim_space(lineout, matchHighlight.start(0))
elif answer == 'k':
lineout = lineout
@@ -252,10 +253,7 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout:
print('\n** comment commit ** \n' + matchComment.group())
answer = ask2()
if answer == 'r':
- lineout = (lineout[:matchComment.start(0)]
- + matchComment.group(2) + lineout[matchComment.end(0):])
- lineout = trim_space(lineout, matchComment.start(0)
- + len(matchComment.group(2)))
+ lineout = (lineout[:matchComment.start(0)] + lineout[matchComment.end(0):])
lineout = trim_space(lineout, matchComment.start(0))
elif answer == 'k':
lineout = lineout