> For AI agents: the complete documentation index is available at https://canary.gukhanmun.org/ko-KR/llms.txt, the full documentation bundle is available at https://canary.gukhanmun.org/ko-KR/llms-full.txt.

# 빠른 시작

모든 Gukhanmun 구현은 단일 비동기 팩토리 함수 `load`를 내보냅니다.  한 번
호출한 뒤, 반환된 `Gukhanmun` 인스턴스를 모든 변환에 사용합니다.

## 최소 예시

```ts twoslash
import { load } from "@gukhanmun/wasm";
import { stdictFst } from "@gukhanmun/stdict-fst";

const g = await load({
  dictionaries: [await stdictFst()],
});

console.log(g.convert("漢字를 한글로"));
// → 한자를 한글로
```

## NAPI 백엔드로 바꾸기

API는 동일합니다; `import` 경로만 바뀝니다:

```ts twoslash
import { load } from "@gukhanmun/napi";
import { stdictFst } from "@gukhanmun/stdict-fst";

const g = await load({
  dictionaries: [await stdictFst()],
});
```

## `convert()` 메서드

`g.convert(source)`는 기본적으로 평문 텍스트를 변환합니다. 두 번째 인수로
미디어 타입을 넘겨 형식을 고를 수 있습니다:

```ts twoslash
import type { Gukhanmun } from "@gukhanmun/types";
const g: Gukhanmun = {} as unknown as Gukhanmun;
// ---cut-before---
g.convert("漢字를 한글로", "text/plain");         // 平文 텍스트 (基本)
g.convert("<p>漢字</p>", "text/html");           // HTML 조각(fragment)
g.convert("# 漢字", "text/markdown");            // CommonMark
g.convert("# 漢字", "text/markdown; variant=GFM"); // GFM
```

TypeScript 선언에서는 위 표기만 새 형식으로 받습니다. 실행 시에는 두 바인딩 모두
CLI와 같은 규칙으로 미디어 타입의 매개변수를 해석하므로
`text/markdown;variant=GFM`도 쓸 수 있습니다.

## 오류 처리

`load()`와 `convert()`는 실패 시 `GukhanmunError`를 던집니다:

```ts twoslash
import { load, GukhanmunError } from "@gukhanmun/wasm";
import { stdictFst } from "@gukhanmun/stdict-fst";

try {
  const g = await load({ dictionaries: [await stdictFst()] });
  g.convert("<invalid html>", "text/html");
} catch (e) {
  if (e instanceof GukhanmunError) {
    console.error(e.code, e.message);
  }
}
```
