#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?: GukhanmunOptions): Promise<Gukhanmun>Creates a Gukhanmun converter with the given options.
Initialises the WASM module on the first call (subsequent calls reuse the
cached module). Dictionaries supplied via
GukhanmunOptions.dictionaries
are fetched and passed to the Rust
engine as FileDictionarySource 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". stdictFst } from "@gukhanmun/stdict-fst";
const const g: Gukhanmun g = await function load(options?: GukhanmunOptions): Promise<Gukhanmun>Creates a Gukhanmun converter with the given options.
Initialises the WASM module on the first call (subsequent calls reuse the
cached module). Dictionaries supplied via
GukhanmunOptions.dictionaries
are fetched and passed to the Rust
engine as FileDictionarySource 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 ({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefinedOrdered list of dictionary sources. Sources are queried in order;
earlier entries take precedence. When omitted (or empty), only the
fallback Unihan character map is used (no stdict).
Unlike the "ko-kr" Rust preset, JavaScript presets do not
automatically include a bundled dictionary. To use the Standard Korean
Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly.
@seeDictionarySource 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". stdictFst ()],
GukhanmunOptions.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.