@@ -9,22 +9,20 @@ def __init__(self):
9
9
pass
10
10
11
11
def contains_inactive_coauthors (self , text ):
12
- return bool (re .search (r'^#+\s*Inactive Co-Authors' , text , re .IGNORECASE | re .MULTILINE ))
12
+ return bool (re .search (r'^#+\s*Inactive( Co-Authors)? ' , text , re .IGNORECASE | re .MULTILINE ))
13
13
14
14
def delete_inactive_coauthors (self , text ):
15
- return re .sub (r'^#+\s*Inactive Co-Authors.*?(?=^#|\Z)' , '' , text ,
15
+ return re .sub (r'^#+\s*Inactive( Co-Authors)? .*?(?=^#|\Z)' , '' , text ,
16
16
flags = re .IGNORECASE | re .MULTILINE | re .DOTALL )
17
17
18
18
def contains_active_coauthors (self , text ):
19
- return bool (re .search (r'^#+\s*Active Co-Authors' , text , re .IGNORECASE | re .MULTILINE ))
19
+ return bool (re .search (r'^#+\s*( Active )? Co-Authors' , text , re .IGNORECASE | re .MULTILINE ))
20
20
21
21
def standardize_coauthor_heading (self , text ):
22
- return re .sub (r'^#+\s*.*Co-?Author.*' , '## Co -Authors' ,
22
+ return re .sub (r'^#+\s*.*?((?:Inactive\s+)?)\s* Co-?Author.*' , r '## \1Co -Authors' ,
23
23
text ,
24
24
flags = re .IGNORECASE | re .MULTILINE )
25
25
26
- import re
27
-
28
26
def remove_coauthor_headings (self , text ):
29
27
# Regular expression to match 1st and 2nd level headings with "Co-Authors"
30
28
# Assumes Markdown formatting where 1st level is '# ' and 2nd level is '## '
@@ -34,7 +32,6 @@ def remove_coauthor_headings(self, text):
34
32
35
33
return cleaned_text
36
34
37
-
38
35
def add_coauthor_heading_before_co_authored_by_list (self , text ):
39
36
search_pattern = r'^(Co-Authored-By.*)$'
40
37
replace_pattern = r'## Co-Authors\n\1'
@@ -43,10 +40,6 @@ def add_coauthor_heading_before_co_authored_by_list(self, text):
43
40
flags = re .IGNORECASE | re .MULTILINE )
44
41
return cleaned_text
45
42
46
- def applesauce (self , text ):
47
- pattern = r'^#+\s*Co-Author$'
48
- re .sub (pattern , text ,flags = re .IGNORECASE )
49
-
50
43
def get_date_from_filename (self , filename ):
51
44
match = re .search (r'(\d{4}-\d{2}-\d{2})' , filename , re .IGNORECASE )
52
45
return match .group (1 ) if match else None
@@ -64,9 +57,9 @@ def contains_session_date(self, text):
64
57
def cleanup_contents (self , text , session_date ):
65
58
if not self .contains_session_date (text ):
66
59
text = f"# Session Date: { session_date } \n " + text
60
+ text = self .standardize_coauthor_heading (text )
67
61
if self .contains_active_coauthors (text ) and self .contains_inactive_coauthors (text ):
68
62
text = self .delete_inactive_coauthors (text )
69
- text = self .standardize_coauthor_heading (text )
70
63
text = self .remove_coauthor_headings (text )
71
64
text = self .add_coauthor_heading_before_co_authored_by_list (text )
72
65
return text
0 commit comments