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.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”ConversionOptions | PreparedOptions = {}
Returns
Section titled “Returns”Example
Section titled “Example”import { convertDetailed } from "@humanities/greek-conversion";
const result = convertDetailed("ἐν ἀρχῇ", "greek", "transliteration", { preset: "sbl-general",});result.output; // → en archēresult.lossy; // → trueresult.losses.map((loss) => loss.diacritic);// → ["smooth","smooth","circumflex","iota-subscript"]Throws
Section titled “Throws”If input is not a string.
Throws
Section titled “Throws”If a format is unknown; an OptionError (a
RangeError) if a preset, an option key, or an option value is.