Skip to content

Commit cb8a959

Browse files
committed
. t New - test_add_coauthor_heading_before_co_authored_by_list(self):
1 parent 25d1171 commit cb8a959

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/session_notes_cleanup/session_notes_cleaner.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,19 @@ def remove_coauthor_headings(self, text):
3030
# Assumes Markdown formatting where 1st level is '# ' and 2nd level is '## '
3131
standard_text = self.standardize_coauthor_heading(text)
3232
pattern = r'^#{1,2}\s*Co-Authors.*$\n?'
33-
cleaned_text = re.sub(pattern, '', standard_text, flags=re.MULTILINE)
33+
cleaned_text = re.sub(pattern, '', standard_text, flags=re.IGNORECASE | re.MULTILINE)
3434

3535
return cleaned_text
3636

37+
38+
def add_coauthor_heading_before_co_authored_by_list(self, text):
39+
search_pattern = r'^(Co-Authored-By.*)$'
40+
replace_pattern = r'## Co-Authors\n\1'
41+
cleaned_text = re.sub(search_pattern, replace_pattern, text,
42+
count=1,
43+
flags=re.IGNORECASE | re.MULTILINE)
44+
return cleaned_text
45+
3746
def applesauce(self, text):
3847
pattern = r'^#+\s*Co-Author$'
3948
re.sub(pattern, text,flags=re.IGNORECASE )
@@ -58,6 +67,8 @@ def cleanup_contents(self, text, session_date):
5867
if self.contains_active_coauthors(text) and self.contains_inactive_coauthors(text):
5968
text = self.delete_inactive_coauthors(text)
6069
text = self.standardize_coauthor_heading(text)
70+
text = self.remove_coauthor_headings(text)
71+
text = self.add_coauthor_heading_before_co_authored_by_list(text)
6172
return text
6273

6374
def cleanup_file(self, filename):

tests/test_session_notes_cleaner.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ def test_remove_coauthor_headings(self):
5151
acceptance_text = f'Before\n{text}====\nAfter\n{clean_text}====\n'
5252
verify(acceptance_text)
5353

54+
def test_add_coauthor_heading_before_co_authored_by_list(self):
55+
cleaner = SessionNotesCleaner()
56+
text = ""
57+
text += "## Facilitator\n"
58+
text += "Everyone\n"
59+
text += "\n"
60+
text += "Co-Authored-By: Manny\n"
61+
text += "Co-Authored-By: Moe\n"
62+
text += "Co-Authored-By: Jack\n"
63+
clean_text = cleaner.add_coauthor_heading_before_co_authored_by_list(text)
64+
acceptance_text = f'Before\n{text}====\nAfter\n{clean_text}====\n'
65+
verify(acceptance_text)
66+
5467
def test_cleanup_contents(self):
5568
cleaner = SessionNotesCleaner()
5669
text = self.sample_file_contents()

0 commit comments

Comments
 (0)