This page is a practical reference for the public classes, builders, enums, and extension points that most application code uses.
It is organized by area:
ParserParser is the main entry point for turning Markdown text into an AST.
Core usage:
Parser parser = Parser.builder().build();
Node document = parser.parse("Hello **world**");
Key ideas:
StringNode treeparse call uses fresh internal parser stateUse Parser when you need:
Parser.BuilderThe builder is where you configure parsing behavior.
Important methods:
extensions(Iterable<? extends Extension>)withExtension(Extension)withExtensions(Extension...)enabledBlockTypes(Set<Class<? extends Block>>)includeSourceSpans(IncludeSourceSpans)maxOpenBlockParsers(int)customBlockParserFactory(BlockParserFactory)customInlineContentParserFactory(InlineContentParserFactory)customDelimiterProcessor(DelimiterProcessor)linkProcessor(LinkProcessor)linkMarker(Character)postProcessor(PostProcessor)inlineParserFactory(InlineParserFactory)Parse only selected core block types:
Parser parser = Parser.builder()
.enabledBlockTypes(Set.of(Heading.class, ListBlock.class))
.build();
Collect source spans:
Parser parser = Parser.builder()
.includeSourceSpans(IncludeSourceSpans.BLOCKS_AND_INLINES)
.build();
Register custom syntax:
Parser parser = Parser.builder()
.customBlockParserFactory(new MyBlockParserFactory())
.customInlineContentParserFactory(new MyInlineParserFactory())
.customDelimiterProcessor(new MyDelimiterProcessor())
.linkProcessor(new MyLinkProcessor())
.postProcessor(new MyPostProcessor())
.build();
Parser.ParserExtensionThis is the parser-side extension contract.
An implementation can register:
This is the hook used by bundled extensions such as autolink, strikethrough, tables, and task lists.
NodeNode is the base type for all AST nodes.
Common responsibilities:
Block and inline nodesBlock nodes include:
DocumentParagraphHeadingListBlockListItemBlockQuoteFencedCodeBlockIndentedCodeBlockHtmlBlockThematicBreakInline nodes include:
TextCodeLinkImageEmphasisStrongEmphasisHtmlInlineSoftLineBreakHardLineBreakSourceSpan and SourceSpansThese types track origin information from the source text.
Use them when you need:
Visitor and AbstractVisitorThe visitor API is the standard way to walk a tree without writing long instanceof chains.
Typical pattern:
class TitlesOnlyVisitor extends AbstractVisitor {
@Override
public void visit(Heading heading) {
System.out.println(heading.getLevel());
}
}
NodesNodes provides utility iteration helpers for working with sibling ranges.
DefinitionMapDefinitionMap stores reference definitions keyed by normalized labels.
It is used internally by the parser, but it is still useful to understand because it explains how reference definitions are collected and reused.
These are the public interfaces and support types that extensions and advanced integrations use when they need to plug into the engine more deeply.
ExtensionRendererNodeRendererUse these as the root types for extension and rendering participation.
InlineParserFactoryInlineParserInlineParserContextPostProcessorBlockParserFactoryBlockParserParserStateInlineContentParserFactoryInlineContentParserInlineParserStateDelimiterProcessorDelimiterRunLinkProcessorLinkInfoLinkResultParsedInlinePositionScannerThese types matter when you are building custom syntax support.
HtmlNodeRendererContextHtmlNodeRendererFactoryAttributeProviderAttributeProviderFactoryAttributeProviderContextElementNodeRendererContextElementNodeRendererFactoryElementAttributeProviderElementAttributeProviderFactoryElementAttributeProviderContextTextContentNodeRendererContextTextContentNodeRendererFactoryMarkdownNodeRendererContextMarkdownNodeRendererFactoryRawHtmlHandlerUrlSanitizerThese types matter when you are customizing output behavior.
DefaultUrlSanitizerIncludeSourceSpansLineBreakRenderingSoftBreakRenderingAutolinkTypeTextContentWriterHtmlWriterMarkdownWriterThese classes are part of the public surface and are useful when wiring advanced application behavior.
HtmlRendererHtmlRenderer renders AST nodes to HTML strings or appendables.
Main methods:
builder()render(Node, Appendable)render(Node)Builder options:
softbreak(String)escapeHtml(boolean)sanitizeUrls(boolean)urlSanitizer(UrlSanitizer)percentEncodeUrls(boolean)omitSingleParagraphP(boolean)attributeProviderFactory(AttributeProviderFactory)nodeRendererFactory(HtmlNodeRendererFactory)extensions(Iterable<? extends Extension>)withExtension(Extension)withExtensions(Extension...)Example:
HtmlRenderer renderer = HtmlRenderer.builder()
.softbreak("<br>")
.sanitizeUrls(true)
.percentEncodeUrls(true)
.build();
HtmlRenderer.HtmlRendererExtensionUse this when an extension needs to register HTML renderer behavior.
AttributeProviderAttributeProviderFactoryAttributeProviderContextUse these when you want to add or override HTML attributes.
UrlSanitizerDefaultUrlSanitizerUse these when you want to control what destination URLs are allowed in HTML output.
HtmlNodeRendererContextHtmlNodeRendererFactoryNodeRendererCoreHtmlNodeRendererThese are the extension points for changing how specific node types render.
MarkdownClassExtensionDuiClassExtensionUse these when you want to attach deterministic CSS classes to rendered HTML elements based on both the Markdown node type and the emitted tag name.
Elemental2RendererElemental2Renderer renders to a detached DocumentFragment.
Main methods:
builder()render(Node)Builder options:
softBreakRendering(SoftBreakRendering)sanitizeUrls(boolean)urlSanitizer(UrlSanitizer)percentEncodeUrls(boolean)omitSingleParagraphP(boolean)rawHtmlHandler(RawHtmlHandler)attributeProviderFactory(ElementAttributeProviderFactory)nodeRendererFactory(ElementNodeRendererFactory)extensions(Iterable<? extends Extension>)withExtension(Extension)withExtensions(Extension...)Example:
Elemental2Renderer renderer = Elemental2Renderer.builder()
.softBreakRendering(SoftBreakRendering.BR_ELEMENT)
.sanitizeUrls(true)
.build();
Elemental2Renderer.Elemental2RendererExtensionThis is the extension contract for DOM rendering.
ElementAttributeProviderElementAttributeProviderFactoryElementAttributeProviderContextRawHtmlHandlerUse this when you want to turn raw HTML literals into custom DOM nodes.
ElementNodeRendererContextElementNodeRendererFactoryElementNodeRendererCoreElementNodeRendererMarkdownClassExtensionDuiClassExtensionUse these when you want the same class strategy to apply to detached Elemental2 DOM output.
TextContentRendererTextContentRenderer renders readable plain text.
Main methods:
builder()render(Node, Appendable)render(Node)Builder options:
lineBreakRendering(LineBreakRendering)stripNewlines(boolean) for compatibilitynodeRendererFactory(TextContentNodeRendererFactory)extensions(Iterable<? extends Extension>)withExtension(Extension)withExtensions(Extension...)Example:
TextContentRenderer renderer = TextContentRenderer.builder()
.lineBreakRendering(LineBreakRendering.SEPARATE_BLOCKS)
.build();
TextContentRenderer.TextContentRendererExtensionThis is the extension contract for plain-text rendering.
TextContentWriterTextContentNodeRendererContextTextContentNodeRendererFactoryCoreTextContentNodeRendererMarkdownRendererMarkdownRenderer turns an AST back into canonical Markdown.
Main methods:
builder()render(Node, Appendable)render(Node)Builder options:
nodeRendererFactory(MarkdownNodeRendererFactory)extensions(Iterable<? extends Extension>)withExtension(Extension)withExtensions(Extension...)Example:
MarkdownRenderer renderer = MarkdownRenderer.builder().build();
MarkdownRenderer.MarkdownRendererExtensionThis is the extension contract for Markdown output.
MarkdownWriterMarkdownNodeRendererContextMarkdownNodeRendererFactoryCoreMarkdownNodeRendererAutolinkExtensionTurns bare URLs, emails, and www. links into link nodes.
Builder methods:
builder()linkTypes(AutolinkType...)linkTypes(Set<AutolinkType>)build()Supported link kinds:
AutolinkType.URLAutolinkType.EMAILAutolinkType.WWWStrikethroughExtensionAdds ~ and ~~ strikethrough support.
Builder methods:
builder()requireTwoTildes(boolean)build()TablesExtensionAdds GitHub-style pipe table support.
This extension has no tunable builder options.
TaskListItemsExtensionAdds checkbox-style task list item support.
This extension has no tunable builder options.
MarkdownClassExtensionAdds configurable CSS classes to rendered HTML and Elemental2 output.
Builder methods:
builder()classes(String...)nodeClasses(Class<? extends Node>, String...)tagClasses(String, String...)build()Use this extension when you want to attach your own class names to every generated element, to a specific Markdown node type, or to a specific rendered tag name.
DuiClassExtensionPreset extension that applies the repository's built-in dui and dui-md-* class naming scheme.
This extension has no tunable builder options.
ExtensionDiscoveryStandardExtensionSetsUse ExtensionDiscovery.load() to get the bundled extension set in deterministic order.
IncludeSourceSpansControls how much source-position information the parser collects.
NONEBLOCKSBLOCKS_AND_INLINESLineBreakRenderingControls plain-text line-break behavior.
STRIPCOMPACTSEPARATE_BLOCKSSoftBreakRenderingControls Elemental2 soft-break behavior.
NEWLINE_TEXTSPACE_TEXTBR_ELEMENTAutolinkTypeControls which kinds of autolinks the autolink extension recognizes.
URLEMAILWWWThese are public and often useful when you are customizing behavior:
CharMatcherAsciiMatcherCharactersUrlSanitizerDefaultUrlSanitizerThe same extension set can often be registered on multiple builders:
Set<Extension> extensions = Set.of(
AutolinkExtension.create(),
StrikethroughExtension.create(),
TablesExtension.create(),
TaskListItemsExtension.create());
Parser parser = Parser.builder().extensions(extensions).build();
HtmlRenderer htmlRenderer = HtmlRenderer.builder().extensions(extensions).build();
Elemental2Renderer domRenderer = Elemental2Renderer.builder().extensions(extensions).build();
TextContentRenderer textRenderer = TextContentRenderer.builder().extensions(extensions).build();
MarkdownRenderer markdownRenderer = MarkdownRenderer.builder().extensions(extensions).build();
That is the cleanest way to keep parsing and rendering behavior aligned.