Riksdagsmonitor Intelligence Platform โ€” API Documentation - v1.0.30
    Preparing search index...
    • Truncate a string to the longest sentence-terminated prefix whose length is โ‰ค hardMax, preferring a break โ‰ฅ softMin. Never cuts mid-word. Used for <meta description> so Google never renders a truncated last token with a trailing ellipsis.

      Supports sentence terminators across multiple scripts:

      • Latin: ., !, ?, โ€ฆ
      • CJK (Chinese/Japanese): ใ€‚
      • Devanagari (Hindi and related Indic scripts): เฅค

      Implements seo-metadata-contract.md ยง3.1 + ยง4: every language ships within its own SERP-width window via descriptionWindowForLanguage.

      If the input contains no usable sentence boundary and no word boundary within the window (e.g. a single run of non-space chars), the result is guaranteed to be non-empty: it is at least hardMax chars plus a trailing โ€ฆ, so the caller never receives a bare โ€ฆ.

      Parameters

      • text: string

        Input prose (markdown emphasis already stripped).

      • softMin: number = 140

        Soft minimum โ€” prefer truncating at or after this length (default 140).

      • hardMax: number = 200

        Hard maximum โ€” never return more than this many chars (default 200).

      Returns string