nws: use raw NWSheadline with no casing manipulation

Remove all headline casing (title-case, sentence-case, TZ regex). Pass
the NWSheadline string through as-is from the CAP parameters, only
applying word-boundary truncation to 80 UTF-8 bytes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-08 07:18:40 +00:00
commit 9de514c4bd

View file

@ -314,13 +314,9 @@ def _render(*, event_type, area_desc, geocoder_city, county, state,
# Line 1: emoji + event type (no office)
line1 = f"{emoji} {prefix_seg}{event_type or 'Weather Alert'}"
# Line 2: NWSheadline (title-cased, 80 chars) or fallback
# Line 2: NWSheadline (raw, truncated to 80 bytes at word boundary) or fallback
nws_hl = (params.get("NWSheadline") or [""])[0].strip()
if nws_hl:
# Sentence-case: capitalize first char, lowercase rest, re-uppercase TZ abbrevs
nws_hl = nws_hl[0].upper() + nws_hl[1:].lower() if nws_hl else ""
nws_hl = re.sub(r'\b(mdt|mst|pdt|pst|cdt|cst|edt|est|utc)\b',
lambda m: m.group().upper(), nws_hl, flags=re.IGNORECASE)
if len(nws_hl.encode("utf-8")) > 80:
while len(nws_hl.encode("utf-8")) > 80:
nws_hl = nws_hl.rsplit(" ", 1)[0]