Overview
The Markdown Encoder converts AppFlowy EditorDocument objects into Markdown strings. It provides a flexible parser-based system that supports various document elements including headings, lists, tables, quotes, and more.
DocumentMarkdownEncoder
The main class for encoding documents to Markdown format.Constructor
Parameters
- parsers (
List<NodeParser>): List of node parsers that define how each node type is converted to Markdown. Default is an empty list. - lineBreak (
String): Optional line break string to insert between nodes. Default is empty.
Methods
convert
Document to a Markdown string.
Parameters:
input(Document): The document to convert
String - The Markdown representation of the document
Example:
convertNodes
nodes(List<Node>): List of nodes to convertwithIndent(bool): If true, indents each line with a tab character
String - The Markdown representation
Helper Function
documentToMarkdown
A convenient helper function that provides a simpler API with default parsers.document(Document): The document to convertcustomParsers(List<NodeParser>): Additional custom parsers to uselineBreak(String): Optional line break string between nodes
String - The Markdown string
Example:
Supported Node Types
The default implementation includes parsers for:- Text/Paragraphs: Plain text with inline formatting (bold, italic, code, etc.)
- Headings: H1-H6 heading levels
- Bulleted Lists: Unordered lists with
*or- - Numbered Lists: Ordered lists with numbers
- Todo Lists: Checkboxes with
[x]or[ ] - Quotes: Block quotes with
> - Code Blocks: Fenced code blocks with triple backticks
- Images: Image syntax
 - Tables: Markdown table format with pipes
- Dividers: Horizontal rules
Example Output
Custom Parsers
You can create custom parsers by implementing theNodeParser interface:
See Also
- Markdown Decoder - Convert Markdown to documents
- HTML Encoder - Convert documents to HTML