> 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.

# Markdown 변환

`InputFormat.MARKDOWN`은 CommonMark를 읽고 HTML 대신 Markdown을 씁니다.

```python
from gukhanmun import Converter, DictionaryEntry, InputFormat, MapDictionarySource

converter = Converter(dictionaries=[MapDictionarySource([
    DictionaryEntry("漢字", "한자"),
])])
output = converter.convert("# 漢字\n\n漢字를 읽습니다.", format=InputFormat.MARKDOWN)
```

## GitHub Flavored Markdown

표·작업 목록·취소선 같은 GFM 확장을 사용하려면 `MarkdownOptions(gfm=True)`를
지정합니다. `MarkdownOptions()`는 `InputFormat.MARKDOWN`과 같습니다.

```python
from gukhanmun import MarkdownOptions

assert converter.convert("~~漢字~~", format=MarkdownOptions(gfm=True)) == "~~한자~~"
```

## 변환 범위와 보존 범위

단락·표제·목록 항목·인용문과 링크/이미지 표시 문구는 변환합니다. GFM을
켜면 표 셀(cell)도 변환합니다. 코드 블록(block), 인라인(inline) 코드,
링크/이미지의 목적지와 원시 HTML 블록은 보존합니다.

인라인 HTML 태그는 마크업으로 남습니다. 인라인 태그 사이의 텍스트는
변환 대상입니다. 둘러싼 `<code>` 같은 보존 태그나 계승한 비한국어 `lang`
속성은 변환을 막습니다. 원시 HTML 블록은 전체를 보존합니다.
완전한 HTML 조각(fragment)을 처리하려면
[HTML 모드](https://canary.gukhanmun.org/ko-KR/guide/python/html.md)를 사용합니다.

## 출력과 렌더링

Markdown 어댑터(adapter)는 문서를 해석하고 직렬화합니다. 문서 구조는
보존하지만 공백이나 목록 표지 같은 형식의 세부를 정규화할 수 있으므로, 바이트
단위의 왕복 일치를 보증하지는 않습니다. 텍스트가 Markdown 문법을 만들 수
있는 경우에는 필요에 따라 이스케이프(escape)합니다.

[루비(ruby) 렌더링](https://canary.gukhanmun.org/ko-KR/guide/python/rendering.md#%EB%A3%A8%EB%B9%84-%EB%A7%88%ED%81%AC%EC%97%85)은 스코프(scope)가 허용하는 곳에
인라인 HTML을 내보냅니다. 결과를 표시하는 애플리케이션이 그 HTML을 허용해야
루비 주해(annotation)가 보입니다. 목적지가 인라인 HTML을 제거한다면 괄호
렌더링 모드를 선택합니다.
