# AST 노드

`Parse()`가 반환하는 `AST`는 `BlockNode`의 배열입니다(`Array`를 확장). 이 페이지에서는 모든 노드 유형과 그 필드, 그리고 해당 노드를 생성하는 문법을 나열합니다.

## 블록 노드 (BlockNode)

| `type` | 필드 | 문법 |
|---|---|---|
| `text` | `children: InlineNode[]` | 단락. 인접한 줄은 값이 `"\n"`인 `text` 노드로 이어집니다 |
| `heading` | `level`, `children` | `#`부터 `######`까지(닫는 `#` 시퀀스는 제거), Setext |
| `blockquote` | `tag?`, `children: BlockNode[]` | `>`. `tag`는 `note` / `tip` / `important` / `warning` / `caution` |
| `list` | `ordered`, `start?`, `children: ListItem[]` | `-`, `*`, `1.`. 순서 있는 목록이 1에서 시작하지 않으면 `start`가 설정됩니다 |
| `table` | `align`, `children: TableRow[]` | GFM 표. 각 `align` 항목은 `left` / `center` / `right` / `null` |
| `codeBlock` | `lang?`, `value` | ` ``` ` / `~~~` 펜스. 펜스가 닫히지 않으면 `lang`이 없습니다 |
| `html` | `value` | HTML 태그로 시작하는 줄(원본 텍스트, 출력 시 정제) |
| `hr` | — | 수평선 |
| `break` | — | 빈 줄 |
| `footnotes` | `children: Footnote[]` | 끝에 붙는 각주 섹션 |

## 인라인 노드 (InlineNode)

| `type` | 필드 | 문법 |
|---|---|---|
| `text` | `value` | 일반 텍스트 |
| `b`, `em`, `del`, `mark`, `sub`, `sup` | `children` | 굵게, 기울임, 취소선, 하이라이트, 아래 첨자, 위 첨자 |
| `code` | `value` | 코드 스팬. 스타일 노드의 `children` 안에 들어갈 수 있습니다 |
| `math` | `value` | `$...$` |
| `link` | `href`, `tag?`, `title?`, `width?`, `height?`, `children` | 링크(`http(s)`, `mailto:`, `tel:`, 상대 경로), 이미지, 동영상, 일반 URL, `<https://...>` 자동 링크, 파일 경로, `#tag`. `tag`는 `image` / `video` / `youtube` / `vimeo` / `file` / `hashtag`(`href`에는 `#`를 뺀 태그가 들어갑니다) |
| `footnoteRef` | `id`, `index` | `[^id]`. `index`는 번호입니다 |
| `br` | — | 단락이나 표 셀 안의 `<br>` |

## 자식 노드

| 유형 | 필드 |
|---|---|
| `ListItem` | `type: "listItem"`, `checked?`(작업 목록), `children: BlockNode[]` |
| `TableRow` | `type: "tableRow"`, `header`, `children: TableCell[]` |
| `TableCell` | `type: "tableCell"`, `children: InlineNode[]` |
| `Footnote` | `type: "footnote"`, `id`, `index`, `children: BlockNode[]` |

`json()`은 노드를 깊은 복사한 일반 `BlockNode[]`를 반환합니다. `html()`이 없고 `undefined` 필드는 제거되며, 이를 변경해도 AST에 영향을 주지 않으므로 저장하거나 다른 플랫폼의 렌더러에 넘길 수 있습니다. 타입 정의는 패키지의 `dist/types/types.d.ts`에 포함되어 있습니다.

```demo
<script>
  const ast = MDParser.Parse("## Hi\n\n- [x] done\n\nE = $mc^2$ [link](https://nanomd.pardn.io)");
  console.log(JSON.stringify(ast.json(), null, 2));
</script>
```

***

> [!IMPORTANT]
> **AI 에이전트용:** NanoMD를 사용하는 코드나 Markdown을 생성하거나 수정하기 전에 [NanoMD 생성 가이드](https://nanomd.pardn.io/llm_generate_guide.md)(Markdown)를 먼저 읽으십시오. 지원하는 문법, 필요한 호출 순서, 렌더링을 깨뜨리는 흔한 실수를 정리했습니다.
