Skip to content

Commit

Permalink
Merge pull request #9 from antoineboquet/dev
Browse files Browse the repository at this point in the history
v0.13
  • Loading branch information
antoineboquet committed Mar 10, 2024
2 parents 0b7ee7a + 9859273 commit cfba815
Show file tree
Hide file tree
Showing 21 changed files with 1,647 additions and 690 deletions.
7 changes: 7 additions & 0 deletions .terserrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mangle": {
"properties": {
"regex": "^CAPITAL|^SMALL|^PUNCT|^DIA"
}
}
}
64 changes: 46 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ fromType: KeyType,
settings: Preset | MixedPreset | IConversionOptions = {}
```

The **`fromType`** parameter can be set to `BETA_CODE | GREEK | TRANSLITERATION` (e.g. `KeyType.GREEK`).
**`fromType`** can be set to `BETA_CODE | TLG_BETA_CODE | GREEK | TRANSLITERATION` (e.g. `KeyType.GREEK`).

The **`settings`** parameter can be filled with:
**`settings`** can be filled with:
1. a `Preset`;
2. a user-defined `IConversionOptions` object;
3. a preset mixed with user-defined conversion options (`[Preset, IConversionOptions]`).
Expand All @@ -98,49 +98,64 @@ The available presets are:
| Preset | Description |
| ------ | ----------- |
| [**`MODERN_BC`**](https://github.com/antoineboquet/greek-conversion/wiki#Modern-beta-code) | `greek-conversion`'s own modernized style |
| [**`TLG`**](https://github.com/antoineboquet/greek-conversion/wiki#TLG) | Thesaurus Linguae Graecae |

2. **For transliteration:**

| Preset | Description |
| ------ | ----------- |
| [**`ALA_LC`**](https://github.com/antoineboquet/greek-conversion/wiki#ALA-LC) | American Library Association – Library of Congress |
| [**`BNF`**](https://github.com/antoineboquet/greek-conversion/wiki#BNF) | Bibliothèque nationale de France |
| [**`ISO`**](https://github.com/antoineboquet/greek-conversion/wiki#iso-843-1997) | ISO 843 (1997) — type 1 (transliteration) |
| [**`SBL`**](https://github.com/antoineboquet/greek-conversion/wiki#SBL) | Society of Biblical Literature |

### Conversion options

The **`IConversionOptions`** interface provides the following controls over the conversion process:

```ts
removeDiacritics?: boolean, // remove diacritics, except those that represent letters
removeDiacritics?: boolean, // remove diacritics, except those that represent letters

removeExtraWhitespace?: boolean, // remove potential extra whitespace

removeExtraWhitespace?: boolean, // remove potential extra whitespace
betaCodeStyle?: {
useTLGStyle?: boolean // use the Thesaurus Linguae Graecae style. e.g. 'Ἄϊδι' → '*)/AI+DI'
},

setGreekStyle?: {
disableBetaVariant?: boolean, // disable the typographic variant 'ϐ' [U+03D0]
useLunateSigma?: boolean // use the lunate sigma rather than the regular form
greekStyle?: {
disableBetaVariant?: boolean, // disable the typographic variant 'ϐ' [U+03D0]
useGreekQuestionMark?: boolean, // use greek question marks ';' [U+037E] rather than regular semicolons
useLunateSigma?: boolean // use lunate sigmas 'ϲ, Ϲ' rather than regular sigmas
},

setTransliterationStyle?: {
useCxOverMacron?: boolean, // use a circumflex rather than a macron for 'η', 'ω', etc
xi_ks?: boolean, // transliterate 'ξ' as 'ks' (defaults to: 'x')
rho_rh?: boolean, // transliterate 'ρ' as 'rh' even if it doesn't have a rough breathing
chi_kh?: boolean, // transliterate 'χ' as 'kh' (defaults to: 'ch')
upsilon_y?: boolean, // transliterate 'υ' as 'y' (defaults to: 'u')
lunatesigma_s?: boolean // transliterate 'ϲ' [U+03F2] as 's' (defaults to: 'c')
transliterationStyle?: {
setCoronisStyle?: Coronis, // set Coronis enum to PSILI | APOSTOPHE | NO (defaults to: PSILI)
useCxOverMacron?: boolean, // use a circumflex rather than a macron for 'η', 'ω', etc
beta_v?: boolean, // transliterate 'β' as 'v' (defaults to: 'b')
eta_i?: boolean, // transliterate 'η' as 'ī' (defaults to: 'ē')
xi_ks?: boolean, // transliterate 'ξ' as 'ks' (defaults to: 'x')
rho_rh?: boolean, // transliterate 'ρ' as 'rh' even if it doesn't have a rough breathing
phi_f?: boolean, // transliterate 'φ' as 'f' (defaults to: 'ph')
chi_kh?: boolean, // transliterate 'χ' as 'kh' (defaults to: 'ch')
upsilon_y?: boolean, // transliterate 'υ' as 'y' (defaults to: 'u')
lunatesigma_s?: boolean // transliterate 'ϲ' [U+03F2] as 's' (defaults to: 'c')
},

useAdditionalChars?: // extend the default mapping with additional chars
AdditionalChar[] | // (use AdditionalChar.ALL to enable the whole set)
additionalChars?: // extend the default mapping with additional chars
AdditionalChar[] | // (use AdditionalChar.ALL to enable the whole set)
AdditionalChar
```

A more detailed description of these conversion options is available on this [page](https://github.com/antoineboquet/greek-conversion/wiki#conversion-options).

### Examples

#### Basic examples

```ts
toBetaCode('ανθρωπος', KeyType.GREEK) // anqrwpos
toGreek('A)/i+da', KeyType.BETA_CODE) // Ἄϊδα
toGreek('*)/AI+DA', KeyType.TLG_BETA_CODE) // Ἄϊδα
toTransliteration('ἄϋλος', KeyType.GREEK, { removeDiacritics: true }) // aulos
```

Expand All @@ -164,7 +179,7 @@ toTransliteration('ἀΰπνους νύκτας ἴαυον', KeyType.GREEK, [

```ts
const style = {
setGreekStyle: {
greekStyle: {
useLunateSigma: true
}
}
Expand All @@ -177,7 +192,7 @@ toGreek('ICHTHUS ZŌNTŌN', KeyType.TRANSLITERATION, style) // ἸΧΘΥϹ ΖΩ

```ts
const style = {
setTransliterationStyle: {
transliterationStyle: {
useCxOverMacron: true,
chi_kh: true
}
Expand All @@ -187,6 +202,19 @@ toTransliteration('τέχνη', KeyType.GREEK) // téchnē
toTransliteration('τέχνη', KeyType.GREEK, style) // tékhnê
```

#### Self conversion (reflect settings)

```ts
toBetaCode('O(pli/ths', KeyType.BETA_CODE, Preset.TLG) // *(OPLI/THS
toBetaCode('*(OPLI/THS', KeyType.TLG_BETA_CODE) // O(pli/ths

const grStyle = { greekStyle: { useLunateSigma: true } }
toGreek('ἅγιος', KeyType.GREEK, grStyle) // ἅγιοϲ

const trStyle = { transliterationStyle: { lunatesigma_s: true } }
toTransliteration('Cōkrátēc', KeyType.TRANSLITERATION, trStyle) // Sōkrátēs
```

## OOP style

### Summary
Expand Down
Loading

0 comments on commit cfba815

Please sign in to comment.