Class QuoteDelimiterProcessorBase

java.lang.Object
com.vladsch.flexmark.ext.typographic.internal.QuoteDelimiterProcessorBase
All Implemented Interfaces:
DelimiterProcessor
Direct Known Subclasses:
AngleQuoteDelimiterProcessor, DoubleQuoteDelimiterProcessor, SingleQuoteDelimiterProcessor

public class QuoteDelimiterProcessorBase extends Object implements DelimiterProcessor
  • Field Details

    • myOptions

      protected final TypographicOptions myOptions
    • myOpenDelimiter

      protected final char myOpenDelimiter
    • myCloseDelimiter

      protected final char myCloseDelimiter
    • myOpener

      protected final String myOpener
    • myCloser

      protected final String myCloser
    • myUnmatched

      protected final String myUnmatched
  • Constructor Details

    • QuoteDelimiterProcessorBase

      public QuoteDelimiterProcessorBase(TypographicOptions options, char openDelimiter, char closeDelimiter, String opener, String closer, String unmatched)
  • Method Details

    • getOpeningCharacter

      public final char getOpeningCharacter()
      Specified by:
      getOpeningCharacter in interface DelimiterProcessor
      Returns:
      the character that marks the beginning of a delimited node, must not clash with any built-in special characters
    • getClosingCharacter

      public final char getClosingCharacter()
      Specified by:
      getClosingCharacter in interface DelimiterProcessor
      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:
      getMinLength in interface DelimiterProcessor
      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: DelimiterProcessor
      Decide whether this delimiter can be an open delimiter
      Specified by:
      canBeOpener in interface DelimiterProcessor
      Parameters:
      before - string before delimiter or '\n' if none
      after - string after delimiter or '\n' if none
      leftFlanking - is left flanking delimiter
      rightFlanking - is right flanking delimiter
      beforeIsPunctuation - is punctuation before
      afterIsPunctuation - is punctuation after
      beforeIsWhitespace - is whitespace before
      afterIsWhiteSpace - 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: DelimiterProcessor
      Decide whether this delimiter can be a close delimiter
      Specified by:
      canBeCloser in interface DelimiterProcessor
      Parameters:
      before - string before delimiter or '\n' if none
      after - string after delimiter or '\n' if none
      leftFlanking - is left flanking delimiter
      rightFlanking - is right flanking delimiter
      beforeIsPunctuation - is punctuation before
      afterIsPunctuation - is punctuation after
      beforeIsWhitespace - is whitespace before
      afterIsWhiteSpace - is whitespace after
      Returns:
      true if can be open delimiter
    • skipNonOpenerCloser

      public boolean skipNonOpenerCloser()
      Description copied from interface: DelimiterProcessor
      Whether to skip delimiters that cannot be openers or closers
      Specified by:
      skipNonOpenerCloser in interface DelimiterProcessor
      Returns:
      true if to skip
    • havePreviousOpener

      protected boolean havePreviousOpener(DelimiterRun opener)
    • haveNextCloser

      protected boolean haveNextCloser(DelimiterRun closer)
    • canClose

      protected boolean canClose(DelimiterRun closer, int minLength)
    • canOpen

      protected boolean canOpen(DelimiterRun opener, int minLength)
    • isAllowed

      protected boolean isAllowed(char c)
    • isAllowed

      protected boolean isAllowed(CharSequence seq, int index)
    • getDelimiterUse

      public int getDelimiterUse(DelimiterRun opener, DelimiterRun closer)
      Description copied from interface: DelimiterProcessor
      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.

      Specified by:
      getDelimiterUse in interface DelimiterProcessor
      Parameters:
      opener - the opening delimiter run
      closer - the closing delimiter run
      Returns:
      how many delimiters should be used; must not be greater than length of either opener or closer
    • unmatchedDelimiterNode

      public Node unmatchedDelimiterNode(InlineParser inlineParser, DelimiterRun delimiter)
      Description copied from interface: DelimiterProcessor
      Allow delimiter processor to substitute unmatched delimiters by custom nodes
      Specified by:
      unmatchedDelimiterNode in interface DelimiterProcessor
      Parameters:
      inlineParser - inline parser instance
      delimiter - delimiter run that was not matched
      Returns:
      node to replace unmatched delimiter, null or delimiter.getNode() to replace with delimiter text
    • process

      public void process(Delimiter opener, Delimiter closer, int delimitersUsed)
      Description copied from interface: DelimiterProcessor
      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.

      Specified by:
      process in interface DelimiterProcessor
      Parameters:
      opener - the delimiter with text node that contained the opening delimiter
      closer - the delimiter with text node that contained the closing delimiter
      delimitersUsed - the number of delimiters that were used