CommonMarkJSRegressionTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
  9. * - (c) John MacFarlane
  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;
  15. /**
  16. * Tests the parser against the CommonMark spec
  17. */
  18. final class CommonMarkJSRegressionTest extends AbstractSpecTest
  19. {
  20. protected function getFileName(): string
  21. {
  22. return __DIR__ . '/../../vendor/commonmark/commonmark.js/test/regression.txt';
  23. }
  24. /**
  25. * @deprecated
  26. *
  27. * We can't currently render spec example 18 exactly how the upstream library does. We'll likely need to overhaul
  28. * our rendering approach in order to fix that, so we'll use this temporary workaround for now.
  29. */
  30. public function dataProvider(): \Generator
  31. {
  32. foreach (parent::dataProvider() as $example) {
  33. if ($example['number'] === 18) {
  34. yield \str_replace('</script></li>', "</script>\n</li>", $example);
  35. } else {
  36. yield $example;
  37. }
  38. }
  39. }
  40. }