UppercaseDelimiterProcessor.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * Additional emphasis processing code based on commonmark-java (https://github.com/atlassian/commonmark-java)
  9. * - (c) Atlassian Pty Ltd
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace League\CommonMark\Tests\Functional\Delimiter;
  15. use League\CommonMark\Delimiter\DelimiterInterface;
  16. use League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface;
  17. use League\CommonMark\Node\Inline\AbstractStringContainer;
  18. final class UppercaseDelimiterProcessor implements DelimiterProcessorInterface
  19. {
  20. public function getOpeningCharacter(): string
  21. {
  22. return '{';
  23. }
  24. public function getClosingCharacter(): string
  25. {
  26. return '}';
  27. }
  28. public function getMinLength(): int
  29. {
  30. return 1;
  31. }
  32. public function getDelimiterUse(DelimiterInterface $opener, DelimiterInterface $closer): int
  33. {
  34. return 1;
  35. }
  36. public function process(AbstractStringContainer $opener, AbstractStringContainer $closer, int $delimiterUse): void
  37. {
  38. $upperCase = new UppercaseText();
  39. $tmp = $opener->next();
  40. while ($tmp !== null && $tmp !== $closer) {
  41. $next = $tmp->next();
  42. $upperCase->appendChild($tmp);
  43. $tmp = $next;
  44. }
  45. $opener->insertAfter($upperCase);
  46. }
  47. }