Top Description Methods
com.vladsch.flexmark.parser.delimiter

public Interface DelimiterProcessor

Known Direct Implementers
com.vladsch.flexmark.parser.core.delimiter.EmphasisDelimiterProcessor
Imports
com.vladsch.flexmark.parser.InlineParser, com.vladsch.flexmark.parser.core.delimiter.Delimiter, com.vladsch.flexmark.util.ast.Node

Custom delimiter processor for additional delimiters besides _ and *.

Note that implementations of this need to be thread-safe, the same instance may be used by multiple parsers.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if can be open delimiter
canBeCloser
(String
string before delimiter or '\n' if none
before
,
String
string after delimiter or '\n' if none
after
,
boolean
is left flanking delimiter
leftFlanking
,
boolean
is right flanking delimiter
rightFlanking
,
boolean
is punctuation before
beforeIsPunctuation
,
boolean
is punctuation after
afterIsPunctuation
,
boolean
is whitespace before
beforeIsWhitespace
,
boolean
is whitespace after
afterIsWhiteSpace
)

Decide whether this delimiter can be a close delimiter

public boolean

Returns:

true if can be open delimiter
canBeOpener
(String
string before delimiter or '\n' if none
before
,
String
string after delimiter or '\n' if none
after
,
boolean
is left flanking delimiter
leftFlanking
,
boolean
is right flanking delimiter
rightFlanking
,
boolean
is punctuation before
beforeIsPunctuation
,
boolean
is punctuation after
afterIsPunctuation
,
boolean
is whitespace before
beforeIsWhitespace
,
boolean
is whitespace after
afterIsWhiteSpace
)

Decide whether this delimiter can be an open delimiter

public char

Returns:

the character that marks the the ending of a delimited node, must not clash with any built-in special characters. Note that for a symmetric delimiter such as "*", this is the same as the opening.
getClosingCharacter
()

public int

Returns:

how many delimiters should be used; must not be greater than length of either opener or closer
getDelimiterUse
(DelimiterRun
the opening delimiter run
opener
,
DelimiterRun
the closing delimiter run
closer
)

Determine how many (if any) of the delimiter characters should be used.

public int

Returns:

Minimum number of delimiter characters that are needed to activate this. Must be at least 1.
getMinLength
()

public char

Returns:

the character that marks the beginning of a delimited node, must not clash with any built-in special characters
getOpeningCharacter
()

public void
process(Delimiter
the delimiter with text node that contained the opening delimiter
opener
,
Delimiter
the delimiter with text node that contained the closing delimiter
closer
,
int
the number of delimiters that were used
delimitersUsed
)

Process the matched delimiters, e.g. by wrapping the nodes between opener and closer in a new node, or appending a new node after the opener.

public boolean

Returns:

true if to skip
skipNonOpenerCloser
()

Whether to skip delimiters that cannot be openers or closers

public Node

Returns:

node to replace unmatched delimiter, null or delimiter.getNode() to replace with delimiter text
unmatchedDelimiterNode
(InlineParser
inline parser instance
inlineParser
,
DelimiterRun
delimiter run that was not matched
delimiter
)

Allow delimiter processor to substitute unmatched delimiters by custom nodes

Method Detail

canBeCloserback to summary
public boolean canBeCloser(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace)

Decide whether this delimiter can be a close delimiter

Parameters
before:String

string before delimiter or '\n' if none

after:String

string after delimiter or '\n' if none

leftFlanking:boolean

is left flanking delimiter

rightFlanking:boolean

is right flanking delimiter

beforeIsPunctuation:boolean

is punctuation before

afterIsPunctuation:boolean

is punctuation after

beforeIsWhitespace:boolean

is whitespace before

afterIsWhiteSpace:boolean

is whitespace after

Returns:boolean

true if can be open delimiter

canBeOpenerback to summary
public boolean canBeOpener(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace)

Decide whether this delimiter can be an open delimiter

Parameters
before:String

string before delimiter or '\n' if none

after:String

string after delimiter or '\n' if none

leftFlanking:boolean

is left flanking delimiter

rightFlanking:boolean

is right flanking delimiter

beforeIsPunctuation:boolean

is punctuation before

afterIsPunctuation:boolean

is punctuation after

beforeIsWhitespace:boolean

is whitespace before

afterIsWhiteSpace:boolean

is whitespace after

Returns:boolean

true if can be open delimiter

getClosingCharacterback to summary
public char getClosingCharacter()
Returns:char

the character that marks the the ending of a delimited node, must not clash with any built-in special characters. Note that for a symmetric delimiter such as "*", this is the same as the opening.

getDelimiterUseback to summary
public int getDelimiterUse(DelimiterRun opener, DelimiterRun closer)

Determine how many (if any) of the delimiter characters should be used.

This allows implementations to decide how many characters to use based on the properties of the delimiter runs. An implementation can also return 0 when it doesn't want to allow this particular combination of delimiter runs.

Parameters
opener:DelimiterRun

the opening delimiter run

closer:DelimiterRun

the closing delimiter run

Returns:int

how many delimiters should be used; must not be greater than length of either opener or closer

getMinLengthback to summary
public int getMinLength()
Returns:int

Minimum number of delimiter characters that are needed to activate this. Must be at least 1.

getOpeningCharacterback to summary
public char getOpeningCharacter()
Returns:char

the character that marks the beginning of a delimited node, must not clash with any built-in special characters

processback to summary
public void process(Delimiter opener, Delimiter closer, int delimitersUsed)

Process the matched delimiters, e.g. by wrapping the nodes between opener and closer in a new node, or appending a new node after the opener.

Note that removal of the delimiter from the delimiter nodes and unlinking them is done by the caller.

Parameters
opener:Delimiter

the delimiter with text node that contained the opening delimiter

closer:Delimiter

the delimiter with text node that contained the closing delimiter

delimitersUsed:int

the number of delimiters that were used

skipNonOpenerCloserback to summary
public boolean skipNonOpenerCloser()

Whether to skip delimiters that cannot be openers or closers

Returns:boolean

true if to skip

unmatchedDelimiterNodeback to summary
public Node unmatchedDelimiterNode(InlineParser inlineParser, DelimiterRun delimiter)

Allow delimiter processor to substitute unmatched delimiters by custom nodes

Parameters
inlineParser:InlineParser

inline parser instance

delimiter:DelimiterRun

delimiter run that was not matched

Returns:Node

node to replace unmatched delimiter, null or delimiter.getNode() to replace with delimiter text