markdown-rule.t 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/usr/bin/env perl
  2. # Copyright (C) 2014–2017 Alex Schroeder <alex@gnu.org>
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. require './t/test.pl';
  17. package OddMuse;
  18. use Test::More tests => 53;
  19. add_module('markdown-rule.pl');
  20. add_module('bbcode.pl');
  21. # ApplyRules strips trailing newlines, so write tests accordingly.
  22. run_tests(split(/\n/,<<'EOT'));
  23. 1. one
  24. <ol><li>one</li></ol>
  25. 2. one
  26. 2. one
  27. 1. one\n2. two
  28. <ol><li>one</li><li>two</li></ol>
  29. 1. one\n\n2. two
  30. <ol><li>one</li><li>two</li></ol>
  31. 1. one\n 2. two\n 3. three
  32. <ol><li>one<ol><li>two</li><li>three</li></ol></li></ol>
  33. 1. one\n\n 2. two\n\n 3. three
  34. <ol><li>one<ol><li>two</li><li>three</li></ol></li></ol>
  35. - one
  36. <ul><li>one</li></ul>
  37. - one\n-- Alex
  38. <ul><li>one -- Alex</li></ul>
  39. - one\n\n- Alex
  40. <ul><li>one</li><li>Alex</li></ul>
  41. * one\n * two
  42. <ul><li>one<ul><li>two</li></ul></li></ul>
  43. * one\n * two\n* three
  44. <ul><li>one<ul><li>two</li></ul></li><li>three</li></ul>
  45. 1. one\n- two
  46. <ol><li>one</li></ol><ul><li>two</li></ul>
  47. this is ***bold italic*** yo!
  48. this is <em><strong>bold italic</strong></em> yo!
  49. this is **bold**
  50. this is <strong>bold</strong>
  51. **bold**
  52. <strong>bold</strong>
  53. *italic*
  54. <em>italic</em>
  55. *italic* less.
  56. <em>italic</em> less.
  57. *italic.* more.
  58. <em>italic.</em> more.
  59. __underline__
  60. <em style="font-style: normal; text-decoration: underline">underline</em>
  61. _underline_
  62. <em style="font-style: normal; text-decoration: underline">underline</em>
  63. _italic._ more.
  64. <em style="font-style: normal; text-decoration: underline">italic.</em> more.
  65. //italic//
  66. <em>italic</em>
  67. /italic/
  68. <em>italic</em>
  69. /italic./ more.
  70. <em>italic.</em> more.
  71. foo\nbar
  72. foo bar
  73. foo\n===\nbar
  74. <h2>foo</h2><p>bar</p>
  75. foo\n---\nbar
  76. <h3>foo</h3><p>bar</p>
  77. foo\n=== bar
  78. foo === bar
  79. foo\n=\nbar
  80. <h2>foo</h2><p>bar</p>
  81. # foo
  82. <h1>foo</h1>
  83. ## foo
  84. <h2>foo</h2>
  85. ### foo
  86. <h3>foo</h3>
  87. #### foo
  88. <h4>foo</h4>
  89. ##### foo
  90. <h5>foo</h5>
  91. ###### foo
  92. <h6>foo</h6>
  93. ####### foo
  94. <h6># foo</h6>
  95. ## foo ##
  96. <h2>foo ##</h2>
  97. bar\n##foo\nbar
  98. bar <h2>foo</h2><p>bar</p>
  99. ```\nfoo\n```\nbar
  100. <pre>foo</pre><p>bar</p>
  101. ```\nfoo\n```
  102. <pre>foo</pre>
  103. ```\nfoo\n``` bar
  104. ``` foo ``` bar
  105. `bar`
  106. <code>bar</code>
  107. |a|b|\n|c|d|\nbar
  108. <table><tr><th>a</th><th>b</th></tr><tr><td>c</td><td>d</td></tr></table><p>bar</p>
  109. |a|b|\n|c|d|
  110. <table><tr><th>a</th><th>b</th></tr><tr><td>c</td><td>d</td></tr></table>
  111. |a
  112. <table><tr><th>a</th></tr></table>
  113. |*foo*
  114. <table><tr><th><em>foo</em></th></tr></table>
  115. |/foo/
  116. <table><tr><th><em>foo</em></th></tr></table>
  117. |_foo_
  118. <table><tr><th><em style="font-style: normal; text-decoration: underline">foo</em></th></tr></table>
  119. foo ~~bar~~
  120. foo <del>bar</del>
  121. pay 1.-/month
  122. pay 1.-/month
  123. EOT
  124. xpath_run_tests(split('\n',<<'EOT'));
  125. [example](http://example.com/)
  126. //a[@class="url http"][@href="http://example.com/"][text()="example"]
  127. [an example](http://example.com/)
  128. //a[@class="url http"][@href="http://example.com/"][text()="an example"]
  129. [an example](http://example.com/ "Title")
  130. //a[@class="url http"][@href="http://example.com/"][@title="Title"][text()="an example"]
  131. EOT