Overview
The Markdown Decoder parses Markdown strings into AppFlowy EditorDocument objects. It uses the GitHub Flavored Markdown specification and supports custom inline syntaxes and element parsers.
DocumentMarkdownDecoder
The main class for decoding Markdown to document format.Constructor
Parameters
- markdownElementParsers (
List<CustomMarkdownParser>): Custom parsers for handling specific Markdown elements. Default is an empty list. - inlineSyntaxes (
List<md.InlineSyntax>): Custom inline syntax parsers (from themarkdownpackage). Default is an empty list.
Methods
convert
Document object.
Parameters:
input(String): The Markdown string to parse
Document - The parsed document
Example:
Helper Function
markdownToDocument
A convenient helper function that provides a simpler API with default parsers.markdown(String): The Markdown string to parsemarkdownParsers(List<CustomMarkdownParser>): Additional custom parsersinlineSyntaxes(List<md.InlineSyntax>): Additional inline syntax parsers
Document - The parsed document
Example:
Supported Markdown Syntax
The decoder supports GitHub Flavored Markdown including:Block Elements
- Headings:
# H1through###### H6 - Paragraphs: Regular text blocks
- Lists:
- Unordered:
*,-, or+ - Ordered:
1.,2., etc. - Nested lists with indentation
- Unordered:
- Todo Lists:
- [x](checked) or- [ ](unchecked) - Block Quotes:
> Quote text - Code Blocks: Fenced with triple backticks
- Tables: Pipe-separated tables with alignment
- Horizontal Rules:
---,***, or___ - Images:

Inline Elements
- Bold:
**text**or__text__ - Italic:
*text*or_text_ - Code:
`code` - Links:
[text](url) - Strikethrough:
~~text~~ - Underline: Custom syntax support
- Formulas: Custom inline math syntax
Example Usage
Basic Parsing
Nested Lists
Formatting Rules
The decoder applies special formatting rules to handle edge cases:Image Handling
-
Single newline before image: Automatically adds double newline
-
No newline before image: Adds double newline
Custom Parsers
Create custom parsers by implementingCustomMarkdownParser:
Custom Inline Syntax
Add custom inline syntax support:Built-in Extensions
The decoder includes built-in support for:- FormulaInlineSyntax: Parse mathematical formulas
- UnderlineInlineSyntax: Support underlined text
See Also
- Markdown Encoder - Convert documents to Markdown
- HTML Decoder - Parse HTML content