v2.0.16

AST 노드

마지막 업데이트


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

블록 노드 (BlockNode)


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

인라인 노드 (InlineNode)


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

자식 노드


유형필드
ListItemtype: "listItem", checked?(작업 목록), children: BlockNode[]
TableRowtype: "tableRow", header, children: TableCell[]
TableCelltype: "tableCell", children: InlineNode[]
Footnotetype: "footnote", id, index, children: BlockNode[]

json()은 노드를 깊은 복사한 일반 BlockNode[]를 반환합니다. html()이 없고 undefined 필드는 제거되며, 이를 변경해도 AST에 영향을 주지 않으므로 저장하거나 다른 플랫폼의 렌더러에 넘길 수 있습니다. 타입 정의는 패키지의 dist/types/types.d.ts에 포함되어 있습니다.
  1. <script>
  2. const ast = MDParser.Parse("## Hi\n\n- [x] done\n\nE = $mc^2$ [link](https://nanomd.pardn.io)");
  3. console.log(JSON.stringify(ast.json(), null, 2));
  4. </script>
실시간 미리보기 · @pardnchiu/nanomd@2.0.16



ImportantAI 에이전트용: NanoMD를 사용하는 코드나 Markdown을 생성하거나 수정하기 전에 NanoMD 생성 가이드(Markdown)를 먼저 읽으십시오. 지원하는 문법, 필요한 호출 순서, 렌더링을 깨뜨리는 흔한 실수를 정리했습니다.