mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-11 01:14:45 +02:00
nws: truncate NWSheadline at word boundary, no ellipsis
Cut at last space before 80 UTF-8 bytes instead of hard-slicing at 77 chars with trailing dots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a4ecd05c60
commit
ddf24e10a9
1 changed files with 3 additions and 2 deletions
|
|
@ -319,8 +319,9 @@ def _render(*, event_type, area_desc, geocoder_city, county, state,
|
||||||
nws_hl = (params.get("NWSheadline") or [""])[0].strip()
|
nws_hl = (params.get("NWSheadline") or [""])[0].strip()
|
||||||
if nws_hl:
|
if nws_hl:
|
||||||
nws_hl = nws_hl.title()
|
nws_hl = nws_hl.title()
|
||||||
if len(nws_hl) > 80:
|
if len(nws_hl.encode("utf-8")) > 80:
|
||||||
nws_hl = nws_hl[:77] + "..."
|
while len(nws_hl.encode("utf-8")) > 80:
|
||||||
|
nws_hl = nws_hl.rsplit(" ", 1)[0]
|
||||||
line2 = nws_hl
|
line2 = nws_hl
|
||||||
else:
|
else:
|
||||||
area_first = (area_desc or "").split(";")[0].strip()
|
area_first = (area_desc or "").split(";")[0].strip()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue