#Directives
The directives option lets you override annotation marks for specific hanja
characters.
#Directive interface
interface Directives {
Directives.requireHanja?: string[] | undefined requireHanja ?: string[]; // always show hanja in output
Directives.requireHangul?: string[] | undefined requireHangul ?: string[]; // always show hangul reading (for "original" mode)
Directives.skipAnnotation?: string[] | undefined skipAnnotation ?: string[]; // suppress annotation entirely
}Each array contains hanja strings whose marks you want to override:
import { function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>Creates a Gukhanmun converter with the given options.
Initialises the WASM module on the first call (subsequent calls reuse the
cached module). Compiled dictionaries supplied via
GukhanmunOptions.dictionaries
are fetched, while
MapDictionarySource
entry lists are serialised and built in memory
as Rust MapDictionary values.
Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a
bundled dictionary. Pass dictionaries: [await stdictFst()] to include the
Standard Korean Language Dictionary.
@paramoptions - Conversion options. All fields are optional; defaults match
the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure. load } from "@gukhanmun/wasm";
import { function stdictFst(): Promise<FileDictionarySource>Loads the bundled Standard Korean Language Dictionary as a
FileDictionarySource
ready to pass to load({ dictionaries: [...] }).
@returnsA FileDictionarySource with format: "fst" and role: "reference". stdictFst } from "@gukhanmun/stdict-fst";
const const g: Gukhanmun g = await function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>Creates a Gukhanmun converter with the given options.
Initialises the WASM module on the first call (subsequent calls reuse the
cached module). Compiled dictionaries supplied via
GukhanmunOptions.dictionaries
are fetched, while
MapDictionarySource
entry lists are serialised and built in memory
as Rust MapDictionary values.
Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a
bundled dictionary. Pass dictionaries: [await stdictFst()] to include the
Standard Korean Language Dictionary.
@paramoptions - Conversion options. All fields are optional; defaults match
the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure. load ({
dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined dictionaries : [await function stdictFst(): Promise<FileDictionarySource>Loads the bundled Standard Korean Language Dictionary as a
FileDictionarySource
ready to pass to load({ dictionaries: [...] }).
@returnsA FileDictionarySource with format: "fst" and role: "reference". stdictFst ()],
directives?: Directives | undefinedPer-hanja rendering directives that override dictionary marks.
@seeDirectives directives : {
Directives.requireHanja?: readonly string[] | undefinedHanja forms that must always be shown with their original hanja
alongside the hangul reading, as if requireHanja were set in the
dictionary.
requireHanja : ["漢", "字"],
Directives.requireHangul?: readonly string[] | undefinedHanja forms that must always be shown with a hangul gloss alongside the
original hanja (relevant for rendering: "original").
requireHangul : ["東"],
Directives.skipAnnotation?: readonly string[] | undefinedHanja forms whose annotation should be suppressed entirely; the renderer
emits only the primary plain text form (hangul or hanja depending on
rendering).
skipAnnotation : ["中"],
},
});#Combining with rendering modes
Directives interact with the active rendering mode:
requireHanjais most visible in"hangul-only"mode, where it forces the hanja to appear alongside the hangul reading.requireHangulis useful in"original"mode to force the hangul gloss for specific characters.skipAnnotationsuppresses any annotation regardless of mode.