HTML format (.html, .htm, .xhtml)
The HTML format reads HTML documents, extracts element text and
attribute values, and writes the translations back while preserving the
surrounding markup. Inline elements (such as b, i, a) become inline
codes within a block, so formatting and links survive translation.
The reader ships with sensible defaults for which elements hold content,
which are inline, and which attributes (such as alt and title) are
extracted. The elements and attributes maps let you override or extend
those rules per element and per attribute, mirroring the okf_html bridge
configuration. Parser behaviour (whitespace handling) is grouped under
parser.
How kapi reads it
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
attributes | object | Globale regler for attributtuttrekk -- tilordner attributtnavn til regelkonfigurasjon (ruleTypes, allElementsExcept, onlyTheseElements, conditions) | |
codeFinderRules | array | Regex-mønstre som matcher innebygde koder i oversettbar tekst | |
elements | object | Regler for elementutvinning -- tilordner elementnavn til regelkonfigurasjon (ruleTypes, conditions, idAttributes, translatableAttributes) | |
extractNonTranslatableContent | boolean | true | Hvis true (standard), vil gjengivbart ikke-oversettbart kontekstuelt innhold — <noscript>-reserveundertreet og JSON-dataøyer (<script type="application/ld+json"|"application/json">) — vises som innholdsblokker (synlig for innhenting/LLM-konsumenter, hoppes over av maskinoversettelse) i stedet for å skjules i skjelett. Generiske kjørbare <script>- og <style>-elementer forblir alltid ugjennomsiktige. |
parser | object | Innstillinger som styrer hvordan HTML-parseren leser inndata | |
useCodeFinder | boolean | false | Aktiver regex-basert deteksjon av innebygde koder (plassholdere, variabler, tagger) i oversettbar tekst |
Configure it live
Examples
Preserve whitespace
Keep significant whitespace in text nodes instead of collapsing it.
parser:
preserveWhitespace: true
Make a custom element translatable
Extract the text of a custom <summary> element.
elements:
summary:
ruleTypes:
- TEXTUNIT
Processing notes
Inline elements become inline codes within blocks; block-level elements form the surrounding structure.
Translatable attributes (such as
altandtitle) are extracted as their own units.
Limitations
The reader applies built-in element/attribute defaults; the
elementsandattributesmaps adjust them rather than replacing the entire rule set.
← Back to the Format Reference