# shiphan/markdown-renderer architecture

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

- Interactive diagram: https://gitdiagram.com/shiphan/markdown-renderer
- Repository: https://github.com/shiphan/markdown-renderer

## Overview

Markdown Renderer is a desktop Markdown editor with a live preview. A user edits text, the application parses it into a document of blocks and spans, then renders that document into a Swing text pane. The README lists headings, paragraphs, emphasis, code, quotes, lists, breaks, images, rules, and links; sampled parser code confirms several core constructs, while link and image parsing is not evidenced in the excerpts. Rendering paths for image and link spans are represented as separate syntax components, not as external services.

Main entry points: [`src/parser/Parser.java`](https://github.com/shiphan/markdown-renderer/blob/main/src/parser/Parser.java) (Markdown parser), [`src/markdownDocument/block/Paragraph.java`](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Paragraph.java) (Paragraph), [`src/markdownDocument/MarkdownDocument.java`](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/MarkdownDocument.java) (Markdown document), [`src/App.java`](https://github.com/shiphan/markdown-renderer/blob/main/src/App.java) (App coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Editor and preview"]
  node_editor["Text editor<br/>[App.java]"]
  node_app["App coordinator<br/>[App.java]"]
end

subgraph group_parse["Markdown parsing"]
  node_parser["Markdown parser<br/>[Parser.java]"]
end

subgraph group_document["Document rendering"]
  node_document["Markdown document"]
end

subgraph group_syntax["Markdown components"]
  node_heading["Heading<br/>[Heading.java]"]
  node_paragraph["Paragraph<br/>[Paragraph.java]"]
  node_quote["Quote<br/>[Quote.java]"]
  node_horizontal["Horizontal rule"]
  node_list["List and items<br/>[List.java]"]
  node_text["Styled and code text<br/>[Text.java]"]
  node_linebreak["Line break<br/>[LineBreak.java]"]
  node_link["Link span<br/>[Link.java]"]
  node_image["Image span<br/>[Image.java]"]
end

node_user(("User"))

node_user -->|"edits text"| node_editor
node_editor -->|"notifies changes"| node_app
node_app -->|"parses input"| node_parser
node_parser -->|"builds document"| node_document
node_parser -->|"creates headings"| node_heading
node_parser -->|"creates paragraphs"| node_paragraph
node_parser -->|"creates quotes"| node_quote
node_parser -->|"creates rules"| node_horizontal
node_parser -->|"creates lists"| node_list
node_parser -->|"creates text spans"| node_text
node_parser -->|"creates breaks"| node_linebreak
node_app -->|"renders preview"| node_document
node_document -->|"renders blocks"| node_heading
node_document -->|"renders blocks"| node_paragraph
node_document -->|"renders blocks"| node_quote
node_document -->|"renders blocks"| node_horizontal
node_paragraph -->|"renders spans"| node_text
node_paragraph -->|"renders spans"| node_linebreak
node_paragraph -->|"renders spans"| node_list
node_quote -->|"renders contents"| node_paragraph
node_list -->|"renders item content"| node_paragraph

click node_editor "https://github.com/shiphan/markdown-renderer/blob/main/src/App.java"
click node_app "https://github.com/shiphan/markdown-renderer/blob/main/src/App.java"
click node_parser "https://github.com/shiphan/markdown-renderer/blob/main/src/parser/Parser.java"
click node_document "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/MarkdownDocument.java"
click node_heading "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Heading.java"
click node_paragraph "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Paragraph.java"
click node_quote "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Quote.java"
click node_horizontal "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/HorizontalRule.java"
click node_list "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/List.java"
click node_text "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Text.java"
click node_linebreak "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/LineBreak.java"
click node_link "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Link.java"
click node_image "https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Image.java"

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_editor,node_app,node_user toneBlue
class node_parser toneAmber
class node_document toneMint
class node_heading,node_paragraph,node_quote,node_horizontal,node_list,node_text,node_linebreak,node_link,node_image toneRose
```

## Components

### Editor and preview

- [Text editor](https://github.com/shiphan/markdown-renderer/blob/main/src/App.java): `src/App.java`
- [App coordinator](https://github.com/shiphan/markdown-renderer/blob/main/src/App.java): `src/App.java`

### Markdown parsing

- [Markdown parser](https://github.com/shiphan/markdown-renderer/blob/main/src/parser/Parser.java): `src/parser/Parser.java`

### Document rendering

- [Markdown document](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/MarkdownDocument.java): `src/markdownDocument/MarkdownDocument.java`

### Markdown components

- [Heading](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Heading.java): `src/markdownDocument/block/Heading.java`
- [Paragraph](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Paragraph.java): `src/markdownDocument/block/Paragraph.java`
- [Quote](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/Quote.java): `src/markdownDocument/block/Quote.java`
- [Horizontal rule](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/block/HorizontalRule.java): `src/markdownDocument/block/HorizontalRule.java`
- [List and items](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/List.java): `src/markdownDocument/span/List.java`
- [Styled and code text](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Text.java): `src/markdownDocument/span/Text.java`
- [Line break](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/LineBreak.java): `src/markdownDocument/span/LineBreak.java`
- [Link span](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Link.java): `src/markdownDocument/span/Link.java`
- [Image span](https://github.com/shiphan/markdown-renderer/blob/main/src/markdownDocument/span/Image.java): `src/markdownDocument/span/Image.java`

### Other components

- **User**

## Connections

- User → Text editor: edits text
- Text editor → App coordinator: notifies changes
- App coordinator → Markdown parser: parses input
- Markdown parser → Markdown document: builds document
- Markdown parser → Heading: creates headings
- Markdown parser → Paragraph: creates paragraphs
- Markdown parser → Quote: creates quotes
- Markdown parser → Horizontal rule: creates rules
- Markdown parser → List and items: creates lists
- Markdown parser → Styled and code text: creates text spans
- Markdown parser → Line break: creates breaks
- App coordinator → Markdown document: renders preview
- Markdown document → Heading: renders blocks
- Markdown document → Paragraph: renders blocks
- Markdown document → Quote: renders blocks
- Markdown document → Horizontal rule: renders blocks
- Paragraph → Styled and code text: renders spans
- Paragraph → Line break: renders spans
- Paragraph → List and items: renders spans
- Quote → Paragraph: renders contents
- List and items → Paragraph: renders item content
