Copied!

Special marker interface for delimiter processors that return dynamic values from getDelimiterUse()

In order to guarantee linear performance of delimiter processing, the delimiter stack must be able to cache the lower bound when searching for a matching opener. This gets complicated for delimiter processors that use a dynamic number of characters (like with emphasis and its "multiple of 3" rule).

AbstractInterface
Methods
public abstract getCacheKey(League\CommonMark\Delimiter\DelimiterInterface $closer) : string
 

Returns a cache key of the factors that determine the number of characters to use.

In order to guarantee linear performance of delimiter processing, the delimiter stack must be able to cache the lower bound when searching for a matching opener. This lower bound is usually quite simple; for example, with quotes, it's just the last opener with that characted. However, this gets complicated for delimiter processors that use a dynamic number of characters (like with emphasis and its "multiple of 3" rule), because the delimiter length being considered may change during processing because of that dynamic logic in getDelimiterUse(). Therefore, we cannot safely cache the lower bound for these dynamic processors without knowing the factors that determine the number of characters to use.

At a minimum, this should include the delimiter character, plus any other factors used to determine the result of getDelimiterUse(). The format of the string is not important so long as it is unique (compared to other processors) and consistent for a given set of factors.

If getDelimiterUse() always returns the same hard-coded value, this method should return just the delimiter character.

public abstract League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface::getClosingCharacter() : string
 

Returns the character that marks the ending of a delimited node.

This must not clash with any other processors being added to the environment.

Note that for a symmetric delimiter such as "*", this is the same as the opening.

public abstract League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface::getDelimiterUse(League\CommonMark\Delimiter\DelimiterInterface $opener, League\CommonMark\Delimiter\DelimiterInterface $closer) : int
 

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

This allows implementations to decide how many characters to be used 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.

IMPORTANT: Unless this method returns the same hard-coded value in all cases, you MUST implement the CacheableDelimiterProcessorInterface interface instead.

  • param \DelimiterInterface $opener The opening delimiter run
  • param \DelimiterInterface $closer The closing delimiter run
public abstract League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface::getMinLength() : int
 

Minimum number of delimiter characters that are needed to active this.

Must be at least 1.

public abstract League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface::getOpeningCharacter() : string
 

Returns the character that marks the beginning of a delimited node.

This must not clash with any other processors being added to the environment.

public abstract League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface::process(League\CommonMark\Node\Inline\AbstractStringContainer $opener, League\CommonMark\Node\Inline\AbstractStringContainer $closer, int $delimiterUse) : void
 

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 detaching them is done by the caller.

  • param \AbstractStringContainer $opener The node that contained the opening delimiter
  • param \AbstractStringContainer $closer The node that contained the closing delimiter
  • param int $delimiterUse The number of delimiters that were used
© 2026 Bruce Wells
Search Namespaces \ Classes
Configuration