Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

66 lines
1.6KB

  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2014 Carsten Brandt
  4. * @license https://github.com/cebe/markdown/blob/master/LICENSE
  5. * @link https://github.com/cebe/markdown#readme
  6. */
  7. namespace cebe\markdown\tests;
  8. use cebe\markdown\GithubMarkdown;
  9. /**
  10. * Test case for the github flavored markdown.
  11. *
  12. * @author Carsten Brandt <mail@cebe.cc>
  13. * @group github
  14. */
  15. class GithubMarkdownTest extends BaseMarkdownTest
  16. {
  17. public function createMarkdown()
  18. {
  19. return new GithubMarkdown();
  20. }
  21. public function getDataPaths()
  22. {
  23. return [
  24. 'markdown-data' => __DIR__ . '/markdown-data',
  25. 'github-data' => __DIR__ . '/github-data',
  26. ];
  27. }
  28. public function testNewlines()
  29. {
  30. $markdown = $this->createMarkdown();
  31. $this->assertEquals("This is text<br />\nnewline\nnewline.", $markdown->parseParagraph("This is text \nnewline\nnewline."));
  32. $markdown->enableNewlines = true;
  33. $this->assertEquals("This is text<br />\nnewline<br />\nnewline.", $markdown->parseParagraph("This is text \nnewline\nnewline."));
  34. $this->assertEquals("<p>This is text</p>\n<p>newline<br />\nnewline.</p>\n", $markdown->parse("This is text\n\nnewline\nnewline."));
  35. }
  36. public function dataFiles()
  37. {
  38. $files = parent::dataFiles();
  39. foreach($files as $i => $f) {
  40. // skip files that are different in github MD
  41. if ($f[0] === 'markdown-data' && (
  42. $f[1] === 'list-marker-in-paragraph' ||
  43. $f[1] === 'dense-block-markers'
  44. )) {
  45. unset($files[$i]);
  46. }
  47. }
  48. return $files;
  49. }
  50. public function testKeepZeroAlive()
  51. {
  52. $parser = $this->createMarkdown();
  53. $this->assertEquals("0", $parser->parseParagraph("0"));
  54. $this->assertEquals("<p>0</p>\n", $parser->parse("0"));
  55. }
  56. }