Public finalizer for SEO meta-descriptions: strips trailing ellipses
emitted by clampForBudget's hard-cut path, then guarantees the
snippet closes with a script-appropriate sentence terminator (. for
Latin/RTL, 。 for CJK). Wraps the module-private ensureTerminator
with language-to-script classification so callers in article-metadata.ts
don't need to know about the per-script terminator tables.
When maxLength is supplied, the finalizer reserves space for the
terminator before stapling it — never returning a string longer than
the caller's budget. Without this, clampForBudget(_, lang, 'metaDescription') returns a string at exactly the budget, the
stapled terminator pushes it 1 grapheme over, and the second clamp in
the HTML shell drops the terminator and cuts mid-word (live
regression in news/2026-05-26-breaking-fr.html).
Public finalizer for SEO meta-descriptions: strips trailing ellipses emitted by clampForBudget's hard-cut path, then guarantees the snippet closes with a script-appropriate sentence terminator (
.for Latin/RTL,。for CJK). Wraps the module-private ensureTerminator with language-to-script classification so callers inarticle-metadata.tsdon't need to know about the per-script terminator tables.When
maxLengthis supplied, the finalizer reserves space for the terminator before stapling it — never returning a string longer than the caller's budget. Without this,clampForBudget(_, lang, 'metaDescription')returns a string at exactly the budget, the stapled terminator pushes it 1 grapheme over, and the second clamp in the HTML shell drops the terminator and cuts mid-word (live regression innews/2026-05-26-breaking-fr.html).