Skip to content

Commit c2894e5

Browse files
triw0lfclaude
andcommitted
fix: handle escaped pipes in leaderboard table parsing
The split('|') approach broke when hunt Notes fields contained literal pipe characters (e.g., H132's "curl \| osascript"), causing phantom contributors. Now uses a character-by-character parser that respects \|. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f60334f commit c2894e5

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎Keepers/Contributors.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Everyone listed below has submitted ideas that have been added to HEARTH. This l
66

77
| Rank | Contributor | Hunts Submitted |
88
|------|-------------|-----------------|
9-
| 1 | Jinx (THOR Collective) | 39 |
10-
| 2 | Sydney Marrone | 29 |
11-
| 3 | Lauren Proehl | 21 |
9+
| 1 | Lauren Proehl | 41 |
10+
| 2 | Jinx (THOR Collective) | 39 |
11+
| 3 | Sydney Marrone | 29 |
1212
| 4 | John Grageda | 6 |
1313
| 5 | Jamie Williams | 3 |
1414
| 6 | Azrara | 3 |

‎scripts/generate_leaderboard.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ def find_hunt_files():
1919
return files
2020

2121

22+
def split_table_row(row):
23+
"""Split a markdown table row on unescaped pipes, ignoring \\| inside cells."""
24+
cells = []
25+
current = []
26+
i = 0
27+
while i < len(row):
28+
if row[i] == '\\' and i + 1 < len(row) and row[i + 1] == '|':
29+
current.append('|')
30+
i += 2
31+
elif row[i] == '|':
32+
cells.append(''.join(current).strip())
33+
current = []
34+
i += 1
35+
else:
36+
current.append(row[i])
37+
i += 1
38+
cells.append(''.join(current).strip())
39+
return [c for c in cells if c]
40+
41+
2242
def extract_submitter(cell):
2343
"""Extract contributor name from a markdown link or plain text."""
2444
# [Name](url) pattern
@@ -44,7 +64,7 @@ def generate_leaderboard():
4464

4565
for i, line in enumerate(lines):
4666
if '|' in line and 'Submitter' in line:
47-
columns = [c.strip() for c in line.split('|') if c.strip()]
67+
columns = split_table_row(line)
4868
for ci, col in enumerate(columns):
4969
clean_col = re.sub(r'\*\*|\*', '', col).strip()
5070
if "Submitter" in clean_col:
@@ -66,7 +86,7 @@ def generate_leaderboard():
6686
if not data_row.strip() or '|' not in data_row:
6787
continue
6888

69-
data_cells = [c.strip() for c in data_row.split('|') if c.strip()]
89+
data_cells = split_table_row(data_row)
7090
if submitter_index >= len(data_cells):
7191
continue
7292

0 commit comments

Comments
 (0)