markdown library
This library contains the grammar, AST parser, HTML renderer, and syntax highlighter for Markdown.
Supports CommonMark 0.31.2 standards with GitHub Flavored Markdown (GFM) extensions (tables, strikethrough, task lists).
For example:
final doc = parseMarkdown('# Hello\n\nThis is **bold** text.');
print(doc.blocks.first);
final html = markdownToHtml('# Hello\n\nThis is **bold** text.');
print(html);
final highlighted = highlightMarkdown('# Hello');
print(highlighted);
Classes
- AutolinkNode
-
An automatic link (
<https://example.com>or<user@domain.com>). - BlockNode
- Base class for all block-level Markdown elements.
- BlockquoteNode
-
A blockquote (
>) containing nested block-level children. - BulletListNode
-
An unordered bullet list (
-,*,+). - CodeSpanNode
-
Inline code span (
`code`). - CompositeInlineNode
- A composite sequence of consecutive children inline nodes.
- DocumentNode
- The root node of a Markdown document containing top-level blocks.
- EmphasisNode
-
Emphasis (
*text*or_text_). - FencedCodeBlockNode
- A code block delimited by fences (``` or ~~~), with optional language info.
- HeadingNode
- An ATX or Setext heading with a level (1-6) and content.
- HighlightSpan
- Represents a highlighted text range with an associated CSS class.
- HtmlBlockNode
- Raw block-level HTML.
- ImageNode
-
An embedded image (
). - IndentedCodeBlockNode
- A code block indented by 4 spaces or 1 tab.
- InlineNode
- Base class for all inline Markdown elements.
- LineBreakNode
-
A line break, either a hard break (
<br />) or soft break (\n). - LinkNode
-
A hyperlink (
[text](url "title")). - LinkReferenceDefinitionNode
-
A link reference definition block (
[label]: url "title"). - ListItemNode
- An individual item inside an ordered or bullet list.
- MarkdownGrammarDefinition
- Complete grammar and parser definition for Markdown.
- MarkdownHighlighter
- A syntax highlighter for Markdown source code that uses AST position tokens.
- MarkdownHtmlRenderer
- Renders a MarkdownNode tree into an HTML string.
- MarkdownNode
- Base class for all Abstract Syntax Tree (AST) nodes in Markdown.
-
MarkdownVisitor<
R> - Visitor interface for traversing MarkdownNode trees.
- OrderedListNode
-
An ordered enumerated list (
1.,2.). - ParagraphNode
- A standard text paragraph block containing inline content.
- RawHtmlInlineNode
-
Raw inline HTML element (
<span>,<code>, etc.). - StrikethroughNode
-
GFM strikethrough (
~~text~~). - StrongNode
-
Strong emphasis (
**text**or__text__). - TableCellNode
- An individual cell inside a TableRowNode.
- TableNode
- A GFM table with rows and column alignments.
- TableRowNode
- A row inside a TableNode.
- TextNode
- Plain literal text.
- ThematicBreakNode
-
A horizontal rule / thematic break (
---,***,___).
Enums
- TableAlignment
- Column text alignment in a Markdown table.
Functions
-
highlightMarkdown(
String input) → String -
Highlights
inputMarkdown source code with HTML syntax spans using PetitParser. -
markdownToHtml(
String input) → String -
Parses
inputMarkdown and renders it to an HTML string. -
parseMarkdown(
String input) → DocumentNode -
Parses the
inputMarkdown text into a strongly typed DocumentNode.