Skip to content

Commit 4119c74

Browse files
authored
Merge pull request #5 from nf-osi/copilot/fix-ideas-table-formatting
Fix markdown table formatting broken by HTML comments
2 parents ca3f648 + cb2ef6b commit 4119c74

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

.github/scripts/update_readme.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,26 @@ def update_readme():
7979
table_content = content[start_idx:end_idx].strip()
8080

8181
# Parse existing rows and check if this issue is already in the table
82+
# Keep track of table header and separator separately
83+
table_lines = table_content.split('\n') if table_content else []
84+
table_header = []
8285
existing_rows = []
83-
if table_content:
84-
for line in table_content.split('\n'):
85-
line = line.strip()
86-
# Skip empty lines, separator rows (containing only |, -, and spaces)
87-
if line and line.startswith('|') and not re.match(r'^[\|\-\s]+$', line):
88-
existing_rows.append(line)
86+
87+
for line in table_lines:
88+
line_stripped = line.strip()
89+
if not line_stripped:
90+
continue
91+
# Detect header and separator rows
92+
if re.match(r'^[\|\-\s]+$', line_stripped):
93+
table_header.append(line_stripped) # This is the separator row
94+
elif line_stripped.startswith('|'):
95+
# First non-separator row is likely the header if we don't have it yet
96+
if not table_header:
97+
table_header.append(line_stripped) # This is the header row
98+
elif len(table_header) == 1:
99+
table_header.append(line_stripped) # This is the separator after header
100+
else:
101+
existing_rows.append(line_stripped) # This is a data row
89102

90103
# Check if this issue already exists in the table
91104
issue_pattern = f"/issues/{issue_number}"
@@ -104,8 +117,17 @@ def update_readme():
104117
# Add the new row
105118
existing_rows.append(new_row)
106119

107-
# Rebuild the table content
108-
new_table_content = '\n' + '\n'.join(existing_rows) + '\n'
120+
# Rebuild the table content with header, separator, and data rows
121+
if not table_header:
122+
# If no header found, create default table structure
123+
table_header = [
124+
'| Title | Description |',
125+
'|-------|-------------|'
126+
]
127+
128+
new_table_lines = table_header + existing_rows
129+
130+
new_table_content = '\n' + '\n'.join(new_table_lines) + '\n'
109131

110132
# Update the README content
111133
new_content = (

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ tracking space for virtual hackathon ideas
33

44
## Ideas
55

6+
<!-- IDEAS_TABLE_START -->
67
| Title | Description |
78
|-------|-------------|
8-
<!-- IDEAS_TABLE_START -->
99
| [idea: fancy landing page for rddc](https://github.com/nf-osi/2025-sage-hack-ideas/issues/3) | We could spend some time building a snazzy-looking landing page for the rare disease data commons... |
1010
<!-- IDEAS_TABLE_END -->

0 commit comments

Comments
 (0)