Extensions (original) (raw)
Contents
- Configuring Options
- Core
- PDF Output Module
- Available Extensions
- Abbreviation
- Admonition
- AnchorLink
- Aside
- Attributes
- Autolink
- Definition Lists
- Docx Converter
- Emoji
- Enumerated Reference
- Footnotes
- Gfm-Issues
- Gfm-Strikethrough/Subscript
- Gfm-TaskList
- Gfm-Users
- GitLab Flavoured Markdown
- Html To Markdown
- Ins
- Jekyll Tags
- Jira-Converter
- Macros
- Media Tags
- Resizable Image Extension
- Spec Example
- Superscript
- Tables
- Table of Contents
- Typographic
- WikiLinks
- XWiki Macro Extension
- YAML front matter
- YouTrack-Converter
- YouTube Embedded Link Transformer
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):
com.vladsch.flexmark flexmark-all 0.64.8Configure 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();}
Configuring Options
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 theParser or HtmlRenderer.
Data keys are described in their respective extension classes and in Parser andHtmlRenderer.
Core
Core implements parser, Html renderer and formatter functionality for CommonMark markdown elements.
Parser
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:
Parser.ASTERISK_DELIMITER_PROCESSOR: defaulttrueenable asterisk delimiter inline processing.Parser.BLANK_LINES_IN_ASTdefaultfalse, set totrueto include blank line nodes in the AST.Parser.BLOCK_QUOTE_ALLOW_LEADING_SPACE: defaulttrue, whentrueleading spaces before>are allowedParser.BLOCK_QUOTE_EXTEND_TO_BLANK_LINE: defaultfalse, whentrueblock quotes extend to next blank line. Enables more customary block quote parsing than commonmark strict standardParser.BLOCK_QUOTE_IGNORE_BLANK_LINE: defaultfalse, whentrueblock quotes will include blank lines between block quotes and treat them as if the blank lines are also preceded by the block quote markerParser.BLOCK_QUOTE_INTERRUPTS_ITEM_PARAGRAPH: defaulttrue, whentrueblock quotes can interrupt list item text, else need blank line before to be included in list itemsParser.BLOCK_QUOTE_INTERRUPTS_PARAGRAPH: defaulttrue, whentrueblock quote can interrupt a paragraph, else needs blank line beforeParser.BLOCK_QUOTE_PARSER: defaulttrue, whentrueparsing of block quotes is enabledParser.BLOCK_QUOTE_WITH_LEAD_SPACES_INTERRUPTS_ITEM_PARAGRAPH: defaulttrue, whentrueblock quotes with leading spaces can interrupt list item text, else need blank line before or no leading spacesParser.CODE_BLOCK_INDENT, defaultParser.LISTS_ITEM_INDENT, setting which determines how many leading spaces will treat the following text as an indented block.
ℹ️ 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: defaultfalse, set totrueto include soft line break nodes in code blocksParser.CODE_STYLE_HTML_CLOSE: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.CODE_STYLE_HTML_OPEN: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.EMPHASIS_STYLE_HTML_CLOSE: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.EMPHASIS_STYLE_HTML_OPEN: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.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: defaulttrueenable parsing of fenced code blocksParser.FENCED_CODE_CONTENT_BLOCK: defaultfalseaddCodeBlockas child to contain the code of a fenced block. Otherwise the code is contained in aTextnode.Parser.HARD_LINE_BREAK_LIMIT: defaultfalseonly 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: defaulttrueallow headings to interrupt list item paragraphsParser.HEADING_NO_ATX_SPACE: defaultfalseallow headers without a space between#and the header text if trueParser.HEADING_NO_EMPTY_HEADING_WITHOUT_SPACEdefaultfalse, set totrueto not recognize empty headings without a space following#Parser.HEADING_NO_LEAD_SPACE: defaultfalsedo 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: defaulttrueenable parsing of headingsParser.HEADING_SETEXT_MARKER_LENGTH: default1sets the minimum number of-or=needed under a setext heading text before it being recognized as a heading.Parser.HTML_ALLOW_NAME_SPACE: defaultfalse, whentruewill 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: defaultfalse, whentruewill allow embedded HTML comments to interrupt paragraphs.Parser.HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS_PARTIAL_TAGdefaulttrue, when true blank line interrupts partially open tag ie.<TAGwithout a corresponding>and having a blank line blank line before>Parser.HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTSdefaulttrue, whentrueBlank line interrupts HTML block when not in raw tag, otherwise only when closedParser.HTML_BLOCK_DEEP_PARSE_FIRST_OPEN_TAG_ON_ONE_LINEdefaultfalse, whentruedo not parse open tags unless they are contained on one line.Parser.HTML_BLOCK_DEEP_PARSE_INDENTED_CODE_INTERRUPTSdefaultfalse, whentrueIndented code can interrupt HTML block without a preceding blank line.Parser.HTML_BLOCK_DEEP_PARSE_MARKDOWN_INTERRUPTS_CLOSEDdefaultfalse, whentrueOther markdown elements can interrupt a closed HTML block without an intervening blank lineParser.HTML_BLOCK_DEEP_PARSE_NON_BLOCKdefaulttrue, parse non-block tags inside HTML blocksParser.HTML_BLOCK_DEEP_PARSERdefaultfalse- enable deep HTML block parsingParser.HTML_BLOCK_PARSER: defaulttrueenable parsing of html blocksParser.HTML_BLOCK_START_ONLY_ON_BLOCK_TAGS, default for deep html parser istrueand regular parserfalse, but you can set your desired specific value and override the default. Whentruewill not start an HTML block on a non-block tag, whenfalseany 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 tagsParser.HTML_COMMENT_BLOCKS_INTERRUPT_PARAGRAPH: defaulttrueenables HTML comments to interrupt paragraphs, otherwise comment to be interpreted as HTML blocks need a blank line before.Parser.HTML_FOR_TRANSLATOR: defaultfalse, whentruethe parser is modified to allow translator placeholders to be recognizedParser.INDENTED_CODE_BLOCK_PARSER: defaulttrueenable parsing of indented code blockParser.INDENTED_CODE_NO_TRAILING_BLANK_LINES: defaulttrueenable removing trailing blank lines from indented code blocksParser.INLINE_DELIMITER_DIRECTIONAL_PUNCTUATIONSdefaultfalse, set totrueto use delimiter parsing rules that take bracket open/close into accountParser.INTELLIJ_DUMMY_IDENTIFIER: defaultfalseadd'\u001f'to all parse patterns as an allowable character, used by plugin to allow for IntelliJ completion location markerParser.LINKS_ALLOW_MATCHED_PARENTHESES: defaulttrue, whenfalseuses spec 0.27 rules for link addresses and does not resolve matched()Parser.LIST_BLOCK_PARSER: defaulttrueenable parsing of listsParser.LIST_REMOVE_EMPTY_ITEMS, defaultfalse. Iftruethen empty list items or list items which only contain aBlankLinenode are removed from the output.Parser.LISTS_END_ON_DOUBLE_BLANK: defaultfalse, whentruelists 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 itemParser.LISTS_LOOSE_WHEN_CONTAINS_BLANK_LINE: defaultfalse, whentruea 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: defaultfalse, whentruewill consider a list with last item followed by blank line as a loose list.Parser.MATCH_CLOSING_FENCE_CHARACTERS: defaulttruewhether 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: defaulttruecustom link ref processors that take tested[]have priority over ones that do not. ie.[[^f]][test]is a wiki link with^fas page ref followed by ref linktestwhen this option is true. IF false then the same would be a ref linktestwith a footnote^frefernce for textParser.PARSE_INNER_HTML_COMMENTS: defaultfalsewhentruewill parse inner HTML comments in HTML blocksParser.PARSE_JEKYLL_MACROS_IN_URLSdefaultfalse, set totrueto allow any characters to appear between{{and}}in URLs, including spaces, pipes and backslashesParser.PARSE_MULTI_LINE_IMAGE_URLS: defaultfalseallows parsing of multi line urls:Parser.PARSER_EMULATION_PROFILEdefaultParserEmulationProfile.COMMONMARK, set to desired one of theParserEmulationProfilevaluesParser.REFERENCE_PARAGRAPH_PRE_PROCESSOR: defaulttrueenable parsing of reference definitionsParser.REFERENCES_KEEP: defaultKeepType.FIRSTwhich duplicates to keep.Parser.REFERENCES: default new repository repository for document's reference definitionsParser.SPACE_IN_LINK_ELEMENTSdefaultfalse, set totrueto allow whitespace between![]or[]and()of links or images.Parser.SPACE_IN_LINK_URLS: defaultfalsewill accept spaces in link address as long as they are not followed by"Parser.STRONG_EMPHASIS_STYLE_HTML_CLOSE: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.STRONG_EMPHASIS_STYLE_HTML_OPEN: default(String)nulloverride HTML to use for wrapping style, if null then no overrideParser.STRONG_WRAPS_EMPHASIS: defaultfalse, whentrueuses spec 0.27 rules for emphasis/strong resolutionParser.THEMATIC_BREAK_PARSER: defaulttrueenable parsing of thematic breaksParser.THEMATIC_BREAK_RELAXED_START: defaulttrueenable parsing of thematic breaks which are not preceded by a blank lineParser.TRACK_DOCUMENT_LINESdefaultfalse. Whentruedocument lines are tracked in the document'slineSegmentslist and offset to line method can be used to get the 0-based line number for the given offset. Whenfalsethese functions compute the line number by counting EOL sequences before the offset.Parser.UNDERSCORE_DELIMITER_PROCESSOR: defaulttruewhether to process underscore delimitersParser.USE_HARDCODED_LINK_ADDRESS_PARSER: defaulttrue, whenfalseuses regex for link address parsing, which causesStackOverflowErrorfor long URLsParser.WWW_AUTO_LINK_ELEMENT: defaultfalse, whentruewww.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 causeStackOverflowError 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 |
List Parsing Options
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:
- the recommended way is to apply
ParserEmulationProfileto options viaMutableDataHolder.setFrom(ParserEmulationProfile)to have all options configured for a particular parser. - start with the
ParserEmulationProfile.getOptions()and modify defaults for the family and then pass it toMutableDataHolder.setFrom(MutableDataSetter) - by configuring an instance of
MutableListOptionsand then passing it toMutableDataHolder.setFrom(MutableDataSetter) - first via individual keys
List Item Options
Parser.LISTS_CODE_INDENT: default4, can be the same as LISTS_ITEM_INDENT or double that for parser emulation families which count indentation from first list item indentParser.LISTS_ITEM_INDENT: default4, is also the INDENTED CODE INDENT. Parser emulation family either does not use this or expects it to be the number of columns to next indent item (in this case indented code is the same)Parser.LISTS_NEW_ITEM_CODE_INDENT: default4, new item with content indent >= this value causes an empty item with code indent child, weird standard, so far only for CommonMark- empty list items require explicit space after marker
Parser.LISTS_ITEM_MARKER_SPACE,ListOptions.itemMarkerSpace - mismatch item type starts a new list:
Parser.LISTS_ITEM_TYPE_MISMATCH_TO_NEW_LIST,ListOptions.itemTypeMismatchToNewList - mismatch item type start a sub-list:
Parser.LISTS_ITEM_TYPE_MISMATCH_TO_SUB_LIST,ListOptions.itemTypeMismatchToSubList - bullet or ordered item delimiter mismatch starts a new list:
Parser.LISTS_DELIMITER_MISMATCH_TO_NEW_LIST,ListOptions.delimiterMismatchToNewList - ordered items only with
.after digit, otherwise)is also allowed:Parser.LISTS_ORDERED_ITEM_DOT_ONLY,ListOptions.orderedItemDotOnly - first ordered item prefix sets start number of list:
Parser.LISTS_ORDERED_LIST_MANUAL_START,ListOptions.orderedListManualStart - item is loose if it contains a blank line after its item text:
Parser.LISTS_LOOSE_WHEN_BLANK_LINE_FOLLOWS_ITEM_PARAGRAPH,ListOptions.looseWhenBlankLineFollowsItemParagraph - item is loose if it is first item and has trailing blank line or if previous item has a trailing blank line:
Parser.LISTS_LOOSE_WHEN_PREV_HAS_TRAILING_BLANK_LINE,ListOptions.looseWhenPrevHasTrailingBlankLine - item is loose if it has loose sub-item:
Parser.LISTS_LOOSE_WHEN_HAS_LOOSE_SUB_ITEM,ListOptions.looseWhenHasLooseSubItem - item is loose if it has trailing blank line in it or its last child:
Parser.LISTS_LOOSE_WHEN_HAS_TRAILING_BLANK_LINE,ListOptions.looseWhenHasTrailingBlankLine - item is loose if it has non-list children:
Parser.LISTS_LOOSE_WHEN_HAS_NON_LIST_CHILDREN,ListOptions.looseWhenHasNonListChildren - all items are loose if any in the list are loose:
Parser.LISTS_AUTO_LOOSE,ListOptions.autoLoose - auto loose list setting
Parser.LISTS_AUTO_LOOSEonly applies to simple 1 level lists:Parser.LISTS_AUTO_LOOSE_ONE_LEVEL_LISTS,ListOptions.autoLooseOneLevelLists - list item marker suffixes, content indent computed after suffix:
Parser.LISTS_ITEM_MARKER_SUFFIXES,ListOptions.itemMarkerSuffixes - list item marker suffixes apply to numbered items:
Parser.LISTS_NUMBERED_ITEM_MARKER_SUFFIXED,ListOptions.numberedItemMarkerSuffixed - list item marker suffixes are not used to affect indent offset for child items:
Parser.LISTS_ITEM_CONTENT_AFTER_SUFFIX, defaultfalse, set totrueto treat the item suffix as part of the list item marker after which the content begins for indentation purposes. Gfm Task List uses the default setting. Parser.LISTS_AUTO_LOOSE_ONE_LEVEL_LISTS, defaultfalse, whentruewill determine looseness of list item by its content, otherwise will use looseness of contained listsParser.LISTS_LOOSE_WHEN_LAST_ITEM_PREV_HAS_TRAILING_BLANK_LINE, defaultfalse, whentruea last list item which is preceded by a blank line will be marked as loose item.Parser.LISTS_LOOSE_WHEN_CONTAINS_BLANK_LINE, defaultfalse, whentruean item will be marked as loose if it contains a blank lineParser.LISTS_ITEM_PREFIX_CHARS, default"*-+", set to allowed list item prefixes
⚠️ If both LISTS_ITEM_TYPE_MISMATCH_TO_NEW_LIST andLISTS_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.
List Item Paragraph Interruption Options
- bullet item can interrupt a paragraph:
Parser.LISTS_BULLET_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.bulletItemInterruptsParagraph - ordered item can interrupt a paragraph:
Parser.LISTS_ORDERED_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.orderedItemInterruptsParagraph - ordered non 1 item can interrupt a paragraph:
Parser.LISTS_ORDERED_NON_ONE_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.orderedNonOneItemInterruptsParagraph - empty bullet item can interrupt a paragraph:
Parser.LISTS_EMPTY_BULLET_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.emptyBulletItemInterruptsParagraph - empty ordered item can interrupt a paragraph:
Parser.LISTS_EMPTY_ORDERED_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedItemInterruptsParagraph - empty ordered non 1 item can interrupt a paragraph:
Parser.LISTS_EMPTY_ORDERED_NON_ONE_ITEM_INTERRUPTS_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedNonOneItemInterruptsParagraph - bullet item can interrupt a paragraph of a list item:
Parser.LISTS_BULLET_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.bulletItemInterruptsItemParagraph - ordered item can interrupt a paragraph of a list item:
Parser.LISTS_ORDERED_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.orderedItemInterruptsItemParagraph - ordered non 1 item can interrupt a paragraph of a list item:
Parser.LISTS_ORDERED_NON_ONE_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.orderedNonOneItemInterruptsItemParagraph - empty bullet item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_BULLET_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyBulletItemInterruptsItemParagraph - empty ordered non 1 item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_ORDERED_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedItemInterruptsItemParagraph - empty ordered item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_ORDERED_NON_ONE_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedNonOneItemInterruptsItemParagraph - empty bullet sub-item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_BULLET_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyBulletSubItemInterruptsItemParagraph - empty ordered non 1 sub-item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_ORDERED_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedSubItemInterruptsItemParagraph - empty ordered sub-item can interrupt a paragraph of a list item:
Parser.LISTS_EMPTY_ORDERED_NON_ONE_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH,ListOptions.itemInterrupt.emptyOrderedNonOneSubItemInterruptsItemParagraph
Renderer
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:
AUTOLINK_WWW_PREFIX: default"http://"prefix to add to autolink if it starts withwww.CODE_STYLE_HTML_CLOSEdefault ``(String) null, custom inline code close HTMLCODE_STYLE_HTML_OPENdefault(String) null, custom inline code open HTMLDO_NOT_RENDER_LINKSdefaultfalse, Disable link rendering in the document. This will cause sub-contexts to also have link rendering disabled.EMPHASIS_STYLE_HTML_CLOSEdefault(String) null, custom emphasis close HTMLEMPHASIS_STYLE_HTML_OPENdefault(String) null, custom emphasis open HTMLESCAPE_HTML_BLOCKSdefault value ofESCAPE_HTML, escape html blocks found in the documentESCAPE_HTML_COMMENT_BLOCKSdefault value ofESCAPE_HTML_BLOCKS, escape html comment blocks found in the document.ESCAPE_HTMLdefaultfalse, escape all html found in the documentESCAPE_INLINE_HTML_COMMENTSdefault value ofESCAPE_HTML_BLOCKS, escape inline html found in the documentESCAPE_INLINE_HTMLdefault value ofESCAPE_HTML, escape inline html found in the documentFENCED_CODE_LANGUAGE_CLASS_MAP, defaultnew HashMap(), provides individual language to class mapping string. If language string is not in the map thenFENCED_CODE_LANGUAGE_CLASS_PREFIX+ language will be used.FENCED_CODE_LANGUAGE_CLASS_PREFIXdefault"language-", prefix used for generating the<code>class for a fenced code block, only used if info is not empty and language is not defined inFENCED_CODE_LANGUAGE_CLASS_MAPFENCED_CODE_NO_LANGUAGE_CLASSdefault"",<code>class for<code>tag of indented code or fenced code block without info (language) specificationFORMAT_FLAGSdefault0, Flags used forFormattingAppendableused for rendering HTMLGENERATE_HEADER_IDdefaultfalse, Generate a header id attribute using the configuredHtmlIdGeneratorbut not render it. The id may be used by another element such as an anchor link.HARD_BREAKdefault"<br />\n", string to use for rendering hard breaksHEADER_ID_ADD_EMOJI_SHORTCUT, defaultfalse. When set totrue, emoji shortcut nodes add the shortcut to collected text used to generate heading id.HEADER_ID_GENERATOR_NO_DUPED_DASHESdefaultfalse, Whentrueduplicate-in id will be replaced by a single-HEADER_ID_GENERATOR_NON_ASCII_TO_LOWERCASE, defaulttrue. When set tofalsechanges the default header id generator to not convert non-ascii alphabetic characters to lowercase. Needed forGitHubid compatibility.HEADER_ID_GENERATOR_RESOLVE_DUPESdefaulttrue, Whentruewill add an incrementing integer to duplicate ids to make them uniqueHEADER_ID_GENERATOR_TO_DASH_CHARSdefault"_", set of characters to convert to-in text used to generate id, non-alpha numeric chars not in set will be removedHEADER_ID_REF_TEXT_TRIM_LEADING_SPACES, defaulttrue. When set tofalsethen leading spaces in link reference text in heading is not trimmed for text used to generate id.HEADER_ID_REF_TEXT_TRIM_TRAILING_SPACES, defaulttrue. When set tofalsethen trailing spaces in link reference text in heading is not trimmed for text used to generate id.HTML_BLOCK_CLOSE_TAG_EOLdefaulttrue, Whenfalsewill suppress EOL after HTML block tags which are automatically generated during html rendering.HTML_BLOCK_OPEN_TAG_EOLdefaulttrue, Whenfalsewill suppress EOL before HTML block tags which are automatically generated during html rendering.INDENT_SIZEdefault0, how many spaces to use for each indent level of nested tagsINLINE_CODE_SPLICE_CLASSdefault(String) null, used for splitting and splicing inline code spans for source line trackingMAX_TRAILING_BLANK_LINESdefault1, Maximum allowed trailing blank lines for rendered HTMLOBFUSCATE_EMAIL_RANDOMdefaulttrue, Whenfalsewill not use random number generator for obfuscation. Used for testsOBFUSCATE_EMAILdefaultfalse, Whentruewill obfuscatemailtolinksPERCENT_ENCODE_URLSdefaultfalse, percent encode urlsRECHECK_UNDEFINED_REFERENCESdefaultfalse, Recheck the existence of refences inParser.REFERENCESfor link and image refs marked undefined. Used when new references are added after parsingRENDER_HEADER_IDdefaultfalse, Render a header id attribute for headers using the configuredHtmlIdGeneratorSOFT_BREAKdefault"\n", string to use for rendering soft breaksSOURCE_POSITION_ATTRIBUTEdefault"", name of the source position HTML attribute, source position is assigned asstartOffset + '-' + endOffsetSOURCE_POSITION_PARAGRAPH_LINESdefaultfalse, if true enables wrapping individual paragraph source lines inspanwith source position attribute setSOURCE_WRAP_HTML_BLOCKSdefault value of SOURCE_WRAP_HTML, if generating source position attribute, then wrap HTML blocks indivwith source positionSOURCE_WRAP_HTMLdefaultfalse, if generating source position attribute, then wrap HTML with source positionSTRONG_EMPHASIS_STYLE_HTML_CLOSEdefault(String) null, custom strong emphasis close HTMLSTRONG_EMPHASIS_STYLE_HTML_OPENdefault(String) null, custom strong emphasis open HTMLSUPPRESS_HTML_BLOCKSdefault value ofSUPPRESS_HTML, suppress html output for html blocksSUPPRESS_HTML_COMMENT_BLOCKSdefault value ofSUPPRESS_HTML_BLOCKS, suppress html output for html comment blocksSUPPRESS_HTMLdefaultfalse, suppress html output for all htmlSUPPRESS_INLINE_HTML_COMMENTSdefault value ofSUPPRESS_INLINE_HTML, suppress html output for inline html commentsSUPPRESS_INLINE_HTMLdefault value ofSUPPRESS_HTML, suppress html output for inline htmlSUPPRESS_LINKSdefault value of"javascript:.*", a regular expression to suppress any links that match. The test occurs before the link is resolved using a link resolver. Therefore any link matching will be suppressed before it is resolved. Likewise, a link resolver returning a suppressed link will not be suppressed since this is up to the custom link resolver to handle.
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.
TYPEdefault"HTML", renderer type. Renderer type extensions can add their own.JiraConverterExtensiondefinesJIRAUNESCAPE_HTML_ENTITIESdefaulttrue, Whenfalsewill leave HTML entities as is in the rendered HTML.
❗ 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
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 inflexmark-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
PDF Output Module
HTML to PDF conversion is done using Open HTML To PDF library by PdfConverterExtension inflexmark-pdf-converter module.
Available Extensions
The following extensions are developed with this library, each in their own artifact.
Extension options are defined in their extension class.
Abbreviation
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 instead of tags for rendering html |
| ABBREVIATIONS_PLACEMENT | ElementPlacement.AS_IS | formatting option see: Markdown Formatter |
| ABBREVIATIONS_SORT | ElementPlacement.AS_IS | formatting option see: Markdown Formatter |
Admonition
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.
CSS and JavaScript must be included in your page
Default CSS and JavaScript are contained in the jar as resources:
Their content is also available by calling AdmonitionExtension.getDefaultCSS() andAdmonitionExtension.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.
AnchorLink
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 totrue 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 |
Aside
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_ toAsideExtension key name to get Parser block quote key name).
⚠️ This can potentially break code relying on versions of the extension before 0.40.20because 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)
Attributes
Converts attributes {...} syntax into attributes AST nodes and adds an attribute provider to set attributes for immediately preceding sibling element during HTML rendering. SeeAttributes Extension
Defined in AttributeExtension from artifact flexmark-ext-attributes
ASSIGN_TEXT_ATTRIBUTES, defaulttrue. Whenfalseattribute assignment rules to nodes are changed not to allow text elements to get attributes.FENCED_CODE_INFO_ATTRIBUTES, defaulttrue. Whenfalseattribute assignment at end of fenced code info string will be ignored.USE_EMPTY_IMPLICIT_AS_SPAN_DELIMITER, defaultfalse. When set totruewill 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
Autolink
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:
IGNORE_LINKS, default"", a regex expression to match link text which should not be auto-linked. This can include full urls likewww.google.comor parts by including wildcard match patterns. Any recognized auto-link which matches the expression will be rendered as text.
Definition Lists
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
Docx Converter
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
Emoji
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:
ATTR_ALIGN, default"absmiddle", attributes to use for rendering in the absence of attribute provider overridesATTR_IMAGE_SIZE, default"20", attributes to use for rendering in the absence of attribute provider overridesATTR_IMAGE_CLASS, default"", if not empty will set the image tag class attribute to this value.ROOT_IMAGE_PATH, default"/img/", root path for emoji image files. SeeEmoji-Cheat-Sheet.com GitHub Repository repository for image files located inpublic/graphics/emojisdirectory.USE_UNICODE_FILE_NAMES, defaultfalse. When true will useunicodeSampleFilefield forEmoji Cheat Sheetimage file name, if available. This is to support implementations which rely on the file renaming done by emoji-cross-reference when copying emoji cheat sheet images to commonemoji_images/emojisdirectory.USE_SHORTCUT_TYPE, defaultEmojiShortcutType.EMOJI_CHEAT_SHEET, select type of shortcuts:EmojiShortcutType.EMOJI_CHEAT_SHEETEmojiShortcutType.GITHUBEmojiShortcutType.ANY_EMOJI_CHEAT_SHEET_PREFERREDuse any shortcut from any source. If image type options is notUNICODE_ONLY, will generate links to Emoji Cheat Sheet files or GitHub URL, with preference given to Emoji Cheat Sheet files.EmojiShortcutType.ANY_GITHUB_PREFERRED- use any shortcut from any source. If image type options is notUNICODE_ONLY, will generate links to Emoji Cheat Sheet files or GitHub URL, with preference given to GitHub URL.
USE_IMAGE_TYPE, defaultEmojiImageType.IMAGE_ONLY, to select what type of images are allowed.EmojiImageType.IMAGE_ONLY, only use image linkEmojiImageType.UNICODE_ONLYconvert to unicode and if there is no unicode treat as invalid emoji shortcutEmojiImageType.UNICODE_FALLBACK_TO_IMAGEconvert to unicode and if no unicode use image. emoji shortcuts using Emoji-Cheat-Sheet.com https://www.webfx.com/tools/emoji-cheat-sheet
Enumerated Reference
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.
Footnotes
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.
Gfm-Issues
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:
GIT_HUB_ISSUES_URL_ROOT: default"issues"override root used for generating the URLGIT_HUB_ISSUE_URL_PREFIX: default"/"override prefix used for appending the issue number to URLGIT_HUB_ISSUE_URL_SUFFIX: default""override suffix used for appending the issue number to URLGIT_HUB_ISSUE_HTML_PREFIX: default""override HTML to use as prefix for the issue textGIT_HUB_ISSUE_HTML_SUFFIX: default""override HTML to use as suffix for the issue text
Gfm-Strikethrough/Subscript
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:
STRIKETHROUGH_STYLE_HTML_OPEN: default(String)nulloverride HTML to use for wrapping style, if null then no overrideSTRIKETHROUGH_STYLE_HTML_CLOSE: default(String)nulloverride HTML to use for wrapping style, if null then no overrideSUBSCRIPT_STYLE_HTML_OPEN: default(String)nulloverride HTML to use for wrapping style, if null then no overrideSUBSCRIPT_STYLE_HTML_CLOSE: default(String)nulloverride HTML to use for wrapping style, if null then no override
Gfm-TaskList
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 | string to use for the item done marker html. | |
| ITEM_NOT_DONE_MARKER | 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 |
TaskListItemCaseAS_IS: no changeLOWERCASE: change[X]to[x]UPPERCASE: change[x]to[X]
TaskListItemPlacementAS_IS: no changeINCOMPLETE_FIRST: sort all lists to put incomplete task items firstINCOMPLETE_NESTED_FIRST: sort all lists to put incomplete task items or items with incomplete task sub-items firstCOMPLETE_TO_NON_TASK: sort all lists to put incomplete task items first and change complete task items to non-task itemsCOMPLETE_NESTED_TO_NON_TASK: sort all lists to put incomplete task items or items with incomplete task sub-items first and change complete task items to non-task items
Gfm-Users
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:
GIT_HUB_USERS_URL_ROOT: default"https://github.com"override root used for generating the URLGIT_HUB_USER_URL_PREFIX: default"/"override prefix used for appending the user name to URLGIT_HUB_USER_URL_SUFFIX: default""override suffix used for appending the user name to URLGIT_HUB_USER_HTML_PREFIX: default"<strong>"override HTML to use as prefix for the user name textGIT_HUB_USER_HTML_SUFFIX: default"</strong>"override HTML to use as suffix for the user name text
GitLab Flavoured Markdown
Parses and rendersGitLab 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
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">``</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘‘</span></span></span></span>or as fenced code withmathinfo string requiring inclusion of Katex in the rendered HTML page. - Graphing via Mermaid as fenced code with
mermaidinfo 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: defaulttrue, enable ins parserDEL_PARSER: defaulttrue, enable del parserBLOCK_QUOTE_PARSER: defaulttrue, enable multi-line block quote parserINLINE_MATH_PARSER: defaulttrue, enable inline math parserRENDER_BLOCK_MATH: defaulttrue, enable rendering math fenced code blocks as math elementsRENDER_BLOCK_MERMAID: defaulttrue, enable rendering mermaid fenced code blocks as mermaid elementsRENDER_VIDEO_IMAGES: defaulttrue, enable rendering image links with video extensions as video elementsRENDER_VIDEO_LINK: defaulttrue, enable rendering video link with video imagesINLINE_MATH_CLASS: default"katex", inline math class attributeBLOCK_MATH_CLASS: default"katex"block math class attributeBLOCK_MERMAID_CLASS: default"mermaid"block mermaid class attributeVIDEO_IMAGE_CLASS: default"video-container"class attributeVIDEO_IMAGE_LINK_TEXT_FORMAT: default"Download '%s'"format for video link text,%sreplaced with image alt textBLOCK_INFO_DELIMITERS: default" ", delimiters used for extracting math and mermaid strings from fenced code info stringVIDEO_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 ofKatex 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:
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: