java.lang.Object
org.commonmark.ext.gfm.alerts.AlertsExtension
- All Implemented Interfaces:
Extension,Parser.ParserExtension,HtmlRenderer.HtmlRendererExtension,MarkdownRenderer.MarkdownRendererExtension,TextContentRenderer.TextContentRendererExtension
public class AlertsExtension
extends Object
implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension, TextContentRenderer.TextContentRendererExtension, MarkdownRenderer.MarkdownRendererExtension
Extension for GFM alerts using
[!TYPE] syntax (GitHub Flavored Markdown).
Create with create() or builder() and configure on builders (Parser.Builder.extensions(Iterable), HtmlRenderer.Builder.extensions(Iterable)). Parsed
alerts become Alert blocks. If custom alert titles are allowed via AlertsExtension.Builder.allowCustomTitles(boolean), the inline formatting of those titles will be parsed into
AlertTitle nodes.
The default configuration of this extension will match GFM exactly, with the
following exceptions:
- Alert markers take precedence over shortcut reference links. - Alerts with no content are allowed. Example:
<!-- Valid -->
> [!NOTE]
<!-- Also valid if custom titles are allowed -->
> [!NOTE] Custom title
- Lazy continuation is not allowed between the marker and the body text. Example:
> [!NOTE]
Lazy body text will be parsed as a new paragraph
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for configuring the alerts extension. -
Field Summary
FieldsModifier and TypeFieldDescriptionA map of alert marker ([!TYPE]) to the default title for that marker.private final booleanprivate final booleanThe standard GitHub Flavored Markdown (GFM) types that the extension enables by default. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AlertsExtension.Builderbuilder()static Extensioncreate()voidextend(Parser.Builder parserBuilder) voidextend(HtmlRenderer.Builder rendererBuilder) voidextend(MarkdownRenderer.Builder rendererBuilder) Extend Markdown rendering, usually by registering custom node renderers usingMarkdownRenderer.Builder.nodeRendererFactory(org.commonmark.renderer.markdown.MarkdownNodeRendererFactory).voidextend(TextContentRenderer.Builder rendererBuilder)
-
Field Details
-
STANDARD_TYPES
The standard GitHub Flavored Markdown (GFM) types that the extension enables by default. These can be overwritten withAlertsExtension.Builder.setAllowedTypes(Map). -
allowedTypes
A map of alert marker ([!TYPE]) to the default title for that marker. -
customTitlesAllowed
private final boolean customTitlesAllowed -
nestedAlertsAllowed
private final boolean nestedAlertsAllowed
-
-
Constructor Details
-
AlertsExtension
-
-
Method Details
-
create
-
builder
-
extend
- Specified by:
extendin interfaceParser.ParserExtension
-
extend
- Specified by:
extendin interfaceHtmlRenderer.HtmlRendererExtension
-
extend
- Specified by:
extendin interfaceTextContentRenderer.TextContentRendererExtension
-
extend
Description copied from interface:MarkdownRenderer.MarkdownRendererExtensionExtend Markdown rendering, usually by registering custom node renderers usingMarkdownRenderer.Builder.nodeRendererFactory(org.commonmark.renderer.markdown.MarkdownNodeRendererFactory).- Specified by:
extendin interfaceMarkdownRenderer.MarkdownRendererExtension- Parameters:
rendererBuilder- the renderer builder to extend
-