Top Inners Fields Constructors Methods
com.vladsch.flexmark.parser.internal

public Class InlineParserImpl

extends LightInlineParserImpl
implements InlineParser, ParagraphPreProcessor
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.parser.block.ParagraphPreProcessor, com.vladsch.flexmark.parser.InlineParser, com.vladsch.flexmark.parser.LightInlineParser
Known Direct Subclasses
com.vladsch.flexmark.parser.internal.CommonmarkInlineParser
Imports
com.vladsch.flexmark.ast.*, com.vladsch.flexmark.ast.util.ReferenceRepository, .TextNodeConverter, com.vladsch.flexmark.parser.*, com.vladsch.flexmark.parser.block.CharacterNodeFactory, .ParagraphPreProcessor, .ParserState, com.vladsch.flexmark.parser.core.delimiter.AsteriskDelimiterProcessor, .Bracket, .Delimiter, .UnderscoreDelimiterProcessor, com.vladsch.flexmark.parser.delimiter.DelimiterProcessor, com.vladsch.flexmark.util.ast.*, com.vladsch.flexmark.util.data.DataHolder, com.vladsch.flexmark.util.dependency.DependencyResolver, com.vladsch.flexmark.util.misc.CharPredicate, com.vladsch.flexmark.util.sequence.BasedSequence, .Escaping, .SegmentedSequence, .SequenceUtils, org.jetbrains.annotations.NotNull, .Nullable, java.util.*, java.util.function.Function, java.util.regex.Matcher

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
protected BitSet
protected Map<Character, CharacterNodeFactory>
protected ArrayList<Node>
protected final BitSet
protected final Map<Character, DelimiterProcessor>
protected List<InlineParserExtensionFactory>
protected Map<Character, List<InlineParserExtension>>
private Bracket
lastBracket

Top opening bracket ([ or ![)).

protected Delimiter
lastDelimiter

Top delimiter (emphasis, strong emphasis or custom emphasis).

protected LinkDestinationParser
protected List<LinkRefProcessor>
protected final LinkRefProcessorData
protected final BitSet
protected ReferenceRepository
referenceRepository

Link references by ID, needs to be built up using parseReference before calling parse.

protected BitSet
Inherited from com.vladsch.flexmark.parser.LightInlineParserImpl:
blockcurrentTextdocumentindexinputmyParsingoptions

Constructor Summary

AccessConstructor and Description
public
InlineParserImpl(DataHolder options, BitSet specialCharacters, BitSet delimiterCharacters, Map<Character, DelimiterProcessor> delimiterProcessors, LinkRefProcessorData linkRefProcessorsData, List<InlineParserExtensionFactory> inlineParserExtensionFactories)

Method Summary

Modifier and TypeMethod and Description
private void
private static void
addDelimiterProcessorForChar(char delimiterChar, DelimiterProcessor toAdd, Map<Character, DelimiterProcessor> delimiterProcessors)

private static void
public static BitSet
public static Map<Character, DelimiterProcessor>
pack-priv static Map<Character, List<InlineParserExtensionFactory>>
public static LinkRefProcessorData
public static BitSet
calculateSpecialCharacters(DataHolder options, BitSet delimiterCharacters)

protected Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

protected static void
collapseLinkRefChildren(Node node, Function<LinkRefDerived, Boolean> isTentative, boolean trimFirstLastChild)

protected static boolean
containsLinkRefs(Node node, Boolean isTentative)

protected static boolean
containsLinkRefs(BasedSequence nodeChars, Node next, Boolean isTentative)

public void
public Bracket
public Delimiter
public void
private InlineParserImpl.ReferenceProcessorMatch
matchLinkRef(Bracket opener, int startIndex, int lookAhead, int nesting)

public void
mergeIfNeeded(Text first, Text last)

public void
public void
parse(@NotNull BasedSequence content, @NotNull Node block)

Parse content in block into inline children, using reference map to resolve references.

protected boolean

Returns:

true
parseBackslash
()

Parse a backslash-escaped special character, adding either the escaped character, a hard line break (if the backslash is followed by a newline), or a literal backslash to the block's children.

protected boolean

Returns:

true if matched backticks, false otherwise
parseBackticks
()

Attempt to parse backticks, adding either a backtick code span or a literal sequence of backticks.

protected boolean

Returns:

true if processed characters false otherwise
parseBang
()

If next character is [, and !

protected boolean

Returns:

true
parseCloseBracket
()

Try to match close bracket against an opening in the delimiter stack.

public @Nullable List<Node>
protected boolean

Returns:

true if processed characters false otherwise
parseDelimiters
(DelimiterProcessor
delimiter processor instance
delimiterProcessor
,
char
delimiter character being processed
delimiterChar
)

Attempt to parse delimiters like emphasis, strong emphasis or custom delimiters.

public boolean

Returns:

true if processed characters false otherwise
parseEntity
()

Implements com.vladsch.flexmark.parser.InlineParser.parseEntity.

Attempt to parse an entity, return Entity object if successful.

public boolean

Returns:

true if processed characters false otherwise
parseHtmlInline
()

Implements com.vladsch.flexmark.parser.InlineParser.parseHtmlInline.

Attempt to parse inline HTML.

protected boolean

Returns:

false on failure true on success
parseInline
()

Parse the next inline element in subject, advancing input index.

protected boolean
parseInline(boolean customOnly)

public BasedSequence

Returns:

the string or null if no match.
parseLinkDestination
()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkDestination.

Attempt to parse link destination,

public int

Returns:

number of characters parsed.
parseLinkLabel
()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkLabel.

Attempt to parse a link label

public BasedSequence

Returns:

the string or null if no match.
parseLinkTitle
()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkTitle.

Attempt to parse link title (sans quotes),

public boolean

Returns:

true
parseNewline
()

Implements com.vladsch.flexmark.parser.InlineParser.parseNewline.

Parse a newline.

protected boolean

Returns:

true
parseOpenBracket
()

Add open bracket to delimiter stack and add a text node to block's children.

protected int

Returns:

number of characters were parsed as a reference from the start of the sequence, 0 if none
parseReference
(Block
the block whose text is being parsed for references
block
,
BasedSequence
sequence of the blocks characters
s
)

Attempt to parse a reference definition, modifying the internal reference map.

protected boolean

Returns:

true if processed characters false otherwise
parseString
()

Parse a run of ordinary characters, or a single character with a special meaning in markdown, as a plain string.

public int
preProcessBlock(Paragraph
paragraph node to process
block
,
ParserState
parser state
state
)

Implements com.vladsch.flexmark.parser.block.ParagraphPreProcessor.preProcessBlock.

Process Paragraph Content on closing of the paragraph block to removeIndex non-text lines.

private boolean
public void
public void
public void
removeDelimiterAndNode(@NotNull Delimiter
delimiter to remove
delim
)

Remove the delimiter and the corresponding text node.

public void
removeDelimiterKeepNode(@NotNull Delimiter
delimiter being processed
delim
)

Remove the delimiter but keep the corresponding node as text.

public void
private void
protected InlineParserImpl.DelimiterData

Returns:

information about delimiter run, or null
scanDelimiters
(DelimiterProcessor
delimiter processor instance
delimiterProcessor
,
char
delimiter character being scanned
delimiterChar
)

Scan a sequence of characters with code delimiterChar, and return information about the number of delimiters and whether they are positioned such that they can open and/or close emphasis or strong emphasis.

Inherited from com.vladsch.flexmark.parser.LightInlineParserImpl:
appendNodeappendSeparateTextappendTextappendTextflushTextNodegetBlockgetCurrentTextgetDocumentgetIndexgetInputgetOptionsgetParsingmatchmatchermatchWithGroupsmoveNodesnonIndentSppeekpeeksetBlocksetDocumentsetIndexsetInputspspnlspnlUrltoEOL

Field Detail

customCharactersback to summary
protected BitSet customCharacters
customSpecialCharacterFactoryMapback to summary
protected Map<Character, CharacterNodeFactory> customSpecialCharacterFactoryMap
customSpecialCharacterNodesback to summary
protected ArrayList<Node> customSpecialCharacterNodes
delimiterCharactersback to summary
protected final BitSet delimiterCharacters
delimiterProcessorsback to summary
protected final Map<Character, DelimiterProcessor> delimiterProcessors
inlineParserExtensionFactoriesback to summary
protected List<InlineParserExtensionFactory> inlineParserExtensionFactories
inlineParserExtensionsback to summary
protected Map<Character, List<InlineParserExtension>> inlineParserExtensions
lastBracketback to summary
private Bracket lastBracket

Top opening bracket ([ or ![)).

lastDelimiterback to summary
protected Delimiter lastDelimiter

Top delimiter (emphasis, strong emphasis or custom emphasis). (Brackets are on a separate stack, different from the algorithm described in the spec.)

linkDestinationParserback to summary
protected LinkDestinationParser linkDestinationParser
linkRefProcessorsback to summary
protected List<LinkRefProcessor> linkRefProcessors
linkRefProcessorsDataback to summary
protected final LinkRefProcessorData linkRefProcessorsData
originalSpecialCharactersback to summary
protected final BitSet originalSpecialCharacters
referenceRepositoryback to summary
protected ReferenceRepository referenceRepository

Link references by ID, needs to be built up using parseReference before calling parse.

specialCharactersback to summary
protected BitSet specialCharacters

Constructor Detail

InlineParserImplback to summary
public InlineParserImpl(DataHolder options, BitSet specialCharacters, BitSet delimiterCharacters, Map<Character, DelimiterProcessor> delimiterProcessors, LinkRefProcessorData linkRefProcessorsData, List<InlineParserExtensionFactory> inlineParserExtensionFactories)

Method Detail

addBracketback to summary
private void addBracket(Bracket bracket)
addDelimiterProcessorForCharback to summary
private static void addDelimiterProcessorForChar(char delimiterChar, DelimiterProcessor toAdd, Map<Character, DelimiterProcessor> delimiterProcessors)
addDelimiterProcessorsback to summary
private static void addDelimiterProcessors(List<? extends DelimiterProcessor> delimiterProcessors, Map<Character, DelimiterProcessor> map)
calculateDelimiterCharactersback to summary
public static BitSet calculateDelimiterCharacters(DataHolder options, Set<Character> characters)
calculateDelimiterProcessorsback to summary
public static Map<Character, DelimiterProcessor> calculateDelimiterProcessors(DataHolder options, List<DelimiterProcessor> delimiterProcessors)
calculateInlineParserExtensionsback to summary
pack-priv static Map<Character, List<InlineParserExtensionFactory>> calculateInlineParserExtensions(DataHolder options, List<InlineParserExtensionFactory> extensionFactories)
calculateLinkRefProcessorsback to summary
public static LinkRefProcessorData calculateLinkRefProcessors(DataHolder options, List<LinkRefProcessorFactory> linkRefProcessors)
calculateSpecialCharactersback to summary
public static BitSet calculateSpecialCharacters(DataHolder options, BitSet delimiterCharacters)
cloneback to summary
protected Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
collapseLinkRefChildrenback to summary
protected static void collapseLinkRefChildren(Node node, Function<LinkRefDerived, Boolean> isTentative, boolean trimFirstLastChild)
containsLinkRefsback to summary
protected static boolean containsLinkRefs(Node node, Boolean isTentative)
containsLinkRefsback to summary
protected static boolean containsLinkRefs(BasedSequence nodeChars, Node next, Boolean isTentative)
finalizeDocumentback to summary
public void finalizeDocument(@NotNull Document document)
Annotations
@Override
getLastBracketback to summary
public Bracket getLastBracket()

Implements com.vladsch.flexmark.parser.InlineParser.getLastBracket.

Annotations
@Override
getLastDelimiterback to summary
public Delimiter getLastDelimiter()

Implements com.vladsch.flexmark.parser.InlineParser.getLastDelimiter.

Annotations
@Override
initializeDocumentback to summary
public void initializeDocument(@NotNull Document document)
Annotations
@Override
matchLinkRefback to summary
private InlineParserImpl.ReferenceProcessorMatch matchLinkRef(Bracket opener, int startIndex, int lookAhead, int nesting)
mergeIfNeededback to summary
public void mergeIfNeeded(Text first, Text last)
Annotations
@Override
mergeTextNodesback to summary
public void mergeTextNodes(@Nullable Node fromNode, @Nullable Node toNode)
Annotations
@Override
parseback to summary
public void parse(@NotNull BasedSequence content, @NotNull Node block)

Parse content in block into inline children, using reference map to resolve references.

Annotations
@Override
parseBackslashback to summary
protected boolean parseBackslash()

Parse a backslash-escaped special character, adding either the escaped character, a hard line break (if the backslash is followed by a newline), or a literal backslash to the block's children.

Returns:boolean

true

parseBackticksback to summary
protected boolean parseBackticks()

Attempt to parse backticks, adding either a backtick code span or a literal sequence of backticks.

Returns:boolean

true if matched backticks, false otherwise

parseBangback to summary
protected boolean parseBang()

If next character is [, and ! delimiter to delimiter stack and add a text node to block's children. Otherwise just add a text node.

Returns:boolean

true if processed characters false otherwise

parseCloseBracketback to summary
protected boolean parseCloseBracket()

Try to match close bracket against an opening in the delimiter stack. Add either a link or image, or a plain [ character, to block's children. If there is a matching delimiter, removeIndex it from the delimiter stack.

Also handles custom link ref processing

Returns:boolean

true

parseCustomback to summary
public @Nullable List<Node> parseCustom(@NotNull BasedSequence input, @NotNull Node node, @NotNull BitSet customCharacters, @NotNull Map<Character, CharacterNodeFactory> nodeFactoryMap)
Annotations
@Nullable
@Override
parseDelimitersback to summary
protected boolean parseDelimiters(DelimiterProcessor delimiterProcessor, char delimiterChar)

Attempt to parse delimiters like emphasis, strong emphasis or custom delimiters.

Parameters
delimiterProcessor:DelimiterProcessor

delimiter processor instance

delimiterChar:char

delimiter character being processed

Returns:boolean

true if processed characters false otherwise

parseEntityback to summary
public boolean parseEntity()

Implements com.vladsch.flexmark.parser.InlineParser.parseEntity.

Attempt to parse an entity, return Entity object if successful.

Returns:boolean

true if processed characters false otherwise

Annotations
@Override
parseHtmlInlineback to summary
public boolean parseHtmlInline()

Implements com.vladsch.flexmark.parser.InlineParser.parseHtmlInline.

Attempt to parse inline HTML.

Returns:boolean

true if processed characters false otherwise

Annotations
@Override
parseInlineback to summary
protected boolean parseInline()

Parse the next inline element in subject, advancing input index. On success, add the result to block's children and return true. On failure, return false.

Returns:boolean

false on failure true on success

parseInlineback to summary
protected boolean parseInline(boolean customOnly)
parseLinkDestinationback to summary
public BasedSequence parseLinkDestination()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkDestination.

Attempt to parse link destination,

Returns:BasedSequence

the string or null if no match.

Annotations
@Override
parseLinkLabelback to summary
public int parseLinkLabel()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkLabel.

Attempt to parse a link label

Returns:int

number of characters parsed.

Annotations
@Override
parseLinkTitleback to summary
public BasedSequence parseLinkTitle()

Implements com.vladsch.flexmark.parser.InlineParser.parseLinkTitle.

Attempt to parse link title (sans quotes),

Returns:BasedSequence

the string or null if no match.

Annotations
@Override
parseNewlineback to summary
public boolean parseNewline()

Implements com.vladsch.flexmark.parser.InlineParser.parseNewline.

Parse a newline. If it was preceded by two spaces, append a hard line break; otherwise a soft line break.

Returns:boolean

true

Annotations
@Override
parseOpenBracketback to summary
protected boolean parseOpenBracket()

Add open bracket to delimiter stack and add a text node to block's children.

Returns:boolean

true

parseReferenceback to summary
protected int parseReference(Block block, BasedSequence s)

Attempt to parse a reference definition, modifying the internal reference map.

Parameters
block:Block

the block whose text is being parsed for references

s:BasedSequence

sequence of the blocks characters

Returns:int

number of characters were parsed as a reference from the start of the sequence, 0 if none

parseStringback to summary
protected boolean parseString()

Parse a run of ordinary characters, or a single character with a special meaning in markdown, as a plain string.

Returns:boolean

true if processed characters false otherwise

preProcessBlockback to summary
public int preProcessBlock(Paragraph block, ParserState state)

Implements com.vladsch.flexmark.parser.block.ParagraphPreProcessor.preProcessBlock.

Doc from com.vladsch.flexmark.parser.block.ParagraphPreProcessor.preProcessBlock.

Process Paragraph Content on closing of the paragraph block to removeIndex non-text lines.

This is used by extensions to take leading lines from a paragraph and convert them to other blocks

by Default leading lines that define references are removed and Reference nodes are inserted before.

Parameters
block:Paragraph

paragraph node to process

state:ParserState

parser state

Returns:int

number of characters processed from the start of the block

Annotations
@Override
processCustomCharactersback to summary
private boolean processCustomCharacters()
processDelimitersback to summary
public void processDelimiters(Delimiter stackBottom)
Annotations
@Override
removeDelimiterback to summary
public void removeDelimiter(@NotNull Delimiter delim)
Annotations
@Override
removeDelimiterAndNodeback to summary
public void removeDelimiterAndNode(@NotNull Delimiter delim)

Remove the delimiter and the corresponding text node. For used delimiters, e.g. `*` in `*foo*`.

Parameters
delim:@NotNull Delimiter

delimiter to remove

Annotations
@Override
removeDelimiterKeepNodeback to summary
public void removeDelimiterKeepNode(@NotNull Delimiter delim)

Remove the delimiter but keep the corresponding node as text. For unused delimiters such as `_` in `foo_bar`.

Parameters
delim:@NotNull Delimiter

delimiter being processed

Annotations
@Override
removeDelimitersBetweenback to summary
public void removeDelimitersBetween(@NotNull Delimiter opener, @NotNull Delimiter closer)
Annotations
@Override
removeLastBracketback to summary
private void removeLastBracket()
scanDelimitersback to summary
protected InlineParserImpl.DelimiterData scanDelimiters(DelimiterProcessor delimiterProcessor, char delimiterChar)

Scan a sequence of characters with code delimiterChar, and return information about the number of delimiters and whether they are positioned such that they can open and/or close emphasis or strong emphasis.

Parameters
delimiterProcessor:DelimiterProcessor

delimiter processor instance

delimiterChar:char

delimiter character being scanned

Returns:InlineParserImpl.DelimiterData

information about delimiter run, or null

com.vladsch.flexmark.parser.internal back to summary

private Class InlineParserImpl.DelimiterData

extends Object
Class Inheritance
  • java.lang.Object
  • com.vladsch.flexmark.parser.internal.InlineParserImpl.DelimiterData

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final boolean
pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
DelimiterData(int count, boolean canOpen, boolean canClose)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canCloseback to summary
pack-priv final boolean canClose
canOpenback to summary
pack-priv final boolean canOpen
countback to summary
pack-priv final int count

Constructor Detail

DelimiterDataback to summary
pack-priv DelimiterData(int count, boolean canOpen, boolean canClose)
com.vladsch.flexmark.parser.internal back to summary

pack-priv Class InlineParserImpl.ReferenceProcessorMatch

extends Object
Class Inheritance
  • java.lang.Object
  • com.vladsch.flexmark.parser.internal.InlineParserImpl.ReferenceProcessorMatch

Field Summary

Modifier and TypeField and Description
public final BasedSequence
public final LinkRefProcessor
public final boolean

Constructor Summary

AccessConstructor and Description
public
ReferenceProcessorMatch(LinkRefProcessor processor, boolean wantExclamation, BasedSequence nodeChars)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeCharsback to summary
public final BasedSequence nodeChars
processorback to summary
public final LinkRefProcessor processor
wantExclamationback to summary
public final boolean wantExclamation

Constructor Detail

ReferenceProcessorMatchback to summary
public ReferenceProcessorMatch(LinkRefProcessor processor, boolean wantExclamation, BasedSequence nodeChars)