diff --git a/generateChangemarks/changemarks.py b/generateChangemarks/changemarks.py index 7a3a82e16627321ece0f18f4689c1d1aba2408cd..497940bbd66396a1f12cf24417950ae3e00de7d2 100644 --- a/generateChangemarks/changemarks.py +++ b/generateChangemarks/changemarks.py @@ -458,7 +458,10 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st _taskID = progress.add_task('[blue]Find clauses with changes', start=False, total=0) - clauseregex = re.compile('^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w*(\.\d+)*|~~#).*') + clauseregex = re.compile('^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w*(\.\d+)*).*') + removedclauseregex = re.compile('^\~\~#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*') + addedclauseregex = re.compile('^\<span\sclass\=\"underline\"\>#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*') + clauses: list[Clause] = [] changed_clauses: list[Clause] = [] changeInClause = False @@ -473,24 +476,37 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st # break # index = index + 1 + def checkClause(_matches): + nonlocal clause + nonlocal changeInClause + + if index - 2 == clause.from_id: # It is a subclause + clause.from_id = index + clause.raw = line + clause.clause_nr = _matches[0][0] + else: # It is the end of the clause + clause.to_id = index - 1 + clauses.append(clause) + if changeInClause: + changed_clauses.append(clause) + clause = Clause(line, index, index, _matches[0][0]) + changeInClause = False + index = 1 for line, change in mdLines_changes: if change: changeInClause = True - if line.startswith('#'): + if line.startswith('#') or line.startswith("~~#") or line.startswith("<span class=\"underline\">#"): matches = re.findall(clauseregex, line) # Match heading + removedmatches = re.findall(removedclauseregex, line) # Match removed heading + addedmatches = re.findall(addedclauseregex, line) # Match removed heading + if matches: # It may be the end of the clause or the start of a subclause - if index - 2 == clause.from_id: # It is a subclause - clause.from_id = index - clause.raw = line - clause.clause_nr = matches[0][0] - else: # It is the end of the clause - clause.to_id = index - 1 - clauses.append(clause) - if changeInClause: - changed_clauses.append(clause) - clause = Clause(line, index, index, matches[0][0]) - changeInClause = False + checkClause(matches) + elif removedmatches: + checkClause(removedmatches) + elif addedmatches: + checkClause(addedmatches) else: # it is last clause print("Unknown heading") diff --git a/generate_changemarks.sh b/generate_changemarks.sh index 55aa6937975dde971cb7531765bb705af6a33226..df51f20257c0d31e09e06893a89368c3e86e6823 100644 --- a/generate_changemarks.sh +++ b/generate_changemarks.sh @@ -1,6 +1,6 @@ #!/bin/bash -FORGELIB_DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.11.0 +FORGELIB_DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.13.0 GENERATE_CHANGEMARKS_DOCKER_IMAGE=generatechangemarks:master DOCKER_IMAGE=pandoc/core:3.1.1.0