Gå til hovedinnhold

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.

IDhtml
SourceBuilt-in
Extensions.html, .htm, .xhtml
MIME Typestext/html, application/xhtml+xml
CapabilitiesRead + Write

How kapi reads it

Parameters

ParameterTypeDefaultDescription
attributesobjectGlobale regler for attributtuttrekk -- tilordner attributtnavn til regelkonfigurasjon (ruleTypes, allElementsExcept, onlyTheseElements, conditions)
codeFinderRulesarrayRegex-mønstre som matcher innebygde koder i oversettbar tekst
elementsobjectRegler for elementutvinning -- tilordner elementnavn til regelkonfigurasjon (ruleTypes, conditions, idAttributes, translatableAttributes)
extractNonTranslatableContentbooleantrueHvis 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.
parserobjectInnstillinger som styrer hvordan HTML-parseren leser inndata
useCodeFinderbooleanfalseAktiver regex-basert deteksjon av innebygde koder (plassholdere, variabler, tagger) i oversettbar tekst

Configure it live

Configuration
Loading form…

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 alt and title) are extracted as their own units.

Limitations

  • The reader applies built-in element/attribute defaults; the elements and attributes maps adjust them rather than replacing the entire rule set.

← Back to the Format Reference