Class EmphasisDelimiterProcessor
java.lang.Object
com.vladsch.flexmark.parser.core.delimiter.EmphasisDelimiterProcessor
- All Implemented Interfaces:
DelimiterProcessor
- Direct Known Subclasses:
AsteriskDelimiterProcessor, UnderscoreDelimiterProcessor
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEmphasisDelimiterProcessor(char delimiterChar, boolean strongWrapsEmphasis) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeCloser(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) Decide whether this delimiter can be a close delimiterbooleancanBeOpener(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) Decide whether this delimiter can be an open delimitercharintgetDelimiterUse(DelimiterRun opener, DelimiterRun closer) Determine how many (if any) of the delimiter characters should be used.intcharvoidProcess the matched delimiters, e.g.booleanWhether to skip delimiters that cannot be openers or closersunmatchedDelimiterNode(InlineParser inlineParser, DelimiterRun delimiter) Allow delimiter processor to substitute unmatched delimiters by custom nodes
-
Field Details
-
delimiterChar
private final char delimiterChar -
multipleUse
private final int multipleUse
-
-
Constructor Details
-
EmphasisDelimiterProcessor
protected EmphasisDelimiterProcessor(char delimiterChar, boolean strongWrapsEmphasis)
-
-
Method Details
-
getOpeningCharacter
public char getOpeningCharacter()- Specified by:
getOpeningCharacterin interfaceDelimiterProcessor- Returns:
- the character that marks the beginning of a delimited node, must not clash with any built-in special characters
-
getClosingCharacter
public char getClosingCharacter()- Specified by:
getClosingCharacterin interfaceDelimiterProcessor- 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.
-
getMinLength
public int getMinLength()- Specified by:
getMinLengthin interfaceDelimiterProcessor- Returns:
- Minimum number of delimiter characters that are needed to activate this. Must be at least 1.
-
canBeOpener
public boolean canBeOpener(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) Description copied from interface:DelimiterProcessorDecide whether this delimiter can be an open delimiter- Specified by:
canBeOpenerin interfaceDelimiterProcessor- Parameters:
before- string before delimiter or '\n' if noneafter- string after delimiter or '\n' if noneleftFlanking- is left flanking delimiterrightFlanking- is right flanking delimiterbeforeIsPunctuation- is punctuation beforeafterIsPunctuation- is punctuation afterbeforeIsWhitespace- is whitespace beforeafterIsWhiteSpace- is whitespace after- Returns:
- true if can be open delimiter
-
canBeCloser
public boolean canBeCloser(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) Description copied from interface:DelimiterProcessorDecide whether this delimiter can be a close delimiter- Specified by:
canBeCloserin interfaceDelimiterProcessor- Parameters:
before- string before delimiter or '\n' if noneafter- string after delimiter or '\n' if noneleftFlanking- is left flanking delimiterrightFlanking- is right flanking delimiterbeforeIsPunctuation- is punctuation beforeafterIsPunctuation- is punctuation afterbeforeIsWhitespace- is whitespace beforeafterIsWhiteSpace- is whitespace after- Returns:
- true if can be open delimiter
-
skipNonOpenerCloser
public boolean skipNonOpenerCloser()Description copied from interface:DelimiterProcessorWhether to skip delimiters that cannot be openers or closers- Specified by:
skipNonOpenerCloserin interfaceDelimiterProcessor- Returns:
- true if to skip
-
unmatchedDelimiterNode
Description copied from interface:DelimiterProcessorAllow delimiter processor to substitute unmatched delimiters by custom nodes- Specified by:
unmatchedDelimiterNodein interfaceDelimiterProcessor- Parameters:
inlineParser- inline parser instancedelimiter- delimiter run that was not matched- Returns:
- node to replace unmatched delimiter, null or delimiter.getNode() to replace with delimiter text
-
getDelimiterUse
Description copied from interface:DelimiterProcessorDetermine 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.
- Specified by:
getDelimiterUsein interfaceDelimiterProcessor- Parameters:
opener- the opening delimiter runcloser- the closing delimiter run- Returns:
- how many delimiters should be used; must not be greater than length of either opener or closer
-
process
Description copied from interface:DelimiterProcessorProcess 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.
- Specified by:
processin interfaceDelimiterProcessor- Parameters:
opener- the delimiter with text node that contained the opening delimitercloser- the delimiter with text node that contained the closing delimiterdelimitersUsed- the number of delimiters that were used
-