# yuin/goldmark architecture

> Architecture diagram of the GitHub repository yuin/goldmark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuin/goldmark
- Repository: https://github.com/yuin/goldmark

## Overview

goldmark is a Go Markdown processing library: callers provide Markdown, the parser builds a source-aware AST, and a separate renderer produces HTML (or another format). Its AST also supports programmatic construction and semantic analysis. Built-in and custom extensions add syntax and rendering, including GFM-style tables, task lists, footnotes, and typographic transformations. The README documents the main parse/render workflow; some internal connections and unsampled extension implementations are therefore shown only where documented or excerpted.

Main entry points: [`parser/parser.go`](https://github.com/yuin/goldmark/blob/v2/parser/parser.go) (Markdown parser), [`extension/table.go`](https://github.com/yuin/goldmark/blob/v2/extension/table.go) (Table extension), [`ast/ast.go`](https://github.com/yuin/goldmark/blob/v2/ast/ast.go) (AST node model), [`renderer/renderer.go`](https://github.com/yuin/goldmark/blob/v2/renderer/renderer.go) (Renderer framework)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_parse["Parsing"]
  node_parser["Markdown parser<br/>[parser.go]"]
  node_paragraphs["Paragraph parser<br/>[paragraph.go]"]
  node_links["Link and delimiter parsing<br/>[link.go]"]
  node_htmlblocks["HTML block parsing<br/>[html_block.go]"]
end

subgraph group_model["AST and source"]
  node_astcore["AST node model<br/>[ast.go]"]
  node_blocknodes["Block nodes<br/>[block.go]"]
  node_inlinenodes["Inline nodes<br/>[inline.go]"]
  node_sourcevalues["Source values<br/>[value.go]"]
  node_reader["Text reader<br/>[reader.go]"]
  node_decoder["Text decoder<br/>[decoder.go]"]
end

subgraph group_render["Rendering"]
  node_renderer["Renderer framework<br/>[renderer.go]"]
  node_html["HTML renderer<br/>[html.go]"]
end

subgraph group_extensions["Extensions"]
  node_tableext["Table extension<br/>[table.go]"]
  node_tableast["Table AST nodes<br/>[table.go]"]
  node_footnotes["Footnote extension<br/>[footnote.go]"]
  node_definitions["Definition lists<br/>[definition_list.go]"]
  node_typographer["Typographer<br/>[typographer.go]"]
  node_gfm["GFM bundle<br/>[gfm.go]"]
  node_strikethrough["Strikethrough<br/>[strikethrough.go]"]
  node_tasklist["Task lists<br/>[tasklist.go]"]
  node_linkify["Linkify<br/>[linkify.go]"]
end

node_caller(("Application"))

node_caller -->|"parses Markdown"| node_parser
node_parser -->|"builds AST"| node_astcore
node_parser -->|"reads source"| node_reader
node_paragraphs -->|"creates paragraphs"| node_blocknodes
node_links -.->|"parses inline nodes"| node_inlinenodes
node_htmlblocks -.->|"creates HTML blocks"| node_blocknodes
node_astcore -->|"retains source values"| node_sourcevalues
node_sourcevalues -->|"decodes values"| node_decoder
node_caller -->|"renders AST"| node_renderer
node_renderer -->|"walks AST"| node_astcore
node_html -->|"configures rendering"| node_renderer
node_caller -->|"selects HTML output"| node_html
node_tableext -->|"creates table nodes"| node_tableast
node_tableext -->|"transforms paragraphs"| node_blocknodes
node_caller -->|"enables extensions"| node_tableext
node_caller -->|"enables extensions"| node_footnotes
node_caller -->|"enables extensions"| node_definitions
node_caller -->|"enables extensions"| node_typographer
node_caller -->|"enables extensions"| node_gfm
node_caller -->|"enables extensions"| node_strikethrough
node_caller -->|"enables extensions"| node_tasklist
node_caller -.->|"enables extensions"| node_linkify

click node_parser "https://github.com/yuin/goldmark/blob/v2/parser/parser.go"
click node_paragraphs "https://github.com/yuin/goldmark/blob/v2/parser/paragraph.go"
click node_links "https://github.com/yuin/goldmark/blob/v2/parser/link.go"
click node_htmlblocks "https://github.com/yuin/goldmark/blob/v2/parser/html_block.go"
click node_astcore "https://github.com/yuin/goldmark/blob/v2/ast/ast.go"
click node_blocknodes "https://github.com/yuin/goldmark/blob/v2/ast/block.go"
click node_inlinenodes "https://github.com/yuin/goldmark/blob/v2/ast/inline.go"
click node_sourcevalues "https://github.com/yuin/goldmark/blob/v2/text/value.go"
click node_reader "https://github.com/yuin/goldmark/blob/v2/text/reader.go"
click node_decoder "https://github.com/yuin/goldmark/blob/v2/text/decoder.go"
click node_renderer "https://github.com/yuin/goldmark/blob/v2/renderer/renderer.go"
click node_html "https://github.com/yuin/goldmark/blob/v2/renderer/html/html.go"
click node_tableext "https://github.com/yuin/goldmark/blob/v2/extension/table.go"
click node_tableast "https://github.com/yuin/goldmark/blob/v2/extension/ast/table.go"
click node_footnotes "https://github.com/yuin/goldmark/blob/v2/extension/footnote.go"
click node_definitions "https://github.com/yuin/goldmark/blob/v2/extension/definition_list.go"
click node_typographer "https://github.com/yuin/goldmark/blob/v2/extension/typographer.go"
click node_gfm "https://github.com/yuin/goldmark/blob/v2/extension/gfm.go"
click node_strikethrough "https://github.com/yuin/goldmark/blob/v2/extension/strikethrough.go"
click node_tasklist "https://github.com/yuin/goldmark/blob/v2/extension/tasklist.go"
click node_linkify "https://github.com/yuin/goldmark/blob/v2/extension/linkify.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parser,node_paragraphs,node_links,node_htmlblocks toneBlue
class node_astcore,node_blocknodes,node_inlinenodes,node_sourcevalues,node_reader,node_decoder toneAmber
class node_renderer,node_html toneMint
class node_tableext,node_tableast,node_footnotes,node_definitions,node_typographer,node_gfm,node_strikethrough,node_tasklist,node_linkify toneRose
class node_caller toneIndigo
```

## Components

### Parsing

- [Markdown parser](https://github.com/yuin/goldmark/blob/v2/parser/parser.go): `parser/parser.go`
- [Paragraph parser](https://github.com/yuin/goldmark/blob/v2/parser/paragraph.go): `parser/paragraph.go`
- [Link and delimiter parsing](https://github.com/yuin/goldmark/blob/v2/parser/link.go): `parser/link.go`
- [HTML block parsing](https://github.com/yuin/goldmark/blob/v2/parser/html_block.go): `parser/html_block.go`

### AST and source

- [AST node model](https://github.com/yuin/goldmark/blob/v2/ast/ast.go): `ast/ast.go`
- [Block nodes](https://github.com/yuin/goldmark/blob/v2/ast/block.go): `ast/block.go`
- [Inline nodes](https://github.com/yuin/goldmark/blob/v2/ast/inline.go): `ast/inline.go`
- [Source values](https://github.com/yuin/goldmark/blob/v2/text/value.go): `text/value.go`
- [Text reader](https://github.com/yuin/goldmark/blob/v2/text/reader.go): `text/reader.go`
- [Text decoder](https://github.com/yuin/goldmark/blob/v2/text/decoder.go): `text/decoder.go`

### Rendering

- [Renderer framework](https://github.com/yuin/goldmark/blob/v2/renderer/renderer.go): `renderer/renderer.go`
- [HTML renderer](https://github.com/yuin/goldmark/blob/v2/renderer/html/html.go): `renderer/html/html.go`

### Extensions

- [Table extension](https://github.com/yuin/goldmark/blob/v2/extension/table.go): `extension/table.go`
- [Table AST nodes](https://github.com/yuin/goldmark/blob/v2/extension/ast/table.go): `extension/ast/table.go`
- [Footnote extension](https://github.com/yuin/goldmark/blob/v2/extension/footnote.go): `extension/footnote.go`
- [Definition lists](https://github.com/yuin/goldmark/blob/v2/extension/definition_list.go): `extension/definition_list.go`
- [Typographer](https://github.com/yuin/goldmark/blob/v2/extension/typographer.go): `extension/typographer.go`
- [GFM bundle](https://github.com/yuin/goldmark/blob/v2/extension/gfm.go): `extension/gfm.go`
- [Strikethrough](https://github.com/yuin/goldmark/blob/v2/extension/strikethrough.go): `extension/strikethrough.go`
- [Task lists](https://github.com/yuin/goldmark/blob/v2/extension/tasklist.go): `extension/tasklist.go`
- [Linkify](https://github.com/yuin/goldmark/blob/v2/extension/linkify.go): `extension/linkify.go`

### Other components

- **Application**

## Connections

- Application → Markdown parser: parses Markdown (evidence: `README.md`)
- Markdown parser → AST node model: builds AST (evidence: `README.md`)
- Markdown parser → Text reader: reads source
- Paragraph parser → Block nodes: creates paragraphs (evidence: `parser/paragraph.go`)
- Link and delimiter parsing → Inline nodes: parses inline nodes
- HTML block parsing → Block nodes: creates HTML blocks
- AST node model → Source values: retains source values (evidence: `ast/ast.go`)
- Source values → Text decoder: decodes values (evidence: `text/value.go`)
- Application → Renderer framework: renders AST (evidence: `README.md`)
- Renderer framework → AST node model: walks AST (evidence: `renderer/renderer.go`)
- HTML renderer → Renderer framework: configures rendering (evidence: `renderer/html/html.go`)
- Application → HTML renderer: selects HTML output (evidence: `README.md`)
- Table extension → Table AST nodes: creates table nodes (evidence: `extension/table.go`)
- Table extension → Block nodes: transforms paragraphs (evidence: `extension/table.go`)
- Application → Table extension: enables extensions (evidence: `README.md`)
- Application → Footnote extension: enables extensions (evidence: `README.md`)
- Application → Definition lists: enables extensions (evidence: `README.md`)
- Application → Typographer: enables extensions (evidence: `README.md`)
- Application → GFM bundle: enables extensions (evidence: `README.md`)
- Application → Strikethrough: enables extensions (evidence: `README.md`)
- Application → Task lists: enables extensions (evidence: `README.md`)
- Application → Linkify: enables extensions
