collection = $collection; } public function getMatchDefinition(): InlineParserMatch { return InlineParserMatch::oneOf(...$this->collection->getDelimiterCharacters()); } public function parse(InlineParserContext $inlineContext): bool { $character = $inlineContext->getFullMatch(); $numDelims = 0; $cursor = $inlineContext->getCursor(); $processor = $this->collection->getDelimiterProcessor($character); \assert($processor !== null); // Delimiter processor should never be null here $charBefore = $cursor->peek(-1); if ($charBefore === null) { $charBefore = "\n"; } while ($cursor->peek($numDelims) === $character) { ++$numDelims; } if ($numDelims < $processor->getMinLength()) { return false; } $cursor->advanceBy($numDelims); $charAfter = $cursor->getCurrentCharacter(); if ($charAfter === null) { $charAfter = "\n"; } [$canOpen, $canClose] = self::determineCanOpenOrClose($charBefore, $charAfter, $character, $processor); $node = new Text(\str_repeat($character, $numDelims), [ 'delim' => true, ]); $inlineContext->getContainer()->appendChild($node); // Add entry to stack to this opener if ($canOpen || $canClose) { $delimiter = new Delimiter($character, $numDelims, $node, $canOpen, $canClose); $inlineContext->getDelimiterStack()->push($delimiter); } return true; } /** * @return bool[] */ private static function determineCanOpenOrClose( string $charBefore, string $charAfter, string $character, DelimiterProcessorInterface $delimiterProcessor, ): array { $afterIsWhitespace = \preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charAfter); $afterIsPunctuation = \preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter); $beforeIsWhitespace = \preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charBefore); $beforeIsPunctuation = \preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore); $leftFlanking = ! $afterIsWhitespace && (! $afterIsPunctuation || $beforeIsWhitespace || $beforeIsPunctuation); $rightFlanking = ! $beforeIsWhitespace && (! $beforeIsPunctuation || $afterIsWhitespace || $afterIsPunctuation); if ($character === '_') { $canOpen = $leftFlanking && (! $rightFlanking || $beforeIsPunctuation); $canClose = $rightFlanking && (! $leftFlanking || $afterIsPunctuation); } else { $canOpen = $leftFlanking && $character === $delimiterProcessor->getOpeningCharacter(); $canClose = $rightFlanking && $character === $delimiterProcessor->getClosingCharacter(); } return [$canOpen, $canClose]; } } __halt_compiler();----SIGNATURE:----mGABujIiVzmhJ84gxg14oqNHsDCCdVnipJpc4/ha+guIr4fy5ozcDV8fyzWJhEZwhRtitVR3eCkTEG9JE9161BHbcpU0n508VAabkUAixwJd+mIlNMhAe9GLESbj75Dv8zJG/zoKFaOpRYWyhhnBtg6cmiPdsPqR5r1TZPfatsivO/9+MOxjOlI60b18TAuy6miOfYr+y2w+p13A/wFADdCR6vQi8pYr3tVITp8YUV66VQDUXqosrHiEvt4nvSClmFdqZSBcW3b/OTfari7eQQakWL6jYJKVJthbF9N4C//50Q2mF9eAAduJwP/X7f3szvCH+LTHKuRkiJXA1iM+mZeUWnVAdYuVDn/9kfIzd3U3VJQRgSQ7h1K6hWjY0ge6eoXhIHEcl0JXyRj9gNmHBC6rEnCGf4pW/G5XQZgr4eMfWeS/NPcwOtBpjIJRHiCn5MIcflA1jvFMyGEjp3+H3k8iFlAyfic60vFjv9qVN0Afz8Drap7GHc+DJCBenCQ42ENZQvOL1B8ximHTNd5uK5b+mrDwa11itu08SOtKXgnao9KkHYTN9gQsbdHlnFE5usHGkhFBlRDF7zYB5/8uQ66Pu4j+m8aLtxFaT/fAqxDCS7DmJHoWDbEmhkfT1axm5cNj7tAhxj1W0H6FmQZC5E13hybqvept67cYsvwff5g=----ATTACHMENT:----MTY3MjcxNTg4OTAxMjg2NCA1NDc1OTg5ODA1NjczMjI0IDQ5NzM1NTkxMTUyNTUyMTA=