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:----c0WBtOYv7eoORAzScgZWT1AuxImzOY1MPGUWI9BuASvSlJRB2wqx2B3koTbY9gfRHrlpK5S759hwF3r9zrvGMXqck3E8piEBopDy87ZdhtqLOlW3nh4UZjzwBMjAgkI6vFZtzP1HP6cBuREhXN3iNIKvpj4+GzFlxdNIbW0OoCDtUtSH8UzoX+KU6aFy0LbtWP79EAoKq9VczKu3XUJ9mHpkQtZRR1cHzIQLRsJL6ho+px+MnUg2jMNqg+KXueTVyMN/6d7/lyK2ufQfAYkf3/mNOLVaDZkaZt6lqos9di1HpciSi7ZvcaKl/Vx7PlcOPK+D+Klix8la0VCbf3b758V5NX2+QY3yD3c4aTRrElBy2pHkbXw53yUuua2JvkbS6hqESJfy1T8fMDNGjCIYKM5/g38QGoUJhV9pmSgNgH+JpMwG10xFCkkH5kUWwX2rcrWAqrfGtQWpO0e3JrvL/OrHTMrX0Rez0ID1HGLMeXhDdEZKhoy7/fkJubhNyyiA6n+pVrC424Fn8uS1YzgrCMZbge+ekwNwyjjkOv99OlusClc1JtnVD5D+cgmjQDqRNFLtgU0lxxqOkeeWXjAa7o4IJmbojscbfTTq07l3g71i7IScvQqG/eCbsKrCI4UnwQuI4+IN0nQ1fco7VoOYP61V60t41xwUerpk2hYT5Mk=----ATTACHMENT:----MjExMzU1NDk4MTYxNjAwMiA5NzYwOTE4MzE5ODYyOTggMzYxNTg0NTYyODYzMjc3OA==