Riksdagsmonitor Intelligence Platform - v0.7.20
    Preparing search index...
    • Inject quality metadata into article HTML as a <meta> tag and, optionally, an inline JSON-LD block.

      CSP note: An inline <script type="application/ld+json"> element is still an inline script from the browser's perspective. If the page's Content-Security-Policy sets script-src without 'unsafe-inline', the JSON-LD block will be blocked by the browser. To keep things safe:

      • The <meta name="quality-score"> tag is injected when a </head> insertion point is found (CSP-safe).
      • The JSON-LD <script> block is only injected when injectJsonLd is true (default: false). Callers that know their CSP allows inline scripts can opt in.
      • If the HTML contains no </head> tag the function returns the original HTML unchanged (no injection possible without a <head> section).

      Parameters

      • html: string

        Original article HTML

      • assessment: MultiDimensionalQualityAssessment

        Quality assessment result

      • injectJsonLd: boolean = false

        If true, also add the JSON-LD script block (requires CSP to permit inline scripts). Default: false.

      Returns string

      Modified HTML with quality metadata injected, or the original HTML if no </head> tag is present.