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.

35 lines (34 loc) 1.65 kB
import { ALL_ASPECTS, aspectToIthkuil } from "../../formative/slot-8/aspect.js"; import { slotVIIIToIthkuil, vnToIthkuil } from "../../formative/slot-8/index.js"; import {} from "../../formative/slot-8/mood-or-case-scope.js"; import { has } from "../../helpers/has.js"; import { VOWEL_TO_STRESSED_VOWEL_MAP } from "../../helpers/stress.js"; import { WithWYAlternative } from "../../helpers/with-wy-alternative.js"; import { modularAdjunctScopeToIthkuil, } from "./scope.js"; import { modularAdjunctTypeToIthkuil } from "./type.js"; export * from "./scope.js"; export * from "./type.js"; /** * Converts a modular adjunct into Ithkuil. * * @param adjunct The adjunct to be converted. * @returns Romanized Ithkuilic text representing the adjunct. */ export function modularAdjunctToIthkuil(adjunct) { const type = modularAdjunctTypeToIthkuil(adjunct.type ?? "WHOLE"); if (adjunct.scope == null && adjunct.vn3 == null) { const aspect = WithWYAlternative.of(aspectToIthkuil(adjunct.vn1)).withPreviousText(type); return type + aspect; } const vn1 = slotVIIIToIthkuil({ cn: adjunct.cn || "CCN", vn: adjunct.vn1 }, { omitDefault: false }).withPreviousText(type); const vn2 = adjunct.vn2 ? WithWYAlternative.of(vnToIthkuil(adjunct.vn2, false)).withPreviousText(type + vn1) + (has(ALL_ASPECTS, adjunct.vn2) ? "n" : "ň") : ""; const output = type + vn1 + vn2; if (adjunct.vn3) { const vn3 = vnToIthkuil(adjunct.vn3, false); return WithWYAlternative.add(output, vn3); } return (output + VOWEL_TO_STRESSED_VOWEL_MAP[modularAdjunctScopeToIthkuil(adjunct.scope)]); }