Skip to content
greek conversion

Converter

Defined in: src/converter.ts:333 (opens in a new tab)

An immutable conversion engine with isolated character extensions. Create one with createConverter(): the class is exported as a type only.

Aliases resolve to built-in letters and therefore receive the complete contextual behavior of those letters. New characters are deliberately opaque: only direct format mapping and semantic case are guaranteed.

convert(input, from, to, options?): string

Defined in: src/converter.ts:436 (opens in a new tab)

Converts text using this converter’s immutable character registry. The options add to the converter’s preset. Prepared options are taken when they were prepared with that preset, or with any when the converter binds none: they are then checked and resolved once.

string

Format

Format

ConversionOptions | PreparedOptions = {}

string

For another preset named in the options, or for options prepared with another preset, or without one when the converter binds one.

When the converter rejects characters outside its scope.


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

Defined in: src/converter.ts:490 (opens in a new tab)

Converts text and reports both information loss and repertoire scope. It takes options as Converter.convert does.

string

Format

Format

ConversionOptions | PreparedOptions = {}

ConverterConversionResult

For another preset named in the options, or for options prepared with another preset, or without one when the converter binds one.

When the converter rejects characters outside its scope.


convertGreekPassages(input, to, options?): string

Defined in: src/converter.ts:631 (opens in a new tab)

Converts the Greek passages of a text, and copies the rest as it is: convertGreekPassages with this converter’s characters and scope. The converter’s own Greek spellings, those of its aliases and the Greek forms of its characters, belong to the passages, whatever characters they are made of. It takes options as Converter.convert does.

string

Format

The format of the passages in the output.

ConversionOptions | PreparedOptions = {}

string

import { createConverter } from "@humanities/greek-conversion";
const converter = createConverter({
characters: [{
id: "san",
forms: {
greek: { lowercase: "ϻ", uppercase: "Ϻ" },
"beta-code": { lowercase: "#9", uppercase: "*#9" },
transliteration: { lowercase: "š", uppercase: "Š" },
},
override: true,
}],
});
converter.convertGreekPassages("the letter ϻ;", "transliteration");
// → the letter š;

For options, or prepared options, of another preset; a CharacterScopeError when the converter rejects a character.


convertGreekPassagesDetailed(input, to, options?): ConverterConversionResult

Defined in: src/converter.ts:670 (opens in a new tab)

Converter.convertGreekPassages, with the losses, the spans, and the diagnostics of Converter.convertDetailed: the text copied keeps what it has, and its spans in the output are those in the input, moved.

string

Format

The format of the passages in the output.

ConversionOptions | PreparedOptions = {}

ConverterConversionResult

For options, or prepared options, of another preset; a CharacterScopeError when the converter rejects a character.


reencode(input, format, options?): string

Defined in: src/converter.ts:472 (opens in a new tab)

Parses and writes text again in the same format, with this converter’s characters and scope: reencode for a converter. It is convert(input, format, format, options).

string

Format

ConversionOptions | PreparedOptions = {}

string

import { createConverter } from "@humanities/greek-conversion";
const converter = createConverter({
aliases: [{
letter: "theta",
format: "transliteration",
spellings: ["þ"],
}],
});
converter.reencode("þeós", "transliteration");
// → theós

For another preset named in the options, or for options prepared with another preset, or without one when the converter binds one.

When the converter rejects characters outside its scope.