APIdia Launch Partner
Top Inners Fields Constructors Methods
jdk.internal.org.commonmark.internal

public Class InlineParserImpl

extends Object
implements InlineParser, InlineParserState
Class Inheritance
All Implemented Interfaces
jdk.internal.org.commonmark.internal.inline.InlineParserState, jdk.internal.org.commonmark.parser.InlineParser
Imports
jdk.internal.org.commonmark.internal.inline.*, jdk.internal.org.commonmark.internal.util.Escaping, .LinkScanner, jdk.internal.org.commonmark.node.*, jdk.internal.org.commonmark.parser.InlineParser, .InlineParserContext, .SourceLines, jdk.internal.org.commonmark.parser.beta.Position, .Scanner, jdk.internal.org.commonmark.parser.delimiter.DelimiterProcessor, jdk.internal.org.commonmark.text.Characters, java.util.*

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final InlineParserContext
private final Map<Character, DelimiterProcessor>
private boolean
private final Map<Character, List<InlineContentParser>>
private Bracket
lastBracket

Top opening bracket ([ or ![)).

private Delimiter
lastDelimiter

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

private Scanner
private final BitSet
private int

Constructor Summary

AccessConstructor and Description
public

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 Map<Character, DelimiterProcessor>
public static BitSet
calculateSpecialCharacters(Set<Character> delimiterCharacters, Set<Character> characters)

private void
private void
mergeIfNeeded(Text first, Text last, int textLength)

private void
mergeTextNodesInclusive(Node fromNode, Node toNode)

public void
parse(SourceLines lines, Node block)

Implements jdk.internal.org.commonmark.parser.InlineParser.parse.

Parse content in block into inline children, appending them to the block node.

private Node
parseBang()

If next character is [, and !

private Node
parseCloseBracket()

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

private List<? extends Node>
parseDelimiters(DelimiterProcessor delimiterProcessor, char delimiterChar)

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

private List<? extends Node>
parseInline()

Parse the next inline element in subject, advancing our position.

private Node
private String
parseLinkDestination(Scanner scanner)

Attempt to parse link destination, returning the string or null if no match.

pack-priv String
parseLinkLabel(Scanner scanner)

Attempt to parse a link label, returning the label between the brackets or null.

private String
parseLinkTitle(Scanner scanner)

Attempt to parse link title (sans quotes), returning the string or null if no match.

private Node
parseOpenBracket()

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

private Node
parseText()

Parse the next character as plain text, and possibly more if the following characters are non-special.

private void
private void
private void
removeDelimiterAndNodes(Delimiter delim)

Remove the delimiter and the corresponding text node.

private void
removeDelimiterKeepNode(Delimiter delim)

Remove the delimiter but keep the corresponding node as text.

private void
private void
pack-priv void
private InlineParserImpl.DelimiterData

Returns:

information about delimiter run, or null
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.

public Scanner
scanner()

Implements jdk.internal.org.commonmark.internal.inline.InlineParserState.scanner.

Return a scanner for the input for the current position (on the character that the inline parser registered interest for).

private Text
text(SourceLines sourceLines)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final InlineParserContext context
delimiterProcessorsback to summary
private final Map<Character, DelimiterProcessor> delimiterProcessors
includeSourceSpansback to summary
private boolean includeSourceSpans
inlineParsersback to summary
private final Map<Character, List<InlineContentParser>> inlineParsers
lastBracketback to summary
private Bracket lastBracket

Top opening bracket ([ or ![)).

lastDelimiterback to summary
private Delimiter lastDelimiter

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

scannerback to summary
private Scanner scanner
specialCharactersback to summary
private final BitSet specialCharacters
trailingSpacesback to summary
private int trailingSpaces

Constructor Detail

InlineParserImplback to summary
public InlineParserImpl(InlineParserContext inlineParserContext)

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(Iterable<DelimiterProcessor> delimiterProcessors, Map<Character, DelimiterProcessor> map)
calculateDelimiterProcessorsback to summary
public static Map<Character, DelimiterProcessor> calculateDelimiterProcessors(List<DelimiterProcessor> delimiterProcessors)
calculateSpecialCharactersback to summary
public static BitSet calculateSpecialCharacters(Set<Character> delimiterCharacters, Set<Character> characters)
mergeChildTextNodesback to summary
private void mergeChildTextNodes(Node node)
mergeIfNeededback to summary
private void mergeIfNeeded(Text first, Text last, int textLength)
mergeTextNodesInclusiveback to summary
private void mergeTextNodesInclusive(Node fromNode, Node toNode)
parseback to summary
public void parse(SourceLines lines, Node block)

Implements jdk.internal.org.commonmark.parser.InlineParser.parse.

Parse content in block into inline children, appending them to the block node.

Annotations
@Override
parseBangback to summary
private Node 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.

parseCloseBracketback to summary
private Node parseCloseBracket()

Try to match close bracket against an opening in the delimiter stack. Return either a link or image, or a plain [ character. If there is a matching delimiter, remove it from the delimiter stack.

parseDelimitersback to summary
private List<? extends Node> parseDelimiters(DelimiterProcessor delimiterProcessor, char delimiterChar)

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

parseInlineback to summary
private List<? extends Node> parseInline()

Parse the next inline element in subject, advancing our position. On success, return the new inline node. On failure, return null.

parseLineBreakback to summary
private Node parseLineBreak()
parseLinkDestinationback to summary
private String parseLinkDestination(Scanner scanner)

Attempt to parse link destination, returning the string or null if no match.

parseLinkLabelback to summary
pack-priv String parseLinkLabel(Scanner scanner)

Attempt to parse a link label, returning the label between the brackets or null.

parseLinkTitleback to summary
private String parseLinkTitle(Scanner scanner)

Attempt to parse link title (sans quotes), returning the string or null if no match.

parseOpenBracketback to summary
private Node parseOpenBracket()

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

parseTextback to summary
private Node parseText()

Parse the next character as plain text, and possibly more if the following characters are non-special.

processDelimitersback to summary
private void processDelimiters(Delimiter stackBottom)
removeDelimiterback to summary
private void removeDelimiter(Delimiter delim)
removeDelimiterAndNodesback to summary
private void removeDelimiterAndNodes(Delimiter delim)

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

removeDelimiterKeepNodeback to summary
private void removeDelimiterKeepNode(Delimiter delim)

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

removeDelimitersBetweenback to summary
private void removeDelimitersBetween(Delimiter opener, Delimiter closer)
removeLastBracketback to summary
private void removeLastBracket()
resetback to summary
pack-priv void reset(SourceLines lines)
scanDelimitersback to summary
private 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.

Returns:InlineParserImpl.DelimiterData

information about delimiter run, or null

scannerback to summary
public Scanner scanner()

Implements jdk.internal.org.commonmark.internal.inline.InlineParserState.scanner.

Doc from jdk.internal.org.commonmark.internal.inline.InlineParserState.scanner.

Return a scanner for the input for the current position (on the character that the inline parser registered interest for).

Note that this always returns the same instance, if you want to backtrack you need to use Scanner#position() and Scanner#setPosition(Position).

Annotations
@Override
textback to summary
private Text text(SourceLines sourceLines)
jdk.internal.org.commonmark.internal back to summary

private Class InlineParserImpl.DelimiterData

extends Object
Class Inheritance
  • java.lang.Object
  • jdk.internal.org.commonmark.internal.InlineParserImpl.DelimiterData

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final boolean
pack-priv final List<Text>

Constructor Summary

AccessConstructor and Description
pack-priv
DelimiterData(List<Text> characters, 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
charactersback to summary
pack-priv final List<Text> characters

Constructor Detail

DelimiterDataback to summary
pack-priv DelimiterData(List<Text> characters, boolean canOpen, boolean canClose)