EU Parliament Monitor — API Documentation - v0.9.25
    Preparing search index...
    • 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).

      Parameters

      • lang: LanguageCode

        Language code (drives Latin/CJK/RTL classification)

      • value: string

        Already-clamped meta-description

      • OptionalmaxLength: number

        Optional grapheme budget the result must fit in

      Returns string

      Description with trailing ellipsis stripped and a real terminator guaranteed