#Markdown conversion
Pass "markdown" as the format to convert():
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 ()] });
const const output: string output = const g: Gukhanmun g .Gukhanmun.convert(source: string, format?: Format): stringConverts source to hangul in one shot. Buffers the entire input
before returning.
@paramsource - The text to convert.@paramformat - Input / output format. Defaults to "text".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure. convert ("# 漢字\n\n漢字를 한글로 변환합니다.", "markdown");
// → "# 한자\n\n한자를 한글로 변환합니다."#GitHub Flavored Markdown
Pass a format object with gfm: true to enable GFM extensions (tables, task
lists, strikethrough):
const const output: string output = const g: Gukhanmun g .Gukhanmun.convert(source: string, format?: Format): stringConverts source to hangul in one shot. Buffers the entire input
before returning.
@paramsource - The text to convert.@paramformat - Input / output format. Defaults to "text".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure. convert (
"| 漢字 | 讀音 |\n|------|------|\n| 東 | 동 |",
{ format: "markdown" format : "markdown", gfm?: boolean | undefined gfm : true },
);#What gets converted
Gukhanmun converts hanja inside paragraph text, headings, list items, blockquotes, and table cells.
The following are always left untouched:
- Fenced code blocks and indented code blocks
- Inline code spans (
`…`) - Raw HTML blocks and inline HTML
- Link and image URLs