Architecture overview
The parser has three main components:- Remark processor — Parses and serializes Markdown
- ParserState — Converts MDAST to ProseMirror
- SerializerState — Converts ProseMirror to MDAST
Markdown extension
The core Markdown extension is defined inextensions/markdown/index.ts:
Unified processor
The processor uses these Remark plugins:- remark-parse — Parses Markdown to MDAST
- remark-stringify — Serializes MDAST to Markdown
- remark-gfm — GitHub Flavored Markdown (tables, task lists, strikethrough)
- remark-directive — Custom directives for Mermaid, PlantUML, etc.
Parser state
TheParserState class converts MDAST (Markdown Abstract Syntax Tree) to ProseMirror nodes:
Node matching
Each TipTap extension can register a parser:Stack-based parsing
The parser uses a stack to build the document:Serializer state
TheSerializerState class converts ProseMirror nodes to MDAST:
Node serialization
Extensions register serializers:Custom directives
Fylepad usesremark-directive for custom content:
Mermaid diagrams
PlantUML diagrams
GitHub Flavored Markdown
Theremark-gfm plugin adds:
Tables
Task lists
Strikethrough
Autolinks
Usage in the app
Import Markdown
Export Markdown
Auto-save
Markdown is also used for persistence:Extension hooks
Extensions can modify the processor:Next steps
Custom nodes
Learn about custom node implementations
TipTap extensions
Overview of TipTap extensions