Skip to content
greek conversion

convertDetailed

convertDetailed(input, from, to, options?): ConversionResult

Defined in: src/mod.ts:253 (opens in a new tab)

Converts text and reports information that the target representation cannot retain, and where each source token was read and written.

Unicode composition and tonos/oxia are representational differences and are not reported as loss. A letter form of the source (glyphVariant) is reported when the target cannot keep it and the options do not write it again; a form the options fold is not. The conversion itself is executed once; only the rendered target is parsed again for comparison.

Positions (ConversionResult.spans, ConversionLoss.offset) are offsets in UTF-16 code units in the input as supplied and in the output as returned: the readers and writers normalize the text, but the positions are mapped back to the caller’s strings.

string

Format

Format

ConversionOptions | PreparedOptions = {}

ConversionResult

import { convertDetailed } from "@humanities/greek-conversion";
const result = convertDetailed("ἐν ἀρχῇ", "greek", "transliteration", {
preset: "sbl-general",
});
result.output; // → en archē
result.lossy; // → true
result.losses.map((loss) => loss.diacritic);
// → ["smooth","smooth","circumflex","iota-subscript"]

If input is not a string.

If a format is unknown; an OptionError (a RangeError) if a preset, an option key, or an option value is.