| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Extensions need to extend the parser, HTML renderer, formatter, or any combination of these. To use an extension, the builder objects can be configured with a list of extensions. Because extensions are optional, they live in separate artifacts, requiring additional dependencies to be added to the project.
Let's look at how to enable tables from GitHub Flavored Markdown or MultiMarkdown, which ever your prefer. First, add all modules as a dependency (see Maven Central for individual modules):
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.64.8</version>
</dependency>Configure the extension on the builders:
import com.vladsch.flexmark.ext.tables.TablesExtension;
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension;
class SomeClass {
static final DataHolder OPTIONS = new MutableDataSet()
.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()))
.toImmutable();
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
}A generic options API allows easy configuration of the parser, renderer and extensions. It consists of DataKey<T> instances defined by various components. Each data key defines the type of its value and a default value.
The values are accessed via the DataHolder and MutableDataHolder interfaces, with the former being a read only container. Since the data key provides a unique identifier for the data there is no collision for options.
To configure the parser or renderer, pass a data holder to the builder() method with the desired options configured, including extensions.
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
public class SomeClass {
static final DataHolder OPTIONS = new MutableDataSet()
.set(Parser.REFERENCES_KEEP, KeepType.LAST)
.set(HtmlRenderer.INDENT_SIZE, 2)
.set(HtmlRenderer.PERCENT_ENCODE_URLS, true)
// for full GFM table compatibility add the following table extension options:
.set(TablesExtension.COLUMN_SPANS, false)
.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create()))
.toImmutable();
static final Parser PARSER = Parser.builder(OPTIONS).build();
static final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
}In the code sample above, Parser.REFERENCES_KEEP defines the behavior of references when duplicate references are defined in the source. In this case it is configured to keep the last value, whereas the default behavior is to keep the first value.
The HtmlRenderer.INDENT_SIZE and HtmlRenderer.PERCENT_ENCODE_URLS define options to use for rendering. Similarly, extension options can be added at the same time. Any options not set, will default to their respective defaults as defined by their data keys.
All markdown element reference types should be stored using a subclass of NodeRepository<T> as is the case for references, abbreviations and footnotes. This provides a consistent mechanism for overriding the default behavior of these references for duplicates from keep first to keep last.
By convention, data keys are defined in the extension class and in the case of the core in the Parser or HtmlRenderer.
Data keys are described in their respective extension classes and in Parser and HtmlRenderer.
Core implements parser, Html renderer and formatter functionality for CommonMark markdown elements.
Unified options handling added which are also used to selectively disable loading of core parsers and processors.
Parser.builder() now implements MutableDataHolder so you can use get/set to customize properties directly on it or pass it a DataHolder with predefined options.
Defined in Parser class:
ℹ️ In parsers, use state.getParsing().CODE_BLOCK_INDENT to ensure that all parsers have the same setting. Parsing copies the setting from options on creation so having this option changed after parsing phase has started will have no effect.
Parser.CODE_SOFT_LINE_BREAKS : default false, set to true to include soft line break nodes in code blocks
Parser.CODE_STYLE_HTML_CLOSE : default (String)null override HTML to use for wrapping style, if null then no override
Parser.CODE_STYLE_HTML_OPEN : default (String)null override HTML to use for wrapping style, if null then no override
Parser.EMPHASIS_STYLE_HTML_CLOSE : default (String)null override HTML to use for wrapping style, if null then no override
Parser.EMPHASIS_STYLE_HTML_OPEN : default (String)null override HTML to use for wrapping style, if null then no override
Parser.EXTENSIONS : default empty list list of extension to use for builders. Can use this option instead of passing extensions to parser builder and renderer builder.
Parser.FENCED_CODE_BLOCK_PARSER : default true enable parsing of fenced code blocks
Parser.FENCED_CODE_CONTENT_BLOCK : default false add CodeBlock as child to contain the code of a fenced block. Otherwise the code is contained in a Text node.
Parser.HARD_LINE_BREAK_LIMIT : default false only treat the last 2 spaces of a hard line break in the HardLineBreak node if set to true. Otherwise all spaces are used.
Parser.HEADING_CAN_INTERRUPT_ITEM_PARAGRAPH : default true allow headings to interrupt list item paragraphs
Parser.HEADING_NO_ATX_SPACE : default false allow headers without a space between # and the header text if true
Parser.HEADING_NO_EMPTY_HEADING_WITHOUT_SPACE default false, set to true to not recognize empty headings without a space following #
Parser.HEADING_NO_LEAD_SPACE : default false do not allow non-indent spaces before # for atx headers and text or -/= marker for setext, if true (pegdown and GFM), if false commonmark rules.
Parser.HEADING_PARSER : default true enable parsing of headings
Parser.HEADING_SETEXT_MARKER_LENGTH : default 1 sets the minimum number of - or = needed under a setext heading text before it being recognized as a heading.
Parser.HTML_ALLOW_NAME_SPACE : default false, when true will allow a name space prefix for HTML elements. ❗ HTML Deep Parser always enables name spaces and ignores this option.
Parser.HTML_BLOCK_COMMENT_ONLY_FULL_LINE : default false, when true will allow embedded HTML comments to interrupt paragraphs.
Parser.HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS_PARTIAL_TAG default true, when true blank line interrupts partially open tag ie. <TAG without a corresponding > and having a blank line blank line before >
Parser.HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS default true, when true Blank line interrupts HTML block when not in raw tag, otherwise only when closed
Parser.HTML_BLOCK_DEEP_PARSE_FIRST_OPEN_TAG_ON_ONE_LINE default false, when true do not parse open tags unless they are contained on one line.
Parser.HTML_BLOCK_DEEP_PARSE_INDENTED_CODE_INTERRUPTS default false, when true Indented code can interrupt HTML block without a preceding blank line.
Parser.HTML_BLOCK_DEEP_PARSE_MARKDOWN_INTERRUPTS_CLOSED default false, when true Other markdown elements can interrupt a closed HTML block without an intervening blank line
Parser.HTML_BLOCK_DEEP_PARSE_NON_BLOCK default true, parse non-block tags inside HTML blocks
Parser.HTML_BLOCK_DEEP_PARSER default false - enable deep HTML block parsing
Parser.HTML_BLOCK_PARSER : default true enable parsing of html blocks
Parser.HTML_BLOCK_START_ONLY_ON_BLOCK_TAGS, default for deep html parser is true and regular parser false, but you can set your desired specific value and override the default. When true will not start an HTML block on a non-block tag, when false any tag will start an HTML block.
Parser.HTML_BLOCK_TAGS, default list: address, article, aside, base, basefont, blockquote, body, caption, center, col, colgroup, dd, details, dialog, dir, div, dl, dt, fieldset, figcaption, figure, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hr, html, iframe, legend, li, link, main, math, menu, menuitem, meta, nav, noframes, ol, optgroup, option, p, param, section, source, summary, table, tbody, td, tfoot, th, thead, title, tr, track, ul, sets the HTML block tags
Parser.HTML_COMMENT_BLOCKS_INTERRUPT_PARAGRAPH : default true enables HTML comments to interrupt paragraphs, otherwise comment to be interpreted as HTML blocks need a blank line before.
Parser.HTML_FOR_TRANSLATOR : default false, when true the parser is modified to allow translator placeholders to be recognized
Parser.INDENTED_CODE_BLOCK_PARSER : default true enable parsing of indented code block
Parser.INDENTED_CODE_NO_TRAILING_BLANK_LINES : default true enable removing trailing blank lines from indented code blocks
Parser.INLINE_DELIMITER_DIRECTIONAL_PUNCTUATIONS default false, set to true to use delimiter parsing rules that take bracket open/close into account
Parser.INTELLIJ_DUMMY_IDENTIFIER : default false add '\u001f' to all parse patterns as an allowable character, used by plugin to allow for IntelliJ completion location marker
Parser.LINKS_ALLOW_MATCHED_PARENTHESES : default true, when false uses spec 0.27 rules for link addresses and does not resolve matched ()
Parser.LIST_BLOCK_PARSER : default true enable parsing of lists
Parser.LIST_REMOVE_EMPTY_ITEMS, default false. If true then empty list items or list items which only contain a BlankLine node are removed from the output.
Parser.LISTS_END_ON_DOUBLE_BLANK : default false, when true lists are terminated by a double blank line as per spec 0.27 rules.
Parser.LISTS_ITEM_PREFIX_CHARS : default "*-+", specify which characters mark a list item
Parser.LISTS_LOOSE_WHEN_CONTAINS_BLANK_LINE : default false, when true a list item which contains a blank line will be considered a loose list item.
Parser.LISTS_LOOSE_WHEN_LAST_ITEM_PREV_HAS_TRAILING_BLANK_LINE : default false, when true will consider a list with last item followed by blank line as a loose list.
Parser.MATCH_CLOSING_FENCE_CHARACTERS : default true whether the closing fence character has to match opening character, when false then back ticks can open and tildes close and vice versa. The number of characters in the opener and close still have to be the same.
Parser.MATCH_NESTED_LINK_REFS_FIRST : default true custom link ref processors that take tested [] have priority over ones that do not. ie. [[^f]][test] is a wiki link with ^f as page ref followed by ref link test when this option is true. IF false then the same would be a ref link test with a footnote ^f refernce for text
Parser.PARSE_INNER_HTML_COMMENTS : default false when true will parse inner HTML comments in HTML blocks
Parser.PARSE_JEKYLL_MACROS_IN_URLS default false, set to true to allow any characters to appear between {{ and }} in URLs, including spaces, pipes and backslashes
Parser.PARSE_MULTI_LINE_IMAGE_URLS : default false allows parsing of multi line urls:
Parser.PARSER_EMULATION_PROFILE default ParserEmulationProfile.COMMONMARK, set to desired one of the ParserEmulationProfile values
Parser.REFERENCE_PARAGRAPH_PRE_PROCESSOR : default true enable parsing of reference definitions
Parser.REFERENCES_KEEP : default KeepType.FIRST which duplicates to keep.
Parser.REFERENCES : default new repository repository for document's reference definitions
Parser.SPACE_IN_LINK_ELEMENTS default false, set to true to allow whitespace between ![] or [] and () of links or images.
Parser.SPACE_IN_LINK_URLS : default false will accept spaces in link address as long as they are not followed by "
Parser.STRONG_EMPHASIS_STYLE_HTML_CLOSE : default (String)null override HTML to use for wrapping style, if null then no override
Parser.STRONG_EMPHASIS_STYLE_HTML_OPEN : default (String)null override HTML to use for wrapping style, if null then no override
Parser.STRONG_WRAPS_EMPHASIS : default false, when true uses spec 0.27 rules for emphasis/strong resolution
Parser.THEMATIC_BREAK_PARSER : default true enable parsing of thematic breaks
Parser.THEMATIC_BREAK_RELAXED_START : default true enable parsing of thematic breaks which are not preceded by a blank line
Parser.TRACK_DOCUMENT_LINES default false. When true document lines are tracked in the document's lineSegments list and offset to line method can be used to get the 0-based line number for the given offset. When false these functions compute the line number by counting EOL sequences before the offset.
Parser.UNDERSCORE_DELIMITER_PROCESSOR : default true whether to process underscore delimiters
Parser.USE_HARDCODED_LINK_ADDRESS_PARSER : default true, when false uses regex for link address parsing, which causes StackOverflowError for long URLs
Parser.WWW_AUTO_LINK_ELEMENT : default false, when true www. prefix is recognized as an auto-link prefix
ℹ️ Parser.USE_HARDCODED_LINK_ADDRESS_PARSER set to true is the default because the regex based parsing requires much more stack space and will cause StackOverflowError error when attempting to parse link URLs larger than about 1.5k characters. This option is available only for backwards compatibility and in case someone customizes the regex for parsing. Performance of the hard-coded parser is on par with the regex one while requiring no stack space for parsing.
| Test | Regex Parser | Hardcoded Parser | Options |
|---|---|---|---|
| emphasisClosersWithNoOpeners | 205 ms | 221 ms | Default |
| emphasisOpenersWithNoClosers | 162 ms | 170 ms | Default |
| linkClosersWithNoOpeners | 61 ms | 65 ms | Default |
| linkOpenersAndEmphasisClosers | 277 ms | 286 ms | Default |
| linkOpenersWithNoClosers | 87 ms | 89 ms | Default |
| StackOverflow longImageLinkTest | 136 ms | 738 ms | Default |
| longLinkTest | 77 ms | 63 ms | Default |
| mismatchedOpenersAndClosers | 264 ms | 342 ms | Default |
| nestedBrackets | 85 ms | 72 ms | Default |
| nestedStrongEmphasis | 8 ms | 6 ms | Default |
| emphasisClosersWithNoOpeners | 173 ms | 113 ms | Space in URLs |
| emphasisOpenersWithNoClosers | 163 ms | 123 ms | Space in URLs |
| linkClosersWithNoOpeners | 55 ms | 56 ms | Space in URLs |
| linkOpenersAndEmphasisClosers | 216 ms | 229 ms | Space in URLs |
| linkOpenersWithNoClosers | 85 ms | 85 ms | Space in URLs |
| longImageLinkTest | Stack Overflow | 684 ms | Space in URLs |
| longLinkTest | Stack Overflow | 71 ms | Space in URLs |
| mismatchedOpenersAndClosers | 214 ms | 327 ms | Space in URLs |
| nestedBrackets | 55 ms | 79 ms | Space in URLs |
| nestedStrongEmphasis | 5 ms | 6 ms | Space in URLs |
Because list parsing is the greatest discrepancy between Markdown parser implementations. Before CommonMark there was no hard specification for parsing lists and every implementation took artistic license with how it determines what the list should look like.
flexmark-java implements four parser families based on their list processing characteristics. In addition to ParserEmulationProfile setting, each of the families has a standard set of common options that control list processing, with defaults set by each but modifiable by the end user.
There are a few ways to configure the list parsing options:
⚠️ If both LISTS_ITEM_TYPE_MISMATCH_TO_NEW_LIST and LISTS_ITEM_TYPE_MISMATCH_TO_SUB_LIST are set to true then a new list will be created if the item had a blank line, otherwise a sub-list is created.
Unified options handling added, existing configuration options were kept but now they modify the corresponding unified option.
Renderer Builder() now has an indentSize(int) method to set size of indentation for hierarchical tags. Same as setting HtmlRenderer.INDENT_SIZE data key in options.
Defined in HtmlRenderer class:
Suppressed links will render only the child nodes, effectively [Something New](javascript:alert(1)) will render as if it was Something New.
Link suppression based on URL prefixes does not apply to HTML inline or block elements. Use HTML suppression options for this.
❗ All the escape and suppress options have dynamic default value. This allows you to set the ESCAPE_HTML and have all html escaped. If you set a value of a specific key then the set value will be used for that key. Similarly, comment affecting keys take their values from the non-comment counterpart. If you want to exclude comments from being affected by suppression or escaping then you need to set the corresponding comment key to false and set the non-comment key to true.
Formatter renders the AST as markdown with various formatting options to clean up and make the source consistent and possibly convert from one indentation rule set to another. Formatter API allows extensions to provide and handle formatting options for custom nodes.
ℹ️ in versions prior to 0.60.0 formatter functionality was implemented in flexmark-formatter module and required an additional dependency.
See: Markdown Formatter
Formatter can also be used to help translate the markdown document to another language by extracting translatable strings, replacing non-translatable strings with an identifier and finally replacing the translatable text spans with translated versions.
Formatter can be used to merge multiple markdown documents into a single document while preserving reference resolution to references within each document, even when reference ids conflict between merged documents.
See: Markdown Merge API
HTML to PDF conversion is done using Open HTML To PDF library by PdfConverterExtension in flexmark-pdf-converter module.
The following extensions are developed with this library, each in their own artifact.
Extension options are defined in their extension class.
Allows to create abbreviations which will be replaced in plain text into <abbr></abbr> tags or optionally into <a></a> with titles for the abbreviation expansion.
Use class AbbreviationExtension from artifact flexmark-ext-abbreviation.
The following options are available:
Defined in AbbreviationExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ABBREVIATIONS | new repository | repository for document's abbreviation definitions |
| ABBREVIATIONS_KEEP | KeepType.FIRST | which duplicates to keep. |
| USE_LINKS | false | use <a> instead of <abb> tags for rendering html |
| ABBREVIATIONS_PLACEMENT | ElementPlacement.AS_IS | formatting option see: Markdown Formatter |
| ABBREVIATIONS_SORT | ElementPlacement.AS_IS | formatting option see: Markdown Formatter |
To create block-styled side content. Based on Admonition Extension, Material for MkDocs (Personal opinion: Material for MkDocs is eye-candy. If you have not taken a look at it, you are missing out on a visual treat.). See Admonition Extension
Use class AbbreviationExtension from artifact flexmark-ext-admonition.
Default CSS and JavaScript are contained in the jar as resources:
Their content is also available by calling AdmonitionExtension.getDefaultCSS() and AdmonitionExtension.getDefaultScript() static methods.
The script should be included at the bottom of the body of the document and is used to toggle open/closed state of collapsible admonition elements.
Automatically adds anchor links to heading, using GitHub id generation algorithm
⚠️ This extension will only render an anchor link for headers that have an id attribute associated with them. You need to have the HtmlRenderer.GENERATE_HEADER_ID option to set to true so that header ids are generated.
Use class AnchorLinkExtension from artifact flexmark-ext-anchorlink.
The following options are available:
Defined in AnchorLinkExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ANCHORLINKS_SET_ID | true | whether to set the id attribute to the header id, if true |
| ANCHORLINKS_SET_NAME | false | whether to set the name attribute to the header id, if true |
| ANCHORLINKS_WRAP_TEXT | true | whether to wrap the heading text in the anchor, if true |
| ANCHORLINKS_TEXT_PREFIX | "" | raw html prefix. Added before heading text, wrapped or unwrapped |
| ANCHORLINKS_TEXT_SUFFIX | "" | raw html suffix. Added before heading text, wrapped or unwrapped |
| ANCHORLINKS_ANCHOR_CLASS | "" | class for the a tag |
Same as block quotes but uses | for prefix and generates <aside> tags. To make it compatible with the table extension, aside block lines cannot have | as the last character of the line, and if using this extension the tables must have the lines terminate with a | otherwise they will be treated as aside blocks.
Use class AsideExtension from artifact flexmark-ext-aside.
Defined in AsideExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| IGNORE_BLANK_LINE | false | aside block will include blank lines between aside blocks and treat them as if the blank lines are also preceded by the aside block marker |
| EXTEND_TO_BLANK_LINE | false | aside blocks extend to blank line when true. Enables more customary a la block quote parsing than commonmark strict standard |
| ALLOW_LEADING_SPACE | true | when true leading spaces before > are allowed |
| INTERRUPTS_ITEM_PARAGRAPH | true | when true block quotes can interrupt list item text, else need blank line before to be included in list items |
| INTERRUPTS_PARAGRAPH | true | when true block quote can interrupt a paragraph, else needs blank line before |
| WITH_LEAD_SPACES_INTERRUPTS_ITEM_PARAGRAPH | true | when true block quotes with leading spaces can interrupt list item text, else need blank line before or no leading spaces |
AsideExtension option keys are dynamic data keys dependent on corresponding Parser block quote options for their defaults. If they are not explicitly set then they will take their default value from the value of the corresponding block quote value (prefix BLOCK_QUOTE_ to AsideExtension key name to get Parser block quote key name).
⚠️ This can potentially break code relying on versions of the extension before 0.40.20 because parsing rules can change depending on which block quote options are changed from their default values.
To ensure independent options for aside blocks and block quotes, set aside options explicitly. The following will set all aside options to default values, independent from block quote options:
.set(EXTEND_TO_BLANK_LINE, false) .set(IGNORE_BLANK_LINE, false) .set(ALLOW_LEADING_SPACE, true) .set(INTERRUPTS_PARAGRAPH, true) .set(INTERRUPTS_ITEM_PARAGRAPH, true) .set(WITH_LEAD_SPACES_INTERRUPTS_ITEM_PARAGRAPH, true)
Converts attributes {...} syntax into attributes AST nodes and adds an attribute provider to set attributes for immediately preceding sibling element during HTML rendering. See Attributes Extension
Defined in AttributeExtension from artifact flexmark-ext-attributes
ASSIGN_TEXT_ATTRIBUTES, default true. When false attribute assignment rules to nodes are changed not to allow text elements to get attributes.
FENCED_CODE_INFO_ATTRIBUTES, default true. When false attribute assignment at end of fenced code info string will be ignored.
USE_EMPTY_IMPLICIT_AS_SPAN_DELIMITER, default false. When set to true will treat {#} or {.}, without embedded spaced, as start attribute span delimiter to mark start of attribute assignment to text between {.} or {#} and the matching attributes element.
Use class AttributesExtension from artifact flexmark-ext-attributes.
Full spec: ext_attributes_ast_spec
Turns plain links such as URLs and email addresses into links (based on autolink-java).
⚠️ current implementation has significant performance impact on large files.
Use class AutolinkExtension from artifact flexmark-ext-autolink.
Defined in AsideExtension class:
Converts definition syntax of Php Markdown Extra Definition List to <dl></dl> HTML and corresponding AST nodes.
Definition items can be preceded by : or ~, depending on the configured options.
Use class DefinitionExtension from artifact flexmark-ext-definition.
The following options are available:
Defined in DefinitionExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| COLON_MARKER | true | enable use of : as definition item marker |
| MARKER_SPACES | 1 | minimum number of spaces after definition item marker for valid definition item |
| TILDE_MARKER | true | enable use of ~ as definition item marker |
| DOUBLE_BLANK_LINE_BREAKS_LIST | false | When true double blank line between definition item and next definition term will break a definition list |
| FORMAT_MARKER_SPACES | 3 | formatting option see: Markdown Formatter |
| FORMAT_MARKER_TYPE | DefinitionMarker.ANY | formatting option see: Markdown Formatter |
ℹ️ this extension uses list parsing and indentation rules and will its best to align list item and definition item parsing according to selected options. For non-fixed indent family of parsers will use the definition item content indent column for sub-items, otherwise uses the Parser.LISTS_ITEM_INDENT value for sub-items.
Wiki: Definition List Extension
Renders the parsed Markdown AST to docx format using the docx4j library.
artifact: flexmark-docx-converter
See the DocxConverterCommonMark Sample for code and Customizing Docx Rendering for an overview and information on customizing the styles.
Pegdown version can be found in DocxConverterPegdown Sample
For details see Docx Renderer Extension
Allows to create image link to emoji images from emoji shortcuts using Emoji-Cheat-Sheet.com, GitHub Emoji API and optionally to replace with its unicode equivalent character with mapping to GitHub shortcut or Emoji-Cheat-Sheet.com shortcut based on the file name.
Use class EmojiExtension from artifact flexmark-ext-emoji.
The following options are available:
Defined in EmojiExtension class:
Used to create numbered references and numbered text labels for elements in the document. Enumerated References Extension
Use class EnumeratedReferenceExtension from artifact flexmark-ext-enumerated-reference.
❗ Note Attributes extension is needed in order for references to be properly resolved for rendering.
Creates footnote references in the document. Footnotes are placed at the bottom of the rendered document with links from footnote references to footnote and vice-versa. Footnotes Extension
Converts: [^footnote] to footnote references and [^footnote]: footnote definition to footnotes in the document.
Enables Gfm issue reference parsing in the form of #123
Use class GfmIssuesExtension in artifact flexmark-ext-gfm-issues.
The following options are available:
Defined in GfmIssuesExtension class:
Enables strikethrough of text by enclosing it in ~~. For example, in hey ~~you~~, you will be rendered as strikethrough text.
Use class StrikethroughExtension in artifact flexmark-ext-gfm-strikethrough.
Enables subscript of text by enclosing it in ~. For example, in hey ~you~, you will be rendered as subscript text.
Use class SubscriptExtension in artifact flexmark-ext-gfm-strikethrough.
To enables both subscript and strike through:
Use class StrikethroughSubscriptExtension in artifact flexmark-ext-gfm-strikethrough.
⚠️ Only one of these extensions can be included in the extension list. If you want both strikethrough and subscript use the StrikethroughSubscriptExtension.
The following options are available:
Defined in StrikethroughSubscriptExtension class:
Enables list items based task lists whose text begins with: [ ], [x] or [X]
Use class TaskListExtension in artifact flexmark-ext-gfm-tasklist.
The following options are available:
Defined in TaskListExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ITEM_DONE_MARKER |
<input type="checkbox" class="task-list-item-checkbox" checked="checked" disabled="disabled" /> |
string to use for the item done marker html. |
| ITEM_NOT_DONE_MARKER |
<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" /> |
string to use for the item not done marker html. |
| ITEM_CLASS | "task-list-item" | tight list item class attribute |
| ITEM_ITEM_DONE_CLASS | "" | list item class for done task list item |
| ITEM_ITEM_NOT_DONE_CLASS | "" | list item class for not done task list item |
| LOOSE_ITEM_CLASS | value of ITEM_CLASS | loose list item class attribute, if not set then will use value of tight item class |
| PARAGRAPH_CLASS | "" | p tag class attribute, only applies to loose list items |
| FORMAT_LIST_ITEM_CASE | TaskListItemCase.AS_IS | formatting option see: Markdown Formatter |
| FORMAT_LIST_ITEM_PLACEMENT | TaskListItemPlacement.AS_IS | formatting option see: Markdown Formatter |
TaskListItemCase
TaskListItemPlacement
Enables Gfm user reference parsing in the form of #123
Use class GfmUsersExtension in artifact flexmark-ext-gfm-users.
The following options are available:
Defined in GfmUsersExtension class:
Parses and renders GitLab Flavoured Markdown.
Add: video link renderer to convert links to video files to embedded content. The valid video extensions are .mp4, .m4v, .mov, .webm, and .ogv.
<div class="video-container"> <video src="video.mp4" width="400" controls="true"></video> <p><a href="video.mp4" target="_blank" rel="noopener noreferrer" title="Download 'Sample Video'">Sample Video</a></p> </div>
Multiline Block quote delimiters >>>
Deleted text markers {- -} or [- -]
Inserted text markers {+ +} or [+ +]
Math, inline via $``$ or as fenced code with math info string requiring inclusion of Katex in the rendered HTML page.
Graphing via Mermaid as fenced code with mermaid info string, via Mermaid inclusion similar to Math solution above.
Use class GitLabExtension in artifact flexmark-ext-gitlab.
The following options are available:
Defined in GitLabExtension class:
INS_PARSER : default true, enable ins parser
DEL_PARSER : default true, enable del parser
BLOCK_QUOTE_PARSER : default true, enable multi-line block quote parser
INLINE_MATH_PARSER : default true, enable inline math parser
RENDER_BLOCK_MATH : default true, enable rendering math fenced code blocks as math elements
RENDER_BLOCK_MERMAID : default true, enable rendering mermaid fenced code blocks as mermaid elements
RENDER_VIDEO_IMAGES : default true, enable rendering image links with video extensions as video elements
RENDER_VIDEO_LINK : default true, enable rendering video link with video images
INLINE_MATH_CLASS : default "katex", inline math class attribute
BLOCK_MATH_CLASS : default "katex" block math class attribute
BLOCK_MERMAID_CLASS : default "mermaid" block mermaid class attribute
VIDEO_IMAGE_CLASS : default "video-container" class attribute
VIDEO_IMAGE_LINK_TEXT_FORMAT : default "Download '%s'" format for video link text, %s replaced with image alt text
BLOCK_INFO_DELIMITERS : default " ", delimiters used for extracting math and mermaid strings from fenced code info string
VIDEO_IMAGE_EXTENSIONS : default "mp4,m4v,mov,webm,ogv", extensions of video files which to render as video
ℹ️ to have Math and Mermaid properly rendered requires inclusion of Katex and Mermaid scripts in the HTML page.
If you have the files in the same directory as the HTML page, somewhere between the <head> and </head> tags, you need to include:
<link rel="stylesheet" href="katex.min.css">
<script src="katex.min.js"></script>
<script src="mermaid.min.js"></script>In addition to the Katex script you need to add JavaScript to the bottom of the page body to convert math elements when the DOM is loaded:
<script>
(function () {
document.addEventListener("DOMContentLoaded", function () {
var mathElems = document.getElementsByClassName("katex");
var elems = [];
for (const i in mathElems) {
if (mathElems.hasOwnProperty(i)) elems.push(mathElems[i]);
}
elems.forEach(elem => {
katex.render(elem.textContent, elem, { throwOnError: false, displayMode: elem.nodeName !== 'SPAN', });
});
});
})();Not really an extension but useful if you need to convert HTML to Markdown.
Converts HTML to Markdown, assumes all non-application specific extensions are going to be used:
This converter has an extension API to allow custom HTML tag to Markdown conversion, link URL replacement and options.
Use class FlexmarkHtmlConverter in artifact flexmark-html2md-converter.
Use FlexmarkHtmlConverter.builder(options).build().convert(htmlString) to get equivalent to old FlexmarkHtmlParser.parse(htmlString, options)
The following options are available:
Defined in FlexmarkHtmlConverter class:
BR_AS_EXTRA_BLANK_LINES default true, when true <br> encountered after a blank line is already in output or current output ends in <br> then will insert an inline HTML <br> into output to create extra blank lines in rendered result.
BR_AS_PARA_BREAKS default true, when true <br> encountered at the beginning of a new line will be treated as a paragraph break
CODE_INDENT, default 4 spaces, indent to use for indented code
DEFINITION_MARKER_SPACES, default 3, min spaces after : for definitions
DIV_AS_PARAGRAPH default false, when true will treat <div> wrapped text as if it was <p> wrapped by adding a blank line after the text.
DOT_ONLY_NUMERIC_LISTS, default true. When set to false closing parenthesis as a list delimiter will be used in Markdown if present in MS-Word style list. Otherwise parenthesis delimited list will be converted to dot ..
EOL_IN_TITLE_ATTRIBUTE, default " ", string to use in place of EOL in image and link title attribute.
LISTS_END_ON_DOUBLE_BLANK default false, when set to true consecutive lists are separated by double blank line, otherwise by an empty HTML comment line.
LIST_CONTENT_INDENT, default true, continuation lines of list items and definitions indent to content column otherwise 4 spaces
MIN_SETEXT_HEADING_MARKER_LENGTH, default 3, min 3, minimum setext heading marker length
MIN_TABLE_SEPARATOR_COLUMN_WIDTH, default 1, min 1, minimum number of - in separator column, excluding alignment colons :
MIN_TABLE_SEPARATOR_DASHES, default 3, min 3, minimum separator column width, including alignment colons :
NBSP_TEXT, default " ", string to use in place of non-break-space
ORDERED_LIST_DELIMITER, default '.', delimiter for ordered items
OUTPUT_UNKNOWN_TAGS, default false, when true unprocessed tags will be output, otherwise they are ignored
RENDER_COMMENTS, default false. When set to true HTML comments will be rendered in the Markdown.
SETEXT_HEADINGS, default true, if true then use Setext headings for h1 and h2
THEMATIC_BREAK, default "*** ** * ** ***", <hr> replacement
UNORDERED_LIST_DELIMITER, default '*', delimiter for unordered list items
OUTPUT_ATTRIBUTES_ID, default true, if true id attribute will be rendered in Attributes syntax
OUTPUT_ID_ATTRIBUTE_REGEX, default "^user-content-(.*)", regex to use for processing id attributes, if matched then will concatenate all groups which are not empty, if result string is empty after trimming then no id will be generated. If value empty then no processing is done and id will be rendered as in the HTML.
ℹ️ Default value will strip out GitHub rendered HTML heading id prefix of user-content-.
OUTPUT_ATTRIBUTES_NAMES_REGEX default "", if not empty then will output attributes extension syntax for attribute names that are matched by the regex.
ADD_TRAILING_EOL, default false. Will add trailing EOL to generated markdown text.
to convert some markdown formatting elements to their inner text, default for all is false:
to control conversion of inline elements, default is ExtensionConversion.MARKDOWN
Available settings:
UNWRAPPED_TAGS, default new String[] { "article", "address", "frameset", "section", "small", "iframe", }, defines tags whose inner html content should be rendered
WRAPPED_TAGS, default new String[] { "kbd", "var" }, defines tags which should render as outer HTML. Inner text will be converted to markdown.
TYPOGRAPHIC_REPLACEMENT_MAP option key taking a Map<String,String>, if not empty will be used instead of the bundled map. Any typographic characters or HTML entities missing from the map will be output without conversion. If you want to suppress a typographic so it is not output add "" to its mapped value.
The bundled map is filled as follows:
class HtmlParser {
static Map<String, String> specialCharsMap = new HashMap<>();
static {
specialCharsMap.put("“", "\"");
specialCharsMap.put("”", "\"");
specialCharsMap.put("“", "\"");
specialCharsMap.put("”", "\"");
specialCharsMap.put("‘", "'");
specialCharsMap.put("’", "'");
specialCharsMap.put("‘", "'");
specialCharsMap.put("’", "'");
specialCharsMap.put("'", "'");
specialCharsMap.put("«", "<<");
specialCharsMap.put("«", "<<");
specialCharsMap.put("»", ">>");
specialCharsMap.put("»", ">>");
specialCharsMap.put("…", "...");
specialCharsMap.put("…", "...");
specialCharsMap.put("–", "--");
specialCharsMap.put("&endash;", "--");
specialCharsMap.put("—", "---");
specialCharsMap.put("&emdash;", "---");
}
}For controlling how the converted HTML tables are rendered in markdown you can use any of the Formatter table options since formatter is used by the HTML parser to render tables.
Uses the excellent jsoup HTML parsing library and emoji shortcuts using Emoji-Cheat-Sheet.com
Enables ins tagging of text by enclosing it in ++. For example, in hey ++you++, you will be rendered as inserted text.
Use class InsExtension in artifact flexmark-ext-ins.
The following options are available:
Defined in InsExtension class:
Allows rendering of Jekyll {% tag %} with and without parameters.
Use class JekyllTagExtension in artifact flexmark-ext-jekyll-tag.
ℹ️ you can process the include tags and add the content of these files to the INCLUDED_HTML map so that the content is rendered. If the included content starts off as Markdown and may contain references that are used by the document which includes the file, then you can transfer the references from the included document to the including document using the Parser.transferReferences(Document, Document). See: JekyllIncludeFileSample.java
The following options are available:
Defined in JekyllTagExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ENABLE_INLINE_TAGS | true | parse inline tags. |
| ENABLE_BLOCK_TAGS | true | parse block tags. |
| ENABLE_RENDERING | false | render tags as text |
| INCLUDED_HTML | (Map<String, String>)null | map of include tag parameter string to HTML content to be used to replace the tag element in rendering |
| LIST_INCLUDES_ONLY | true | only add includes tags to TAG_LIST if true, else add all tags |
| TAG_LIST | new ArrayList<JekyllTag>() | list of all jekyll tags in the document |
Allows rendering of the markdown AST as JIRA formatted text
Use class JiraConverterExtension in artifact flexmark-jira-converter.
No options are defined. Extensions that do no support JIRA formatting will not generate any output for their corresponding nodes.
Macro Definitions are block elements which can contain any markdown element(s) but can be expanded in a block or inline context, allowing block elements to be used where only inline elements are permitted by the syntax. Macros Extension
Use class MacroExtension in artifact flexmark-ext-macros.
Media link transformer extension courtesy Cornelia Schultz (GitHub @CorneliaXaos) transforms links using custom prefixes to Audio, Embed, Picture, and Video HTML5 tags.
Use class MediaTagsExtension in artifact flexmark-ext-media-tags.
No options are defined.
Adds image size syntax to image URL.  where =WxH is the width and height attribute values for the image, px suffix will be added to the numerical values.
Use class ResizableImageExtension in artifact flexmark-ext-resizable-image.
No options are defined.
⚠️ This extension is a user contribution and will not be supported in the future. Its implementation does not follow the flexmark-java parser extension model, it does not implement any renderers other than HTML and does not provide any text details of the source elements in its AST.
Use at your own discretion.
Parses the flexmark extended spec examples into example nodes with particulars broken and many rendering options. Otherwise these parse as fenced code. Flexmark Spec Example Extension
This extension is used by Markdown Navigator plugin for JetBrains IDEs to facilitate work with flexmark-java test spec files.
Enables ins tagging of text by enclosing it in ^. For example, in hey ^you^, you will be rendered as superscript text.
Use class SuperscriptExtension in artifact flexmark-ext-superscript.
The following options are available:
Defined in SuperscriptExtension class:
Enables tables using pipes as in GitHub Flavored Markdown. With added options to handle column span syntax, ability to have more than one header row, disparate column numbers between rows, etc. Tables Extension
Table of contents extension is really two extensions in one: [TOC] element which renders a table of contents and a simulated [TOC]:# element which also renders a table of contents but is also intended for post processors that will append a table of contents after the element. Resulting in a source file with a table of contents element which will render on any markdown processor.
Use class TocExtension or SimTocExtension in artifact flexmark-ext-toc.
For details see Table of Contents Extension
Converts plain text to typographic characters. Typographic Extension
Enables wiki links [[page reference]] and optionally wiki images ![[image reference]]
To properly resolve wiki link to URL you will most likely need to implement a custom link resolver to handle the logic of your project. Please see: PegdownCustomLinkResolverOptions
Use class WikiLinkExtension in artifact flexmark-ext-wikilink.
The following options are available:
Defined in WikiLinkExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ALLOW_INLINES | false | to allow delimiter processing in text part when ` |
| DISABLE_RENDERING | false | disables wiki link rendering if true wiki links render the text of the node. Used to parse WikiLinks into the AST but not render them in the HTML |
| IMAGE_LINKS | false | enables wiki image link format ![[]] same as wiki links but with a ! prefix, alt text is same as wiki link text and affected by LINK_FIRST_SYNTAX |
| IMAGE_PREFIX | "" | Prefix to add to the to generated link URL |
| IMAGE_PREFIX_ABSOLUTE | value of IMAGE_PREFIX | Prefix to add to the to generated link URL for absolute wiki links (starting with /) |
| IMAGE_FILE_EXTENSION | "" | Extension to append to generated link URL |
| LINK_FIRST_SYNTAX | false | When two part syntax is used `[[first |
| LINK_PREFIX | "" | Prefix to add to the to generated link URL |
| LINK_PREFIX_ABSOLUTE | value of LINK_PREFIX | Prefix to add to the to generated link URL for absolute wiki links (starting with /) |
| LINK_FILE_EXTENSION | "" | Extension to append to generated link URL |
| LINK_ESCAPE_CHARS | " +/<>" | characters to replace in page ref by replacing them with corresponding characters in LINK_REPLACE_CHARS |
| LINK_REPLACE_CHARS | "-----" | characters to replace in page ref by replacing corresponding characters in LINK_ESCAPE_CHARS |
Application provided macros of the form {{macroName}}content{{/macroName}} or the block macro form:
{{macroName}}
content
{{/macroName}}Use class MacroExtension in artifact flexmark-ext-xwiki-macros.
The following options are available:
Defined in MacroExtension class:
| Static Field | Default Value | Description |
|---|---|---|
| ENABLE_INLINE_MACROS | true | enable inline macro processing |
| ENABLE_BLOCK_MACROS | true | enable block macro processing |
| ENABLE_RENDERING | false | enable rendering of macro nodes as text |
Adds support for metadata through a YAML front matter block. This extension only supports a subset of YAML syntax. Here's an example of what's supported:
---
key: value list: - value 1 - value 2 literal: | this is literal value.
literal values 2
---
document starts hereUse class YamlFrontMatterExtension in artifact flexmark-ext-yaml-front-matter. To fetch metadata, use YamlFrontMatterVisitor.
Allows rendering of the markdown AST as YouTrack formatted text
Use class YouTrackConverterExtension in artifact flexmark-youtrack-converter.
No options are defined. Extensions that do no support YouTrack formatting will not generate any output for their corresponding nodes.
YouTube link transformer extension courtesy Vyacheslav N. Boyko (GitHub @bvn13) transforms simple links to youtube videos to embedded video iframe.
Use class YouTubeLinkExtension in artifact flexmark-ext-youtube-embedded.
No options are defined.
Converts simple links to youtube videos to embedded video HTML code.
Places to Start
Used by: Markdown Navigator
| Back | FazBrowse Home | New Git URL |