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:----h1ZMdxe2mdafJi8DoLJ0kJ5BFPBAaak8HlUBVuCVkpcncQ+SAr986HG2AUOYyXEbsddNVd5f7CwR9IDh0YoO0wtJ3dLaGusEyaFRVlizZt1WrpjljXOGp+/WPsdhwht10bnbIHg+QczPAy01eA25EpEfHcbEumywCU/4RKCHY6jmiCTWUN9yuFL+xTpDZ6vKjXU5FQActGClkLtqhB6x+2DNIpzYQaBd6+MZwddfCwOLQ2K1wPSglufkgGOnkLFHnqLoZp5ZrEH05MC5pF9SebU9dhqv6BkqVX6U4DhzZ9bb348CfZHACltM1hMY9gE2331tjGlXZGoXLkpEzguDnMxL3fD+MX74NyaXcwCFlTkZMaHu1RfiFW11eQly1/K0Gqegu0gw7O4BO8TxrZUqXcVtUZcd6yZUnBHOQIgXWhFFxspzRzu39mQ8QaPQKD1oZmjsk3nLcihNTLSzOtfMs32OJwJEwmUXoAxvVSAT7AX5npIbXXz3hlxgsw33d7yuMbnM+X8z8TvuF/qSo2rOwt0/EQCoLDhUjkVk6W/f/HBCg87S1AsE6kkBIe4s0RoV4g+UlgB7WJmt9fGhgqljcxnOZHTNQSBYABk14/tmlfal0L0H+tRuIgdEWYllXqkx6BaoTS3fEXKaJB3x1FCVCpnJ0OtDZGa1iwPImlg9S+8=----ATTACHMENT:----ODU0MTA5MDkzNjkxNTc3OCA4Mzc5NTgyMjE4NzY3NDc1IDg1NjUyNDYyNDk1NDU1ODY=