bbcode.t 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Copyright (C) 2007, 2008 Alex Schroeder <alex@emacswiki.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the
  15. # Free Software Foundation, Inc.
  16. # 59 Temple Place, Suite 330
  17. # Boston, MA 02111-1307 USA
  18. require 't/test.pl';
  19. package OddMuse;
  20. use Test::More tests => 39;
  21. add_module('bbcode.pl');
  22. run_tests(split('\n',<<'EOT'));
  23. [b]this text is bold[/b]
  24. <b>this text is bold</b>
  25. [i]this text is italic[/i]
  26. <i>this text is italic</i>
  27. [u]this text is underlined[/u]
  28. <em style="text-decoration: underline; font-style: normal;">this text is underlined</em>
  29. [s]this text is deleted[/s]
  30. <del>this text is deleted</del>
  31. [strike]this text is deleted[/strike]
  32. <del>this text is deleted</del>
  33. [color=blue]this text is blue[/color]
  34. <em style="color: blue; font-style: normal;">this text is blue</em>
  35. [size=+2]this text is two sizes larger than normal[/size]
  36. <em style="font-size: 200%; font-style: normal;">this text is two sizes larger than normal</em>
  37. [size=test]this text is two sizes larger than normal[/size]
  38. [size=test]this text is two sizes larger than normal[/size]
  39. [font=courier]this text is in the courier font[/font]
  40. <span style="font-family: courier;">this text is in the courier font</span>
  41. [url]yadda
  42. [url]yadda
  43. [quote]quoted text[/quote]
  44. <blockquote><p>quoted text</p></blockquote>
  45. [quote]first paragraph\n\nsecond paragraph[/quote]
  46. <blockquote><p>first paragraph</p><p>second paragraph</p></blockquote>
  47. [quote]quoted text[/quote]\nmore text
  48. <blockquote><p>quoted text</p></blockquote><p>more text</p>
  49. [quote]quoted text[/quote]\nmore text\nand some more\n
  50. <blockquote><p>quoted text</p></blockquote><p>more text and some more</p>
  51. [quote]quoted text[/quote]\n more text
  52. <blockquote><p>quoted text</p></blockquote><p> more text</p>
  53. [quote]quoted\ntext\n[/quote]\n more text\n
  54. <blockquote><p>quoted text </p></blockquote><p> more text</p>
  55. [code]monospaced text[/code]
  56. <pre>monospaced text</pre>
  57. [code]monospaced\n\n text[/code]
  58. <pre>monospaced\n\n text</pre>
  59. [code]monospaced text[/code]\nmore text
  60. <pre>monospaced text</pre><p>more text</p>
  61. [code]monospaced text[/code]\n more text
  62. <pre>monospaced text</pre><p> more text</p>
  63. [code]monospaced text[/code]\nmore text\nand last line
  64. <pre>monospaced text</pre><p>more text and last line</p>
  65. :) :-) :( :-(
  66. &#x1F60A; &#x1F60A; &#x1F61F; &#x1F61F;
  67. :smile: :happy: :frown: :sad:
  68. &#x1F60A; &#x1F60A; &#x1F61F; &#x1F61F;
  69. foo\n[h1]blarg
  70. foo <h1>blarg</h1>
  71. foo[h2]blarg[/h2]fnord
  72. foo<h2>blarg</h2><p>fnord</p>
  73. [h3]blarg [i]moo[/i][/h3]
  74. <h3>blarg <i>moo</i></h3>
  75. [h5][h6]blarg[/h6]foo
  76. <h5></h5><h6>blarg</h6><p>foo</p>
  77. [center][size=5]The Savage Tides[/size][/center]
  78. <div class="center" style="text-align: center"><p><em style="font-size: 500%; font-style: normal;">The Savage Tides</em></p></div>
  79. [left]This is left[/left]
  80. <div class="left" style="float: left"><p>This is left</p></div>
  81. [right]This is right[/right]
  82. <div class="right" style="float: right"><p>This is right</p></div>
  83. [list]\n[*]one\n[*]two\n[/list]
  84. <ul> <li>one </li><li>two </li></ul>
  85. [quote][list][*]one[*]two[/list][/quote]
  86. <blockquote></blockquote><ul><li>one</li><li>two</li></ul><p>[/quote]</p>
  87. [highlight]this text is highlighted[/highlight]
  88. <strong class="highlight">this text is highlighted</strong>
  89. EOT
  90. xpath_run_tests(split('\n',<<'EOT'));
  91. [url]http://wikipedia.org[/url]
  92. //a[@class="url http"][@href="http://wikipedia.org"][text()="http://wikipedia.org"]
  93. [url=http://wikipedia.org]Wikipedia[/url]
  94. //a[@class="url http"][@href="http://wikipedia.org"][text()="Wikipedia"]
  95. [img]http://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Wikipedia-logo.png/150px-Wikipedia-logo.png[/img]
  96. //img[@class="url http"][@src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Wikipedia-logo.png/150px-Wikipedia-logo.png"]
  97. [H4][url=http://example.org]mu[/url][/h4]
  98. //h4/a[@class="url http"][@href="http://example.org"][text()="mu"]
  99. EOT
  100. add_module('creole.pl');
  101. run_tests(split('\n',<<'EOT'));
  102. * [s]this text is deleted[/s]
  103. <ul><li><del>this text is deleted</del></li></ul>
  104. EOT
  105. test_page(update_page('test', '[b]Important:[/b]'),
  106. '<b>Important:</b>');