UNPKG

@zsnout/ithkuil

Version:

A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.

104 lines (103 loc) 3.92 kB
import { type ConstructableCharacter, type FormativeToScriptOptions } from "./index.js"; import type { Result } from "./utilities/result.js"; /** * A helper type which removes properties that may only be undefined from an * object type `T`. */ export type OmitUndefinedValues<T> = T extends infer U ? { [K in keyof U as [U[K]] extends [undefined] ? never : K]: U[K]; } : never; /** * Converts romanized text into Ithkuil characters. * * @param text The text to be converted. * @param options If a boolean, marks whether the outputted characters should be * handwritten. Otherwise, an object marking properties about how to transform * the text. * @returns A `Result` containing an array of `ConstructableCharacter`s. */ export declare function textToScript(text: string, options?: FormativeToScriptOptions | boolean | undefined): Result<ConstructableCharacter[]>; /** * New script conversion norms * * {!flag} means {flag: false} or {flag: []} {=flag} means {flag: true} {flag?} * means {flag: flag} {flag¿} means {flag: !flag} * * Q(V?)(C?)(V?)([-~^:`'"¿]?)([/|><]{0,2}) Q1(formative whose primary will be * shown) Q2?(EVE|CVV|VVC|V?CV?|VV|V̀) Q3(VL)?(V[PEA])?V?([PEA]V)?(LV)? * Q4(Hmood)?V(Hcasescope)? V's stress determines case/ill+val * Q(A|IA?)[123]?[57]?V NV?\d{1,4}V? * * STATE: SELF (a list of self states based on current state) * * - STANDARD{carrier?, !adjuncts} * - SUPPLETIVE{register?} * - REGISTER * * STATE: GLOBAL (these are possible options in every state) * * - (word) (output) (next state) * - Q... adjuncts+alphabetic SELF * - Q1... adjuncts+primary SELF * - Q2?... adjuncts+secondary SELF * - Q3... adjuncts+tertiary SELF * - Q4... adjuncts+quaternary SELF * - Q(A|IA?)... adjuncts+accessor SELF * - QB... adjuncts+bias SELF * - (digits) adjuncts+numeral SELF * - N... adjuncts+numeral_adv SELF * - Hi adjuncts+register REGISTER_ONEWORD * - H[aeiou]?[0123]? adjuncts+register SELF * - H[aeiou]?[0123]? adjuncts+register REGISTER * - X[aeiou]?[0123]? adjuncts+register SUPPLETIVE{!register} * - X[aeiou]?[0123]? adjuncts+register SUPPLETIVE{=register} * - QS adjuncts STANDARD{!carrier, !adjuncts} * - QSC adjuncts STANDARD{=carrier, !adjuncts} * - QSS adjuncts SUPPLETIVE{!register} * - QSSR adjuncts SUPPLETIVE{=register} * - QSR adjuncts REGISTER * * STATE: STANDARD{carrier, adjuncts} (this is the default state) * * - (word) (output) (next state) * - Global states * - S... formative HUNT_REGISTER * - Hlas... formative STANDARD{=carrier} * - (child formative) formative+adjuncts STANDARD{carrier?, adjuncts?} * - (parent formative) formative+adjuncts STANDARD{!carrier, adjuncts?} if * carrier=false * - (parent formative) formative HUNT_REGISTER if carrier=true * - (affix/mod adjunct) ———————— STANDARD{!carrier, adjuncts: * adjuncts.with(this)} * - (bias adjunct) bias STANDARD{!carrier, adjuncts?} * - Hla/hmn/hna/hňa register REGISTER * * STATE: SUPPLETIVE{register} * * - Global states * - S... formative w/o -S- STANDARD{!carrier, !adjuncts} if register=false * - S... formative w/o -S- REGISTER if register=true * - STANDARD{!carrier, !adjuncts} if register=false * - REGISTER if register=false * * STATE: REGISTER (this state is for when writing alphabetics inside registers. * its goal is to write alphabetic characters while allowing global states to be * usable.) * * - @... secondaries REGISTER * - Global states * - ... secondaries REGISTER * * STATE: REGISTER_ONEWORD (this state is immediately after a lone "hi" adjunct. * its goal is to preserve the old just-one-word behavior.) * * - @... secondaries REGISTER * - Global states * - ... secondaries REGISTER * * STATE: HUNT_REGISTER (this state is immediately after carrier formatives. its * goal is to default to h1 but use other registers if provided) * * - Global states * - Register REGISTER */