# Gukhanmun ## Playground - [Playground](https://canary.gukhanmun.org/playground.md): Interactive demo for converting mixed-script Korean (國漢文混用體) to hangul in real time. Supports plain text, Markdown, and HTML input, with configurable rendering modes and options. ## Guide - [Introduction](https://canary.gukhanmun.org/guide/intro.md): An overview of Gukhanmun and how to choose between the CLI, Rust, JavaScript and Python interfaces. - [Punctuation profiles](https://canary.gukhanmun.org/guide/punctuation.md): Normalize commas, periods, and explicit citation delimiters independently of hanja rendering. - [Installation](https://canary.gukhanmun.org/guide/cli/install.md): How to install the Gukhanmun command-line tool. - [Quick start](https://canary.gukhanmun.org/guide/cli/start.md): Basic usage of the Gukhanmun command-line tool. - [Dictionaries](https://canary.gukhanmun.org/guide/cli/dictionary.md): Using the bundled dictionary and loading custom dictionaries from the CLI. - [Conversion options](https://canary.gukhanmun.org/guide/cli/conversion.md): Flags that control how Gukhanmun converts hanja to hangul. - [Rendering modes](https://canary.gukhanmun.org/guide/cli/rendering.md): How to control how Gukhanmun presents hanja and their hangul readings in the output. - [Directives](https://canary.gukhanmun.org/guide/cli/directives.md): Per-hanja overrides that force or suppress annotations for specific characters. - [HTML processing](https://canary.gukhanmun.org/guide/cli/html.md): How Gukhanmun handles HTML input and which elements it always skips. - [Markdown processing](https://canary.gukhanmun.org/guide/cli/markdown.md): How Gukhanmun converts Markdown documents, including selected YAML front matter fields. - [Installation](https://canary.gukhanmun.org/guide/rust/install.md): Adding Gukhanmun as a Rust dependency. - [Quick start](https://canary.gukhanmun.org/guide/rust/start.md): Basic usage of the Gukhanmun Rust library. - [Dictionaries](https://canary.gukhanmun.org/guide/rust/dictionary.md): Loading and composing dictionaries in the Gukhanmun Rust library. - [Conversion options](https://canary.gukhanmun.org/guide/rust/conversion.md): Builder methods that control how Gukhanmun converts hanja to hangul. - [Rendering modes](https://canary.gukhanmun.org/guide/rust/rendering.md): Controlling how Gukhanmun presents hanja and hangul readings in Rust. - [Directives](https://canary.gukhanmun.org/guide/rust/directives.md): Per-hanja annotation overrides in the Gukhanmun Rust library. - [Markdown conversion](https://canary.gukhanmun.org/guide/rust/markdown.md): Converting Markdown documents with the Gukhanmun Rust library. - [HTML conversion](https://canary.gukhanmun.org/guide/rust/html.md): Converting HTML documents with the Gukhanmun Rust library. - [Streaming API](https://canary.gukhanmun.org/guide/rust/streaming.md): Processing large documents incrementally with Gukhanmun's iterator API. - [Installation](https://canary.gukhanmun.org/guide/javascript/install.md): Installing Gukhanmun for JavaScript, TypeScript, Node.js, Deno, and browsers. - [Quick start](https://canary.gukhanmun.org/guide/javascript/start.md): Basic usage of the Gukhanmun JavaScript library. - [Dictionaries](https://canary.gukhanmun.org/guide/javascript/dictionary.md): Loading and using dictionaries with the Gukhanmun JavaScript library. - [Conversion options](https://canary.gukhanmun.org/guide/javascript/conversion.md): Options that control how Gukhanmun converts hanja to hangul in JavaScript. - [Rendering modes](https://canary.gukhanmun.org/guide/javascript/rendering.md): Controlling how Gukhanmun presents hanja and hangul readings in JavaScript. - [Directives](https://canary.gukhanmun.org/guide/javascript/directives.md): Per-hanja annotation overrides in the Gukhanmun JavaScript library. - [Markdown conversion](https://canary.gukhanmun.org/guide/javascript/markdown.md): Converting Markdown documents with the Gukhanmun JavaScript library. - [HTML processing](https://canary.gukhanmun.org/guide/javascript/html.md): Converting HTML and preserving specific elements in the Gukhanmun JavaScript library. - [Streaming API](https://canary.gukhanmun.org/guide/javascript/streaming.md): Feed string chunks through Gukhanmun's buffered TransformStream API. - [Logging](https://canary.gukhanmun.org/guide/javascript/logging.md): Configure LogTape in your application to see Gukhanmun's JavaScript logs, including deprecation warnings for legacy formats. - [Installation](https://canary.gukhanmun.org/guide/python/install.md): Install Gukhanmun from PyPI with pip, uv or Poetry, add optional dictionary data, or choose a prerelease or local build. - [Python quick start](https://canary.gukhanmun.org/guide/python/start.md): Convert text, HTML and Markdown in Python with a reusable Gukhanmun converter, explicit dictionaries and typed options. - [Dictionaries](https://canary.gukhanmun.org/guide/python/dictionaries.md): Load official dictionaries, runtime entries and compiled FST/CDB sources in Python, and control how their roles select readings. - [Conversion options](https://canary.gukhanmun.org/guide/python/conversion.md): Choose Python presets, segmentation and numeral strategies, and control homophone annotations, first occurrences and punctuation. - [Rendering modes](https://canary.gukhanmun.org/guide/python/rendering.md): Compare Python rendering modes, add ruby or parenthetical glosses, and select the hanja variants used in output. - [Directives](https://canary.gukhanmun.org/guide/python/directives.md): Use Python literal-hanja directives to require hanja or hangul glosses, or suppress annotation without changing reading selection. - [Markdown conversion](https://canary.gukhanmun.org/guide/python/markdown.md): Convert CommonMark and GitHub Flavored Markdown in Python while preserving code, destinations and raw HTML blocks. - [HTML processing](https://canary.gukhanmun.org/guide/python/html.md): Convert HTML fragments in Python, preserve selected subtrees, use ruby markup and choose strict or lenient recovery. - [Streaming API](https://canary.gukhanmun.org/guide/python/streaming.md): Use Python buffered conversion streams and iterables, handle stream finalization, and share a converter across document-processing threads. - [Supported platforms](https://canary.gukhanmun.org/guide/python/platforms.md): The platforms, interpreters and minimum versions that the Gukhanmun Python wheels support, and how to build the package from its source distribution. ## References - [API references](https://canary.gukhanmun.org/api/index.md): Gukhanmun provides APIs for Rust, JavaScript and Python. - [Changelog](https://canary.gukhanmun.org/api/changelog.md) - [Gukhanmun](https://canary.gukhanmun.org/api/js/index.md) - [Class: GukhanmunError](https://canary.gukhanmun.org/api/js/classes/_gukhanmun_napi.GukhanmunError.md): Error thrown by {@link load}, {@link Gukhanmun.convert}, and {@link Gukhanmun.stream} when the Rust engine reports a failure. code identifies the failure class; chain carries the full causal chain materialised at the FFI boundary so callers do not need additional round trips. - [Class: GukhanmunError](https://canary.gukhanmun.org/api/js/classes/_gukhanmun_types.GukhanmunError.md): Error class thrown by all Gukhanmun operations. Declared here as a declare class so this package remains purely type-level. The actual class (with identical shape) is provided by each runtime package (@gukhanmun/wasm and @gukhanmun/napi). The chain property exposes the Rust Error::source() chain materialised at the FFI boundary, allowing callers to inspect underlying causes without additional FFI calls. - [Class: GukhanmunError](https://canary.gukhanmun.org/api/js/classes/_gukhanmun_wasm.GukhanmunError.md): Error thrown by {@link load}, {@link Gukhanmun.convert}, and {@link Gukhanmun.stream} when the Rust engine reports a failure. code identifies the failure class; chain carries the full causal chain materialised at the FFI boundary so callers do not need additional round trips. - [Function: loanwordsCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_loanwords-cdb.loanwordsCdb.md): loanwordsCdb(): Promise Loads the bundled NIKL loanword examples as a FileDictionarySource ready to pass to load({ dictionaries: [...] }). - [Function: loanwordsCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_loanwords-cdb.loanwordsCdbBytes.md): loanwordsCdbBytes(url?): Promise> Loads the bundled NIKL loanword examples as raw bytes. The access strategy is chosen from the URL scheme, not from the host runtime. A file: URL is read from disk with node:fs/promises (Node.js, Deno, and Bun all provide it, and it is the only option since Node.js's fetch rejects file: URLs); any other scheme is retrieved with fetch. Branching on the scheme is what makes a JSR install work on Deno: there import.meta.url (and therefore loanwordsCdbUrl) is an https: URL, yet Deno also exposes process.versions.node, so a runtime sniff would wrongly take the node:fs path and readFile would reject the https: URL with "The URL must be of scheme file". - [Function: loanwordsFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_loanwords-fst.loanwordsFst.md): loanwordsFst(): Promise Loads the bundled NIKL loanword examples as a FileDictionarySource ready to pass to load({ dictionaries: [...] }). - [Function: loanwordsFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_loanwords-fst.loanwordsFstBytes.md): loanwordsFstBytes(url?): Promise> Loads the bundled NIKL loanword examples as raw bytes. The access strategy is chosen from the URL scheme, not from the host runtime. A file: URL is read from disk with node:fs/promises (Node.js, Deno, and Bun all provide it, and it is the only option since Node.js's fetch rejects file: URLs); any other scheme is retrieved with fetch. Branching on the scheme is what makes a JSR install work on Deno: there import.meta.url (and therefore loanwordsFstUrl) is an https: URL, yet Deno also exposes process.versions.node, so a runtime sniff would wrongly take the node:fs path and readFile would reject the https: URL with "The URL must be of scheme file". - [Function: load()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_napi.load.md): load(options?): Promise Creates a Gukhanmun converter with the given options. The native addon is synchronously ready; compiled dictionaries supplied via {@link GukhanmunOptions.dictionaries} are fetched or read from disk, while {@link 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. - [Function: loadDictionary()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_napi.loadDictionary.md): loadDictionary(source): Promise Loads one immutable dictionary snapshot for reuse by this backend. - [Function: opendictArchaicCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictArchaicCdb.md): opendictArchaicCdb(): Promise Loads the bundled Open Korean Dictionary 옛말 dictionary. - [Function: opendictArchaicCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictArchaicCdbBytes.md): opendictArchaicCdbBytes(url?): Promise> Loads the bundled Open Korean Dictionary 옛말 CDB binary as raw bytes. - [Function: opendictCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictCdbBytes.md): opendictCdbBytes(url): Promise> Loads an Open Korean Dictionary CDB binary as raw bytes. A file: URL is read from disk with node:fs/promises when running in Node.js, Deno, or Bun; in other runtimes (e.g. browsers) and for all other schemes the bytes are retrieved with fetch. The bundled binaries are stored gzip-compressed to stay within registry per-file size limits. Bytes that begin with the gzip magic number are therefore inflated transparently, so the returned value is always the raw CDB ready to hand to load; bytes that are not gzip-compressed are returned unchanged. - [Function: opendictDialectCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictDialectCdb.md): opendictDialectCdb(): Promise Loads the bundled Open Korean Dictionary 방언 dictionary. - [Function: opendictDialectCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictDialectCdbBytes.md): opendictDialectCdbBytes(url?): Promise> Loads the bundled Open Korean Dictionary 방언 CDB binary as raw bytes. - [Function: opendictGeneralCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictGeneralCdb.md): opendictGeneralCdb(): Promise Loads the bundled Open Korean Dictionary 일반어 dictionary. - [Function: opendictGeneralCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictGeneralCdbBytes.md): opendictGeneralCdbBytes(url?): Promise> Loads the bundled Open Korean Dictionary 일반어 CDB binary as raw bytes. - [Function: opendictNorthKoreanCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictNorthKoreanCdb.md): opendictNorthKoreanCdb(): Promise Loads the bundled Open Korean Dictionary 북한어 dictionary. - [Function: opendictNorthKoreanCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-cdb.opendictNorthKoreanCdbBytes.md): opendictNorthKoreanCdbBytes(url?): Promise> Loads the bundled Open Korean Dictionary 북한어 CDB binary as raw bytes. - [Function: opendictArchaicFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictArchaicFst.md): opendictArchaicFst(): Promise Loads the bundled Open Korean Dictionary 옛말 dictionary. - [Function: opendictArchaicFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictArchaicFstBytes.md): opendictArchaicFstBytes(url?): Promise> Loads the bundled Open Korean Dictionary 옛말 FST binary as raw bytes. - [Function: opendictDialectFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictDialectFst.md): opendictDialectFst(): Promise Loads the bundled Open Korean Dictionary 방언 dictionary. - [Function: opendictDialectFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictDialectFstBytes.md): opendictDialectFstBytes(url?): Promise> Loads the bundled Open Korean Dictionary 방언 FST binary as raw bytes. - [Function: opendictFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictFstBytes.md): opendictFstBytes(url): Promise> Loads an Open Korean Dictionary FST binary as raw bytes. A file: URL is read from disk with node:fs/promises when running in Node.js, Deno, or Bun; in other runtimes (e.g. browsers) and for all other schemes the bytes are retrieved with fetch. - [Function: opendictGeneralFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictGeneralFst.md): opendictGeneralFst(): Promise Loads the bundled Open Korean Dictionary 일반어 dictionary. - [Function: opendictGeneralFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictGeneralFstBytes.md): opendictGeneralFstBytes(url?): Promise> Loads the bundled Open Korean Dictionary 일반어 FST binary as raw bytes. - [Function: opendictNorthKoreanFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictNorthKoreanFst.md): opendictNorthKoreanFst(): Promise Loads the bundled Open Korean Dictionary 북한어 dictionary. - [Function: opendictNorthKoreanFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_opendict-fst.opendictNorthKoreanFstBytes.md): opendictNorthKoreanFstBytes(url?): Promise> Loads the bundled Open Korean Dictionary 북한어 FST binary as raw bytes. - [Function: stdictCdb()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_stdict-cdb.stdictCdb.md): stdictCdb(): Promise Loads the bundled Standard Korean Language Dictionary as a FileDictionarySource ready to pass to load({ dictionaries: [...] }). - [Function: stdictCdbBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_stdict-cdb.stdictCdbBytes.md): stdictCdbBytes(url?): Promise> Loads the bundled Standard Korean Language Dictionary as raw bytes. The access strategy is chosen from the URL scheme, not from the host runtime. A file: URL is read from disk with node:fs/promises (Node.js, Deno, and Bun all provide it, and it is the only option since Node.js's fetch rejects file: URLs); any other scheme is retrieved with fetch. Branching on the scheme is what makes a JSR install work on Deno: there import.meta.url (and therefore stdictCdbUrl) is an https: URL, yet Deno also exposes process.versions.node, so a runtime sniff would wrongly take the node:fs path and readFile would reject the https: URL with "The URL must be of scheme file". Gzip is detected from the payload's magic bytes, so compressed files are inflated transparently and relocated raw CDB files remain supported. - [Function: stdictFst()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_stdict-fst.stdictFst.md): stdictFst(): Promise Loads the bundled Standard Korean Language Dictionary as a FileDictionarySource ready to pass to load({ dictionaries: [...] }). - [Function: stdictFstBytes()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_stdict-fst.stdictFstBytes.md): stdictFstBytes(url?): Promise> Loads the bundled Standard Korean Language Dictionary as raw bytes. The access strategy is chosen from the URL scheme, not from the host runtime. A file: URL is read from disk with node:fs/promises (Node.js, Deno, and Bun all provide it, and it is the only option since Node.js's fetch rejects file: URLs); any other scheme is retrieved with fetch. Branching on the scheme is what makes a JSR install work on Deno: there import.meta.url (and therefore stdictFstUrl) is an https: URL, yet Deno also exposes process.versions.node, so a runtime sniff would wrongly take the node:fs path and readFile would reject the https: URL with "The URL must be of scheme file". - [Function: load()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_types.load.md): load(options?): Promise Top-level entry point exported by both @gukhanmun/wasm and @gukhanmun/napi as a named export. Equivalent to new GukhanmunFactory().load(options). Declared here so that code that import { load } from either implementation package type-checks against the same signature. - [Function: loadDictionary()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_types.loadDictionary.md): loadDictionary(source): Promise Load one dictionary snapshot for reuse by converters on this backend. - [Function: load()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_wasm.load.md): load(options?): Promise 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 {@link GukhanmunOptions.dictionaries} are fetched, while {@link 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. - [Function: loadDictionary()](https://canary.gukhanmun.org/api/js/functions/_gukhanmun_wasm.loadDictionary.md): loadDictionary(source): Promise Loads one immutable dictionary snapshot for reuse by this backend. - [Interface: CustomPunctuationProfile](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.CustomPunctuationProfile.md): Partial overrides; omitted roles inherit, null preserves the role. - [Interface: DelimiterStyle](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.DelimiterStyle.md): Opening and closing Unicode punctuation scalars. - [Interface: DictionaryEntry](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.DictionaryEntry.md): A single dictionary entry: a hanja key with one hangul reading. Callers pass these in MapDictionarySource.entries to build a dictionary at runtime. Fields mirror the Rust ReadingCandidate type plus the hanja key. - [Interface: Directives](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.Directives.md): Per-hanja rendering directives that override the dictionary's own marks. Each list contains hanja forms (exact string matches, e.g. "漢字"). JavaScript bindings expose only the literal-set form; glob and predicate variants are available in the Rust API only. Corresponds to Rust UserDirectives with DirectiveAction::RequireHanja, DirectiveAction::RequireHangul, and DirectiveAction::SkipAnnotation. - [Interface: FileDictionarySource](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.FileDictionarySource.md): Specifies a dictionary loaded from a binary file or URL. The data field accepts: A BufferSource (ArrayBuffer or ArrayBufferView) — supported in all environments.A URL — resolved via fetch in browsers; via node:fs/promises in Node.js, Deno 2.0+, and Bun.A string — treated as a filesystem path; supported in Node.js, Deno 2.0+, and Bun only. Throws in browser environments. At runtime, a FileDictionarySource is distinguished from other values by the absence of an entries property ("entries" in source selects a MapDictionarySource). - [Interface: Gukhanmun](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.Gukhanmun.md): A configured hanja-to-hangul converter. Created by calling GukhanmunFactory.load (or the top-level load function). The instance is immutable after creation; call load again to obtain a converter with different options. - [Interface: GukhanmunFactory](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.GukhanmunFactory.md): Factory interface satisfied by both @gukhanmun/wasm and @gukhanmun/napi. - [Interface: GukhanmunOptions](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.GukhanmunOptions.md): Full set of options passed to GukhanmunFactory.load (or the top-level load function) to configure a Gukhanmun instance. All fields are optional. When a preset is specified it supplies defaults; individual fields override those defaults. When no preset is given, "ko-kr" is implicitly used. - [Interface: HtmlOptions](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.HtmlOptions.md): Fine-grained HTML preservation rules passed in GukhanmunOptions.html. These are additive: a scope is preserved when any rule matches. They correspond to the CLI flags --html-preserve-class and --html-preserve-attr, and to the Rust Builder::html_preserve_when predicate. - [Interface: LoadedDictionary](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.LoadedDictionary.md): An immutable dictionary snapshot made by a backend's loadDictionary. Use the handle with the same backend instance that created it. - [Interface: MapDictionarySource](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.MapDictionarySource.md): A dictionary built from entries computed at runtime, such as per-document reading overrides. Use this instead of compiling a TSV file with gukhanmun-mkdict when the entries do not exist on disk, for example in a browser, an edge runtime, or a site generator that derives entries per document. A source is distinguished from a FileDictionarySource by the presence of an entries property. - [Interface: ResolvedPunctuationProfile](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.ResolvedPunctuationProfile.md): Fully resolved styles, copied and deeply frozen by each binding. - [Interface: StopStyle](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_napi.StopStyle.md): A single Unicode scalar and its following U+0020 policy. - [Interface: CustomPunctuationProfile](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.CustomPunctuationProfile.md): Partial overrides; omitted roles inherit, null preserves the role. - [Interface: DelimiterStyle](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.DelimiterStyle.md): Opening and closing Unicode punctuation scalars. - [Interface: DictionaryEntry](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.DictionaryEntry.md): A single dictionary entry: a hanja key with one hangul reading. Callers pass these in MapDictionarySource.entries to build a dictionary at runtime. Fields mirror the Rust ReadingCandidate type plus the hanja key. - [Interface: Directives](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.Directives.md): Per-hanja rendering directives that override the dictionary's own marks. Each list contains hanja forms (exact string matches, e.g. "漢字"). JavaScript bindings expose only the literal-set form; glob and predicate variants are available in the Rust API only. Corresponds to Rust UserDirectives with DirectiveAction::RequireHanja, DirectiveAction::RequireHangul, and DirectiveAction::SkipAnnotation. - [Interface: FileDictionarySource](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.FileDictionarySource.md): Specifies a dictionary loaded from a binary file or URL. The data field accepts: A BufferSource (ArrayBuffer or ArrayBufferView) — supported in all environments.A URL — resolved via fetch in browsers; via node:fs/promises in Node.js, Deno 2.0+, and Bun.A string — treated as a filesystem path; supported in Node.js, Deno 2.0+, and Bun only. Throws in browser environments. At runtime, a FileDictionarySource is distinguished from other values by the absence of an entries property ("entries" in source selects a MapDictionarySource). - [Interface: Gukhanmun](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.Gukhanmun.md): A configured hanja-to-hangul converter. Created by calling GukhanmunFactory.load (or the top-level load function). The instance is immutable after creation; call load again to obtain a converter with different options. - [Interface: GukhanmunFactory](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.GukhanmunFactory.md): Factory interface satisfied by both @gukhanmun/wasm and @gukhanmun/napi. - [Interface: GukhanmunOptions](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.GukhanmunOptions.md): Full set of options passed to GukhanmunFactory.load (or the top-level load function) to configure a Gukhanmun instance. All fields are optional. When a preset is specified it supplies defaults; individual fields override those defaults. When no preset is given, "ko-kr" is implicitly used. - [Interface: HtmlOptions](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.HtmlOptions.md): Fine-grained HTML preservation rules passed in GukhanmunOptions.html. These are additive: a scope is preserved when any rule matches. They correspond to the CLI flags --html-preserve-class and --html-preserve-attr, and to the Rust Builder::html_preserve_when predicate. - [Interface: LoadedDictionary](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.LoadedDictionary.md): An immutable dictionary snapshot made by a backend's loadDictionary. Use the handle with the same backend instance that created it. - [Interface: MapDictionarySource](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.MapDictionarySource.md): A dictionary built from entries computed at runtime, such as per-document reading overrides. Use this instead of compiling a TSV file with gukhanmun-mkdict when the entries do not exist on disk, for example in a browser, an edge runtime, or a site generator that derives entries per document. A source is distinguished from a FileDictionarySource by the presence of an entries property. - [Interface: ResolvedPunctuationProfile](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.ResolvedPunctuationProfile.md): Fully resolved styles, copied and deeply frozen by each binding. - [Interface: StopStyle](https://canary.gukhanmun.org/api/js/interfaces/_gukhanmun_types.StopStyle.md): A single Unicode scalar and its following U+0020 policy. - [Module: @gukhanmun/loanwords-cdb](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_loanwords-cdb.md): NIKL loanword examples prebuilt as a CDB binary for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/loanwords-fst](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_loanwords-fst.md): NIKL loanword examples prebuilt as an FST binary for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/napi](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_napi.md): Node.js native addon (napi-rs) implementation of the Gukhanmun hanja-to-hangul converter. Provides the same {@link load} / {@link Gukhanmun} contract as @gukhanmun/wasm but uses a precompiled native addon for maximum throughput. Node.js 20+ is required. The native addon binary (gukhanmun_napi.node) must be present in the package directory; build it locally with mise run napi-build. The load() factory is asynchronous for API uniformity with the WASM backend, but the native addon is synchronously ready—dictionary data is the only async part. - [Module: @gukhanmun/opendict-cdb](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_opendict-cdb.md): Open Korean Dictionary (우리말샘) categories prebuilt as CDB binaries for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/opendict-fst](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_opendict-fst.md): Open Korean Dictionary (우리말샘) categories prebuilt as FST binaries for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/stdict-cdb](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_stdict-cdb.md): Standard Korean Language Dictionary (標準國語大辭典) prebuilt as a CDB binary for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/stdict-fst](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_stdict-fst.md): Standard Korean Language Dictionary (標準國語大辭典) prebuilt as an FST binary for use with {@link load} from @gukhanmun/wasm or @gukhanmun/napi. - [Module: @gukhanmun/types](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_types.md): Canonical TypeScript API contract for Gukhanmun. This package contains only TypeScript type declarations and carries no runtime code. Both @gukhanmun/wasm and @gukhanmun/napi satisfy this contract structurally. All TSDoc lives here as the single source of truth for the JavaScript API. - [Module: @gukhanmun/wasm](https://canary.gukhanmun.org/api/js/modules/_gukhanmun_wasm.md): WebAssembly implementation of the Gukhanmun hanja-to-hangul converter. Provides the same {@link load} / {@link Gukhanmun} contract as @gukhanmun/napi but runs in any WebAssembly-capable environment—browsers, Deno 2.0+, Node 20+, and Bun 1.0+. The WASM module is initialised lazily on the first load() call and cached for subsequent calls. Dictionary data (FST format) must be supplied explicitly via {@link GukhanmunOptions.dictionaries}. - [Type Alias: AnnotationGranularity](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.AnnotationGranularity.md): AnnotationGranularity = "word" | "hanja-run" The span to annotate when both scripts are shown. "word" keeps the whole-word gloss. "hanja-run" annotates contiguous hanja runs when the reading can be split uniquely, and otherwise keeps the whole-word gloss. - [Type Alias: ContextWindow](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.ContextWindow.md): ContextWindow = "off" | "per-block" | "per-section" | "per-document" Defines the scope within which the homophone marker and first-occurrence filter track previously seen readings. Corresponds to Rust ContextWindow. "off" — Disable the corresponding middleware entirely."per-block" — Reset at each block boundary (paragraph, list item, heading, …). This is the default for both homophone marking and first- occurrence filtering. In plain text, which has no block scopes, per-block is document-wide."per-section" — Reset at each heading boundary (HTML

–

, Markdown ATX/setext headings)."per-document" — Track across the entire document. This buffers the entire token stream and is appropriate only for small inputs or when full accuracy matters more than latency. - [Type Alias: DictionarySource](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.DictionarySource.md): DictionarySource = FileDictionarySource | MapDictionarySource A dictionary source accepted by GukhanmunOptions.dictionaries. Authored overrides take precedence over cooperative reference and loanword sources. GukhanmunOptions.sourcePolicy controls cooperation; the "ordered" policy restores first-match array ordering. Source roles do not infer lexical identity or authorize forms without reference evidence. - [Type Alias: ErrorCode](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.ErrorCode.md): ErrorCode = "dictionary-load" | "segmentation" | "invalid-reading" | "html-scan" | "html-malformed-attr" | "markdown" | "unsupported-content-type" | "invalid-input" | "io" | "internal" | "other" Discriminant code carried by every GukhanmunError. "dictionary-load" — A dictionary file could not be opened, read, or decoded."segmentation" — The lattice segmenter encountered an internal inconsistency."invalid-reading" — A dictionary entry's hangul reading is not valid hangul."html-scan" — The HTML scanner encountered an unrecoverable error."html-malformed-attr" — An HTML attribute string could not be parsed."markdown" — The Markdown adapter encountered a parsing error."unsupported-content-type" — An unrecognised format string was passed to convert or stream."invalid-input" — An option value is not in the expected set (e.g. an unrecognised preset or render mode string)."io" — An I/O error occurred (file read, network, …)."internal" — An internal invariant was violated; this is a bug."other" — Any other error not covered by the above codes. - [Type Alias: Format](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.Format.md): Format = MediaType | "text" | "html" | "markdown" | { format: "markdown"; gfm?: boolean; } Input/output format for Gukhanmun.convert and Gukhanmun.stream. Includes legacy selectors for compatibility until Gukhanmun 1.0. Use MediaType for new code. - [Type Alias: GukhanmunLoadOptions](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.GukhanmunLoadOptions.md): GukhanmunLoadOptions = Omit & object Options for the backend's top-level load function. Loaded snapshots can appear alongside ordinary dictionary sources in registration order. - [Type Alias: HanjaVariantSet](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.HanjaVariantSet.md): HanjaVariantSet = "as-dictionary" | "shinjitai" | "kanxi" | "simplified" | "asahimoji" The hanja variant set applied after dictionary recognition. - [Type Alias: HomophoneDetection](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.HomophoneDetection.md): HomophoneDetection = "context-local" | "dictionary-wide" Selects how the homophone marker decides that a reading needs its hanja shown in rendering: "hangul-only". Corresponds to Rust HomophoneDetection. "context-local" — Gloss a reading only when a different-meaning homophone actually appears within the ContextWindow. This keeps hangul-only output clean and is the default."dictionary-wide" — Also gloss readings shared by other hanja forms anywhere in the dictionary, even when no homophone appears in the text. With a large reference dictionary this glosses most Sino-Korean words; words that should always be glossed are better expressed with requireHanja. - [Type Alias: MediaType](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.MediaType.md): MediaType = "text/plain" | "text/html" | "text/markdown" | "text/markdown; variant=GFM" Canonical input/output media types for Gukhanmun.convert and Gukhanmun.stream. "text/plain": Plain text (default). Ruby rendering falls back to parentheses."text/html": HTML fragments."text/markdown": CommonMark Markdown."text/markdown; variant=GFM": GitHub Flavored Markdown, including tables, strikethrough, and task lists. - [Type Alias: NumeralStrategy](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.NumeralStrategy.md): NumeralStrategy = "hangul-phonetic" | "positional-arabic" | "additive-arabic" | "smart" Controls how runs of hanja numerals are converted. Corresponds to Rust NumeralStrategy. "hangul-phonetic" — Read every digit character-by-character in Korean phonetics. This is Seonbi's behaviour and the preset default. Corresponds to Rust NumeralStrategy::HangulPhonetic."positional-arabic" — Treat a run of digit-only hanja (〇一二三四五六七八九 and variants) as positional (place-value) notation and convert to Arabic. Corresponds to Rust NumeralStrategy::PositionalArabic."additive-arabic" — Parse sequences containing place markers (十百千萬億兆京) using stack-based accumulation and produce Arabic, respecting the Korean convention that bare 十 means 10 not 一十. Corresponds to Rust NumeralStrategy::AdditiveArabic."smart" — Uses "additive-arabic" for additive numerals that begin with a digit, and for small-place-marker starts (十, 百, 千) unless the next character is an ambiguous non-unit hanja word character; uses "positional-arabic" for pure-digit runs of four or more characters (year convention) or when a unit hanja follows the digit run (年月日時分秒號世紀 and others); otherwise falls back to "hangul-phonetic". Corresponds to Rust NumeralStrategy::Smart. - [Type Alias: OriginalGloss](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.OriginalGloss.md): OriginalGloss = "parens" | "ruby" Selects how glosses are rendered when RenderMode is "original". "parens" — Wrap the gloss in parentheses: 漢字(한글) (default). Corresponds to Rust OriginalGloss::Parens."ruby" — Wrap the gloss in a element. Falls back to parentheses in scopes that do not permit inline markup. Corresponds to Rust OriginalGloss::Ruby. This option is ignored when rendering is not "original". - [Type Alias: Preset](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.Preset.md): Preset = "ko-kr" | "ko-kp" Named configuration preset that sets orthographic and lexical defaults. "ko-kr" — South Korean orthography: dictionary-driven readings, the initial sound law applied to fallback fragments, per-block homophone disambiguation, and the bundled Standard Korean Language Dictionary (標準國語大辭典). Corresponds to Rust Preset::KoKr."ko-kp" — North Korean orthography: no initial sound law (래일, 류행, 녀자), no bundled dictionary data. Corresponds to Rust Preset::KoKp. Both presets default rendering to "hangul-only" and segmentation to "lattice". Individual options passed to GukhanmunOptions override the preset. - [Type Alias: PunctuationPreset](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.PunctuationPreset.md): PunctuationPreset = "preserve" | "modern" | "traditional" | "traditional-vertical" Built-in output style; input recognition is independent of this choice. - [Type Alias: Recovery](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.Recovery.md): Recovery = "strict" | "lenient" Controls how the pipeline handles reader errors encountered during HTML scanning. Corresponds to Rust Recovery. "strict" — Propagate the error and stop (default)."lenient" — Log the error via tracing and emit a verbatim token for the unrecognised region so that downstream tokens continue to flow. This option is meaningful only for format: "html". Markdown parsing does not produce recoverable errors, so this option is ignored for Markdown input. - [Type Alias: RenderMode](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.RenderMode.md): RenderMode = "hangul-only" | "hangul-hanja-parens" | "hanja-hangul-parens" | "ruby-on-hangul" | "ruby-on-hanja" | "original" Controls how the renderer expands each converted hanja annotation into output text or markup. Corresponds to Rust RenderMode. "hangul-only" — Emit only the hangul reading. When homophone or require_hanja is set on an annotation the reading is followed by the original hanja in parentheses: 한글(漢字). Corresponds to Rust RenderMode::HangulOnly."hangul-hanja-parens" — Always emit 한글(漢字). Corresponds to Rust RenderMode::HangulHanjaParens."hanja-hangul-parens" — Always emit 漢字(한글). Useful for academic and historical-document styles. Corresponds to Rust RenderMode::HanjaHangulParens."ruby-on-hangul" — Emit 한글漢字. Falls back to parentheses when the current scope does not permit inline markup (e.g., inside
).  Corresponds to Rust RenderMode::Ruby(RubyBase::OnHangul)."ruby-on-hanja" — Emit 漢字한글. Corresponds to Rust RenderMode::Ruby(RubyBase::OnHanja)."original" — Keep the original mixed-script form; only annotations with require_hangul or a user directive receive a hangul gloss, which appears either in parentheses or as a ruby element depending on GukhanmunOptions.originalGloss.  Corresponds to Rust RenderMode::Original.
- [Type Alias: Segmentation](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.Segmentation.md): Segmentation = "lattice" | "eager" Controls how the engine segments a hanja-containing span into dictionary words and fallback fragments.  Corresponds to Rust SegmentationStrategy. "lattice" — Dynamic programming over all possible dictionary matches at each position; selects the segmentation that maximises dictionary coverage and then prefers fewer segments.  This is the default and produces better results than greedy approaches when a longer prefix would leave a suffix uncovered by the dictionary.  Corresponds to Rust SegmentationStrategy::Lattice."eager" — Left-to-right longest-match (greedy).  Lower overhead per span at the cost of occasional mis-segmentation.  Corresponds to Rust SegmentationStrategy::Eager.
- [Type Alias: SourcePolicy](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.SourcePolicy.md): SourcePolicy = "reference-authorized" | "reference-first" | "loanword-first" | "ordered" Cooperation between reference dictionaries and independent loanword sources. "reference-authorized" uses typed reference evidence to authorize alternate forms. "reference-first" and "loanword-first" select an explicit preference; "ordered" restores the original array-order behavior and ignores roles and GukhanmunOptions.referenceOnly. Authored overrides remain exclusive under every cooperative policy.
- [Type Alias: SourceRole](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.SourceRole.md): SourceRole = "override" | "reference" | "loanword" A source's role, independent of preference among its own readings.
- [Type Alias: SpaceAfter](https://canary.gukhanmun.org/api/js/types/_gukhanmun_napi.SpaceAfter.md): SpaceAfter = "preserve" | "remove" | "single" Policy for ordinary spaces following an eligible stop.
- [Type Alias: AnnotationGranularity](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.AnnotationGranularity.md): AnnotationGranularity = "word" | "hanja-run" The span to annotate when both scripts are shown. "word" keeps the whole-word gloss. "hanja-run" annotates contiguous hanja runs when the reading can be split uniquely, and otherwise keeps the whole-word gloss.
- [Type Alias: ContextWindow](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.ContextWindow.md): ContextWindow = "off" | "per-block" | "per-section" | "per-document" Defines the scope within which the homophone marker and first-occurrence filter track previously seen readings.  Corresponds to Rust ContextWindow. "off" — Disable the corresponding middleware entirely."per-block" — Reset at each block boundary (paragraph, list item, heading, …).  This is the default for both homophone marking and first- occurrence filtering.  In plain text, which has no block scopes, per-block is document-wide."per-section" — Reset at each heading boundary (HTML 

–

, Markdown ATX/setext headings)."per-document" — Track across the entire document. This buffers the entire token stream and is appropriate only for small inputs or when full accuracy matters more than latency. - [Type Alias: DictionarySource](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.DictionarySource.md): DictionarySource = FileDictionarySource | MapDictionarySource A dictionary source accepted by GukhanmunOptions.dictionaries. Authored overrides take precedence over cooperative reference and loanword sources. GukhanmunOptions.sourcePolicy controls cooperation; the "ordered" policy restores first-match array ordering. Source roles do not infer lexical identity or authorize forms without reference evidence. - [Type Alias: ErrorCode](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.ErrorCode.md): ErrorCode = "dictionary-load" | "segmentation" | "invalid-reading" | "html-scan" | "html-malformed-attr" | "markdown" | "unsupported-content-type" | "invalid-input" | "io" | "internal" | "other" Discriminant code carried by every GukhanmunError. "dictionary-load" — A dictionary file could not be opened, read, or decoded."segmentation" — The lattice segmenter encountered an internal inconsistency."invalid-reading" — A dictionary entry's hangul reading is not valid hangul."html-scan" — The HTML scanner encountered an unrecoverable error."html-malformed-attr" — An HTML attribute string could not be parsed."markdown" — The Markdown adapter encountered a parsing error."unsupported-content-type" — An unrecognised format string was passed to convert or stream."invalid-input" — An option value is not in the expected set (e.g. an unrecognised preset or render mode string)."io" — An I/O error occurred (file read, network, …)."internal" — An internal invariant was violated; this is a bug."other" — Any other error not covered by the above codes. - [Type Alias: Format](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.Format.md): Format = MediaType | "text" | "html" | "markdown" | { format: "markdown"; gfm?: boolean; } Input/output format for Gukhanmun.convert and Gukhanmun.stream. Includes legacy selectors for compatibility until Gukhanmun 1.0. Use MediaType for new code. - [Type Alias: GukhanmunLoadOptions](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.GukhanmunLoadOptions.md): GukhanmunLoadOptions = Omit & object Options for the backend's top-level load function. Loaded snapshots can appear alongside ordinary dictionary sources in registration order. - [Type Alias: HanjaVariantSet](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.HanjaVariantSet.md): HanjaVariantSet = "as-dictionary" | "shinjitai" | "kanxi" | "simplified" | "asahimoji" The hanja variant set applied after dictionary recognition. - [Type Alias: HomophoneDetection](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.HomophoneDetection.md): HomophoneDetection = "context-local" | "dictionary-wide" Selects how the homophone marker decides that a reading needs its hanja shown in rendering: "hangul-only". Corresponds to Rust HomophoneDetection. "context-local" — Gloss a reading only when a different-meaning homophone actually appears within the ContextWindow. This keeps hangul-only output clean and is the default."dictionary-wide" — Also gloss readings shared by other hanja forms anywhere in the dictionary, even when no homophone appears in the text. With a large reference dictionary this glosses most Sino-Korean words; words that should always be glossed are better expressed with requireHanja. - [Type Alias: MediaType](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.MediaType.md): MediaType = "text/plain" | "text/html" | "text/markdown" | "text/markdown; variant=GFM" Canonical input/output media types for Gukhanmun.convert and Gukhanmun.stream. "text/plain": Plain text (default). Ruby rendering falls back to parentheses."text/html": HTML fragments."text/markdown": CommonMark Markdown."text/markdown; variant=GFM": GitHub Flavored Markdown, including tables, strikethrough, and task lists. - [Type Alias: NumeralStrategy](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.NumeralStrategy.md): NumeralStrategy = "hangul-phonetic" | "positional-arabic" | "additive-arabic" | "smart" Controls how runs of hanja numerals are converted. Corresponds to Rust NumeralStrategy. "hangul-phonetic" — Read every digit character-by-character in Korean phonetics. This is Seonbi's behaviour and the preset default. Corresponds to Rust NumeralStrategy::HangulPhonetic."positional-arabic" — Treat a run of digit-only hanja (〇一二三四五六七八九 and variants) as positional (place-value) notation and convert to Arabic. Corresponds to Rust NumeralStrategy::PositionalArabic."additive-arabic" — Parse sequences containing place markers (十百千萬億兆京) using stack-based accumulation and produce Arabic, respecting the Korean convention that bare 十 means 10 not 一十. Corresponds to Rust NumeralStrategy::AdditiveArabic."smart" — Uses "additive-arabic" for additive numerals that begin with a digit, and for small-place-marker starts (十, 百, 千) unless the next character is an ambiguous non-unit hanja word character; uses "positional-arabic" for pure-digit runs of four or more characters (year convention) or when a unit hanja follows the digit run (年月日時分秒號世紀 and others); otherwise falls back to "hangul-phonetic". Corresponds to Rust NumeralStrategy::Smart. - [Type Alias: OriginalGloss](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.OriginalGloss.md): OriginalGloss = "parens" | "ruby" Selects how glosses are rendered when RenderMode is "original". "parens" — Wrap the gloss in parentheses: 漢字(한글) (default). Corresponds to Rust OriginalGloss::Parens."ruby" — Wrap the gloss in a element. Falls back to parentheses in scopes that do not permit inline markup. Corresponds to Rust OriginalGloss::Ruby. This option is ignored when rendering is not "original". - [Type Alias: Preset](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.Preset.md): Preset = "ko-kr" | "ko-kp" Named configuration preset that sets orthographic and lexical defaults. "ko-kr" — South Korean orthography: dictionary-driven readings, the initial sound law applied to fallback fragments, per-block homophone disambiguation, and the bundled Standard Korean Language Dictionary (標準國語大辭典). Corresponds to Rust Preset::KoKr."ko-kp" — North Korean orthography: no initial sound law (래일, 류행, 녀자), no bundled dictionary data. Corresponds to Rust Preset::KoKp. Both presets default rendering to "hangul-only" and segmentation to "lattice". Individual options passed to GukhanmunOptions override the preset. - [Type Alias: PunctuationPreset](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.PunctuationPreset.md): PunctuationPreset = "preserve" | "modern" | "traditional" | "traditional-vertical" Built-in output style; input recognition is independent of this choice. - [Type Alias: Recovery](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.Recovery.md): Recovery = "strict" | "lenient" Controls how the pipeline handles reader errors encountered during HTML scanning. Corresponds to Rust Recovery. "strict" — Propagate the error and stop (default)."lenient" — Log the error via tracing and emit a verbatim token for the unrecognised region so that downstream tokens continue to flow. This option is meaningful only for format: "html". Markdown parsing does not produce recoverable errors, so this option is ignored for Markdown input. - [Type Alias: RenderMode](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.RenderMode.md): RenderMode = "hangul-only" | "hangul-hanja-parens" | "hanja-hangul-parens" | "ruby-on-hangul" | "ruby-on-hanja" | "original" Controls how the renderer expands each converted hanja annotation into output text or markup. Corresponds to Rust RenderMode. "hangul-only" — Emit only the hangul reading. When homophone or require_hanja is set on an annotation the reading is followed by the original hanja in parentheses: 한글(漢字). Corresponds to Rust RenderMode::HangulOnly."hangul-hanja-parens" — Always emit 한글(漢字). Corresponds to Rust RenderMode::HangulHanjaParens."hanja-hangul-parens" — Always emit 漢字(한글). Useful for academic and historical-document styles. Corresponds to Rust RenderMode::HanjaHangulParens."ruby-on-hangul" — Emit 한글漢字. Falls back to parentheses when the current scope does not permit inline markup (e.g., inside
).  Corresponds to Rust RenderMode::Ruby(RubyBase::OnHangul)."ruby-on-hanja" — Emit 漢字한글. Corresponds to Rust RenderMode::Ruby(RubyBase::OnHanja)."original" — Keep the original mixed-script form; only annotations with require_hangul or a user directive receive a hangul gloss, which appears either in parentheses or as a ruby element depending on GukhanmunOptions.originalGloss.  Corresponds to Rust RenderMode::Original.
- [Type Alias: Segmentation](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.Segmentation.md): Segmentation = "lattice" | "eager" Controls how the engine segments a hanja-containing span into dictionary words and fallback fragments.  Corresponds to Rust SegmentationStrategy. "lattice" — Dynamic programming over all possible dictionary matches at each position; selects the segmentation that maximises dictionary coverage and then prefers fewer segments.  This is the default and produces better results than greedy approaches when a longer prefix would leave a suffix uncovered by the dictionary.  Corresponds to Rust SegmentationStrategy::Lattice."eager" — Left-to-right longest-match (greedy).  Lower overhead per span at the cost of occasional mis-segmentation.  Corresponds to Rust SegmentationStrategy::Eager.
- [Type Alias: SourcePolicy](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.SourcePolicy.md): SourcePolicy = "reference-authorized" | "reference-first" | "loanword-first" | "ordered" Cooperation between reference dictionaries and independent loanword sources. "reference-authorized" uses typed reference evidence to authorize alternate forms. "reference-first" and "loanword-first" select an explicit preference; "ordered" restores the original array-order behavior and ignores roles and GukhanmunOptions.referenceOnly. Authored overrides remain exclusive under every cooperative policy.
- [Type Alias: SourceRole](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.SourceRole.md): SourceRole = "override" | "reference" | "loanword" A source's role, independent of preference among its own readings.
- [Type Alias: SpaceAfter](https://canary.gukhanmun.org/api/js/types/_gukhanmun_types.SpaceAfter.md): SpaceAfter = "preserve" | "remove" | "single" Policy for ordinary spaces following an eligible stop.
- [Variable: loanwordsCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_loanwords-cdb.loanwordsCdbUrl.md): const loanwordsCdbUrl: URL URL of the bundled NIKL loanword examples CDB binary.
- [Variable: loanwordsFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_loanwords-fst.loanwordsFstUrl.md): const loanwordsFstUrl: URL URL of the bundled NIKL loanword examples FST binary.
- [Variable: opendictArchaicCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-cdb.opendictArchaicCdbUrl.md): const opendictArchaicCdbUrl: URL URL of the bundled Open Korean Dictionary 옛말 CDB binary. Stored gzip-compressed; opendictCdbBytes inflates it transparently.
- [Variable: opendictDialectCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-cdb.opendictDialectCdbUrl.md): const opendictDialectCdbUrl: URL URL of the bundled Open Korean Dictionary 方言 CDB binary. Stored gzip-compressed; opendictCdbBytes inflates it transparently.
- [Variable: opendictGeneralCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-cdb.opendictGeneralCdbUrl.md): const opendictGeneralCdbUrl: URL URL of the bundled Open Korean Dictionary 一般語 CDB binary. The bundled artifact is stored gzip-compressed (hence the .cdb.gz extension) to stay within registry per-file size limits; opendictCdbBytes inflates it transparently.
- [Variable: opendictNorthKoreanCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-cdb.opendictNorthKoreanCdbUrl.md): const opendictNorthKoreanCdbUrl: URL URL of the bundled Open Korean Dictionary 北韓語 CDB binary. Stored gzip-compressed; opendictCdbBytes inflates it transparently.
- [Variable: opendictArchaicFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-fst.opendictArchaicFstUrl.md): const opendictArchaicFstUrl: URL URL of the bundled Open Korean Dictionary 옛말 FST binary.
- [Variable: opendictDialectFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-fst.opendictDialectFstUrl.md): const opendictDialectFstUrl: URL URL of the bundled Open Korean Dictionary 방언 FST binary.
- [Variable: opendictGeneralFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-fst.opendictGeneralFstUrl.md): const opendictGeneralFstUrl: URL URL of the bundled Open Korean Dictionary 일반어 FST binary.
- [Variable: opendictNorthKoreanFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_opendict-fst.opendictNorthKoreanFstUrl.md): const opendictNorthKoreanFstUrl: URL URL of the bundled Open Korean Dictionary 북한어 FST binary.
- [Variable: stdictCdbUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_stdict-cdb.stdictCdbUrl.md): const stdictCdbUrl: URL URL of the bundled, gzip-compressed Standard Korean Language Dictionary CDB. The URL now points to stdict.cdb.gz to fit registry per-file limits. stdictCdbBytes transparently returns the decompressed CDB bytes. The npm package also retains its raw stdict.cdb file export.
- [Variable: stdictFstUrl](https://canary.gukhanmun.org/api/js/variables/_gukhanmun_stdict-fst.stdictFstUrl.md): const stdictFstUrl: URL URL of the bundled Standard Korean Language Dictionary FST binary.
- [Python API](https://canary.gukhanmun.org/api/python.md): Reference for Gukhanmun Python converters, immutable options, dictionary sources, punctuation profiles, streams and coded errors.

## Internals

- [Design](https://canary.gukhanmun.org/internals/design.md): Gukhanmun is a library for converting Korean text written in mixed script (國漢文混用體) into hangul-only text. It is the successor to Seonbi, narrowed in scope to the hanja conversion pipeline and broadened along several axes: streaming I/O, pluggable dictionaries, lattice-based segmentation, and a wider range of output formats. The project is implemented in Rust and exposed as a Rust library, a command-line tool, WebAssembly bindings, Node-API bindings, and Python bindings.
- [Dictionary format](https://canary.gukhanmun.org/internals/dictionary-format.md): This document specifies the normalized dictionary input formats consumed by gukhanmun-mkdict and the FST/CDB dictionary file layouts produced from those inputs. It is the boundary between dictionary extractors, user-maintained glossaries, and backend builders.
- [Standard Korean Language Dictionary](https://canary.gukhanmun.org/internals/stdict.md): gukhanmun-stdict bundles a snapshot derived from the National Institute of Korean Language's Standard Korean Language Dictionary (標準國語大辭典) JSON download. The source dump is not committed to this repository.  The download requires a login on the dictionary website, and the archive is much larger than the normalized data used by the build.  The committed source of truth is instead the canonical TSV file at crates/gukhanmun-stdict/data/stdict.tsv.
- [Open Korean Dictionary](https://canary.gukhanmun.org/internals/opendict.md): Provenance, extraction policy, and runtime use for bundled Open Korean Dictionary snapshots.

## Sponsorship

- [Sponsorship](https://canary.gukhanmun.org/sponsorship.md): Support Gukhanmun through GitHub Sponsors or Open Collective, and meet the organizations helping sustain the project.