Package com.vladsch.flexmark.parser
Class Parser
java.lang.Object
com.vladsch.flexmark.parser.Parser
- All Implemented Interfaces:
IParse
Parses input text to a tree of nodes.
Start with the builder()
method, configure the parser and build it. Example:
Parser parser = Parser.builder().build();
Node document = parser.parse("input text");
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<CustomBlockParserFactory>
private final List<List<BlockPreProcessorFactory>>
private final BitSet
private final Map<Character,
DelimiterProcessor> static final DataKey<Collection<Extension>>
Name spaces are allowed in HTML elements, default false for backward compatibilityBlank line interrupts HTML block when not in raw tag, otherwise only when closedblank line interrupts partially open tag ie.open tags must be contained on one lineIndented code can interrupt HTML blockOther markdown elements can interrupt a closed block without an intervening blank lineprivate final List<InlineParserExtensionFactory>
private final InlineParserFactory
private final LinkRefProcessorData
LINKS_ALLOW_MATCHED_PARENTHESES default true, when false makes parsing CommonMark Spec 0.27 compliantprivate final @NotNull DataHolder
private final List<List<ParagraphPreProcessorFactory>>
static final DataKey<ParserEmulationProfile>
private final List<PostProcessorManager.PostProcessorDependencyStage>
static final DataKey<ReferenceRepository>
static final DataKey<List<SpecialLeadInHandler>>
private final BitSet
STRONG_WRAPS_EMPHASIS default false, when true makes parsing CommonMark Spec 0.27 compliantUsed by formatter for translation parsing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MutableDataHolder
addExtensions
(MutableDataHolder options, Extension... extensions) Add extension(s) to the extension liststatic Parser.Builder
builder()
Create a new builder for configuring aParser
.static Parser.Builder
builder
(DataHolder options) @NotNull DataHolder
Get Options for parsing@NotNull Document
parse
(@NotNull BasedSequence input) Parse the specified input text into a tree of nodes.@NotNull Document
Parse the specified input text into a tree of nodes.@NotNull Document
parseReader
(@NotNull Reader input) Parse the specified reader into a tree of nodes.private Document
postProcess
(Document document) static MutableDataHolder
removeExtensions
(MutableDataHolder options, Class... extensions) Remove extension(s) of given class from the extension listboolean
transferReferences
(@NotNull Document document, @NotNull Document included, Boolean onlyIfUndefined) Transfer reference definition between documentsstatic <T extends Node>
booleantransferReferences
(NodeRepository<T> destination, NodeRepository<T> included, boolean onlyIfUndefined)
-
Field Details
-
EXTENSIONS
-
REFERENCES_KEEP
-
REFERENCES
-
ASTERISK_DELIMITER_PROCESSOR
-
TRACK_DOCUMENT_LINES
-
BLOCK_QUOTE_PARSER
-
BLOCK_QUOTE_EXTEND_TO_BLANK_LINE
-
BLOCK_QUOTE_IGNORE_BLANK_LINE
-
BLOCK_QUOTE_ALLOW_LEADING_SPACE
-
BLOCK_QUOTE_INTERRUPTS_PARAGRAPH
-
BLOCK_QUOTE_INTERRUPTS_ITEM_PARAGRAPH
-
BLOCK_QUOTE_WITH_LEAD_SPACES_INTERRUPTS_ITEM_PARAGRAPH
-
FENCED_CODE_BLOCK_PARSER
-
MATCH_CLOSING_FENCE_CHARACTERS
-
FENCED_CODE_CONTENT_BLOCK
-
CODE_SOFT_LINE_BREAKS
-
HARD_LINE_BREAK_LIMIT
-
HEADING_PARSER
-
HEADING_SETEXT_MARKER_LENGTH
-
HEADING_NO_ATX_SPACE
-
ESCAPE_HEADING_NO_ATX_SPACE
-
HEADING_NO_EMPTY_HEADING_WITHOUT_SPACE
-
HEADING_NO_LEAD_SPACE
-
HEADING_CAN_INTERRUPT_ITEM_PARAGRAPH
-
HTML_BLOCK_PARSER
-
HTML_COMMENT_BLOCKS_INTERRUPT_PARAGRAPH
-
HTML_FOR_TRANSLATOR
-
INLINE_DELIMITER_DIRECTIONAL_PUNCTUATIONS
-
INDENTED_CODE_BLOCK_PARSER
-
INDENTED_CODE_NO_TRAILING_BLANK_LINES
-
INTELLIJ_DUMMY_IDENTIFIER
-
MATCH_NESTED_LINK_REFS_FIRST
-
PARSE_INNER_HTML_COMMENTS
-
PARSE_MULTI_LINE_IMAGE_URLS
-
PARSE_JEKYLL_MACROS_IN_URLS
-
SPACE_IN_LINK_URLS
-
SPACE_IN_LINK_ELEMENTS
-
WWW_AUTO_LINK_ELEMENT
-
LINK_TEXT_PRIORITY_OVER_LINK_REF
-
REFERENCE_PARAGRAPH_PRE_PROCESSOR
-
THEMATIC_BREAK_PARSER
-
THEMATIC_BREAK_RELAXED_START
-
UNDERSCORE_DELIMITER_PROCESSOR
-
BLANK_LINES_IN_AST
-
USE_HARDCODED_LINK_ADDRESS_PARSER
-
STRONG_WRAPS_EMPHASIS
STRONG_WRAPS_EMPHASIS default false, when true makes parsing CommonMark Spec 0.27 compliant -
LINKS_ALLOW_MATCHED_PARENTHESES
LINKS_ALLOW_MATCHED_PARENTHESES default true, when false makes parsing CommonMark Spec 0.27 compliant -
LIST_BLOCK_PARSER
-
PARSER_EMULATION_PROFILE
-
HTML_BLOCK_DEEP_PARSER
-
HTML_BLOCK_DEEP_PARSE_NON_BLOCK
-
HTML_BLOCK_COMMENT_ONLY_FULL_LINE
-
HTML_BLOCK_START_ONLY_ON_BLOCK_TAGS
-
HTML_BLOCK_TAGS
-
HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS
Blank line interrupts HTML block when not in raw tag, otherwise only when closed -
HTML_BLOCK_DEEP_PARSE_FIRST_OPEN_TAG_ON_ONE_LINE
open tags must be contained on one line -
HTML_BLOCK_DEEP_PARSE_MARKDOWN_INTERRUPTS_CLOSED
Other markdown elements can interrupt a closed block without an intervening blank line -
HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS_PARTIAL_TAG
blank line interrupts partially open tag ie. <TAG without a corresponding > -
HTML_BLOCK_DEEP_PARSE_INDENTED_CODE_INTERRUPTS
Indented code can interrupt HTML block -
HTML_ALLOW_NAME_SPACE
Name spaces are allowed in HTML elements, default false for backward compatibility -
TRANSLATION_HTML_BLOCK_TAG_PATTERN
Used by formatter for translation parsing -
TRANSLATION_HTML_INLINE_TAG_PATTERN
-
TRANSLATION_AUTOLINK_TAG_PATTERN
-
LISTS_CODE_INDENT
-
LISTS_ITEM_INDENT
-
LISTS_NEW_ITEM_CODE_INDENT
-
LISTS_ITEM_MARKER_SPACE
-
LISTS_ITEM_MARKER_SUFFIXES
-
LISTS_NUMBERED_ITEM_MARKER_SUFFIXED
-
LISTS_AUTO_LOOSE
-
LISTS_AUTO_LOOSE_ONE_LEVEL_LISTS
-
LISTS_LOOSE_WHEN_PREV_HAS_TRAILING_BLANK_LINE
-
LISTS_LOOSE_WHEN_LAST_ITEM_PREV_HAS_TRAILING_BLANK_LINE
-
LISTS_LOOSE_WHEN_HAS_NON_LIST_CHILDREN
-
LISTS_LOOSE_WHEN_BLANK_LINE_FOLLOWS_ITEM_PARAGRAPH
-
LISTS_LOOSE_WHEN_HAS_LOOSE_SUB_ITEM
-
LISTS_LOOSE_WHEN_HAS_TRAILING_BLANK_LINE
-
LISTS_LOOSE_WHEN_CONTAINS_BLANK_LINE
-
LISTS_DELIMITER_MISMATCH_TO_NEW_LIST
-
LISTS_END_ON_DOUBLE_BLANK
-
LISTS_ITEM_TYPE_MISMATCH_TO_NEW_LIST
-
LISTS_ITEM_TYPE_MISMATCH_TO_SUB_LIST
-
LISTS_ORDERED_ITEM_DOT_ONLY
-
LISTS_ORDERED_LIST_MANUAL_START
-
LISTS_ITEM_CONTENT_AFTER_SUFFIX
-
LISTS_BULLET_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_ORDERED_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_ORDERED_NON_ONE_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_EMPTY_BULLET_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_EMPTY_ORDERED_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_EMPTY_ORDERED_NON_ONE_ITEM_INTERRUPTS_PARAGRAPH
-
LISTS_BULLET_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_ORDERED_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_ORDERED_NON_ONE_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_BULLET_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_ORDERED_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_ORDERED_NON_ONE_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_BULLET_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_ORDERED_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_EMPTY_ORDERED_NON_ONE_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH
-
LISTS_ITEM_PREFIX_CHARS
-
SPECIAL_LEAD_IN_HANDLERS
-
CODE_BLOCK_INDENT
-
blockParserFactories
-
delimiterProcessors
-
delimiterCharacters
-
specialCharacters
-
postProcessorDependencies
-
paragraphPreProcessorFactories
-
blockPreProcessorDependencies
-
linkRefProcessors
-
inlineParserExtensionFactories
-
inlineParserFactory
-
options
-
-
Constructor Details
-
Parser
Parser(Parser.Builder builder)
-
-
Method Details
-
builder
Create a new builder for configuring aParser
.- Returns:
- a builder
-
builder
-
parse
Parse the specified input text into a tree of nodes.Note that this method is thread-safe (a new parser state is used for each invocation).
-
parse
Parse the specified input text into a tree of nodes.Note that this method is thread-safe (a new parser state is used for each invocation).
-
parseReader
Parse the specified reader into a tree of nodes. The caller is responsible for closing the reader.Note that this method is thread-safe (a new parser state is used for each invocation).
- Specified by:
parseReader
in interfaceIParse
- Parameters:
input
- the reader to parse- Returns:
- the root node
- Throws:
IOException
- when reading throws an exception
-
postProcess
-
getOptions
Description copied from interface:IParse
Get Options for parsing- Specified by:
getOptions
in interfaceIParse
- Returns:
- DataHolder for options
-
transferReferences
public boolean transferReferences(@NotNull @NotNull Document document, @NotNull @NotNull Document included, Boolean onlyIfUndefined) Description copied from interface:IParse
Transfer reference definition between documents- Specified by:
transferReferences
in interfaceIParse
- Parameters:
document
- destination documentincluded
- source documentonlyIfUndefined
- true if only should transfer references not already defined in the destination document, false to transfer all, null to use repository's KEEP_TYPE to make the determination (if KEEP_FIRST then only transfer if undefined,- Returns:
- true if any references were transferred
-
transferReferences
public static <T extends Node> boolean transferReferences(NodeRepository<T> destination, NodeRepository<T> included, boolean onlyIfUndefined) -
addExtensions
Add extension(s) to the extension list- Parameters:
options
- mutable options holding existing extensionsextensions
- extension to add- Returns:
- mutable options
-
removeExtensions
Remove extension(s) of given class from the extension list- Parameters:
options
- mutable options holding existing extensionsextensions
- extension classes to remove- Returns:
- mutable options
-