Skip to content

Commit d7af87f

Browse files
jeremymanningclaude
andcommitted
fix current_position formatting for alumni with existing prefixes
Added format_position_display() to detect patterns like "now at", "now a", "then at", "then a" in the current_position field. When found, the prefix is preserved and only the rest is hyperlinked. This prevents duplicate prefixes like "now at now at X". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e6980ba commit d7af87f

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

people.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ <h3>Graduate Students</h3>
245245
Hanli Li (2016)</p>
246246

247247
<h3>Lab Managers</h3>
248-
<p><a href="http://paxtonfitzpatrick.github.io" target="_blank">Paxton Fitzpatrick</a> (2019-2021; now at <a href="https://context-lab.com" target="_blank">now a CDL grad student!</a>)<br>
249-
Emily Whitaker (2017-2018; now at <a href="https://www.wisc.edu/" target="_blank">now at U Wisconsin-Madison</a>)<br>
250-
<a href="http://kirstensgithub.github.io/" target="_blank">Kirsten Ziman</a> (2016-2017; now at <a href="https://context-lab.com" target="_blank">then a CDL grad student!</a>)</p>
248+
<p><a href="http://paxtonfitzpatrick.github.io" target="_blank">Paxton Fitzpatrick</a> (2019-2021; now a <a href="https://context-lab.com" target="_blank">CDL grad student!</a>)<br>
249+
Emily Whitaker (2017-2018; now at <a href="https://www.wisc.edu/" target="_blank">U Wisconsin-Madison</a>)<br>
250+
<a href="http://kirstensgithub.github.io/" target="_blank">Kirsten Ziman</a> (2016-2017; then a <a href="https://context-lab.com" target="_blank">CDL grad student!</a>)</p>
251251
</div>
252252
<div>
253253
<h3>Undergraduate Researchers</h3>

scripts/build_people.py

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,45 @@ def generate_members_content(members: List[Dict[str, Any]]) -> str:
275275
return "\n\n".join(grids)
276276

277277

278+
def format_position_display(current_position: str, current_position_url: str) -> str:
279+
"""Format the current position text with optional hyperlink.
280+
281+
Handles patterns like "now at X", "now a X", "then a X", "then at X".
282+
If the position already contains such a pattern, uses it as-is and
283+
hyperlinks just the relevant part. Otherwise prepends "now at".
284+
285+
Args:
286+
current_position: The position text (may include prefix like "now at")
287+
current_position_url: Optional URL to link
288+
289+
Returns:
290+
Formatted position display string
291+
"""
292+
if not current_position:
293+
return ""
294+
295+
# Patterns that indicate the text already has a prefix
296+
# Match: "now at ", "now a ", "then at ", "then a "
297+
prefix_pattern = re.match(r'^(now at |now a |then at |then a )', current_position, re.IGNORECASE)
298+
299+
if prefix_pattern:
300+
# Text already has a prefix - extract prefix and the rest
301+
prefix = prefix_pattern.group(1)
302+
rest = current_position[len(prefix):]
303+
304+
if current_position_url:
305+
# Hyperlink just the part after the prefix
306+
return f'{prefix}<a href="{current_position_url}" target="_blank">{rest}</a>'
307+
else:
308+
return current_position
309+
else:
310+
# No prefix - add "now at"
311+
if current_position_url:
312+
return f'now at <a href="{current_position_url}" target="_blank">{current_position}</a>'
313+
else:
314+
return f"now at {current_position}"
315+
316+
278317
def generate_alumni_entry(alum: Dict[str, Any]) -> str:
279318
"""Generate HTML for a single alumni entry.
280319
@@ -297,12 +336,7 @@ def generate_alumni_entry(alum: Dict[str, Any]) -> str:
297336
name_display = name
298337

299338
# Build position display with optional link
300-
if current_position and current_position_url:
301-
position_display = f'now at <a href="{current_position_url}" target="_blank">{current_position}</a>'
302-
elif current_position:
303-
position_display = f"now at {current_position}"
304-
else:
305-
position_display = ""
339+
position_display = format_position_display(current_position, current_position_url)
306340

307341
# Build parenthetical info
308342
paren_parts = []

0 commit comments

Comments
 (0)