test/parser_test.rb in trac-wiki-0.1.3 vs test/parser_test.rb in trac-wiki-0.1.5

- old
+ new

@@ -2,14 +2,10 @@ class Bacon::Context def tc(html, wiki, options = {}) TracWiki.render(wiki, options).should.equal html end - - def tce(html, wiki) - tc(html, wiki, :extensions => true) - end end describe TracWiki::Parser do it 'should not parse linkd' do tc "<p>[[ahoj]]</p>\n", "[[ahoj]]", :no_link => true @@ -121,15 +117,31 @@ # By example tc "<p><em>This is <strong>also</strong> good.</em></p>\n", "''This is **also** good.''" end + it 'should parse math' do + tc "<p>\\( the \\)</p>\n", '$the$', math: true + tc "<p>test \\( the \\) west</p>\n", 'test $the$ west', math: true + tc "<p>test \\( e^{i\\pi} \\) test</p>\n", 'test $e^{i\pi}$ test', math: true + tc "<p>test $ e<sup>{i\\pi} test</sup></p>\n", 'test $ e^{i\pi} test', math: true + tc "<p>$the$</p>\n", '$the$', math: false + + tc "<p>ahoj</p>\n$$e^{i\\pi}$$\n<p>nazdar</p>\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: true + tc "<p>ahoj $$e<sup>{i\\pi}$$ nazdar</sup></p>\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: false + end it 'should parse headings' do # Only three differed sized levels of heading are required. tc "<h1>Heading 1</h1>", "= Heading 1 =" tc "<h2>Heading 2</h2>", "== Heading 2 ==" tc "<h3>Heading 3</h3>", "=== Heading 3 ===" + tc "<a name=\"HE3\"/><h3>Heading 3</h3>", "=== Heading 3 === #HE3" + tc "<a name=\"Heading-3\"/><h3>Heading 3</h3>", "=== Heading 3 === #Heading-3" + tc "<a name=\"Heading/3\"/><h3>Heading 3</h3>", "=== Heading 3 === #Heading/3" + tc "<a name=\"Heading/3\"/><h3>Heading 3</h3>", "=== Heading 3 === #Heading/3 " + tc "<a name=\"Heading&lt;3&gt;\"/><h3>Heading 3</h3>", "=== Heading 3 === #Heading<3>" + tc "<a name=\"Heading'&quot;3&quot;'\"/><h3>Heading 3</h3>", "=== Heading 3 === #Heading'\"3\"'" # WARNING: Optional feature, not specified in tc "<h4>Heading 4</h4>", "==== Heading 4 ====" tc "<h5>Heading 5</h5>", "===== Heading 5 =====" tc "<h6>Heading 6</h6>", "====== Heading 6 ======" @@ -746,26 +758,28 @@ it 'should parse bold combo' do tc("<p><strong>bold and</strong></p>\n<table><tr><td>table</td></tr></table><p>end<strong></strong></p>\n", "**bold and\n||table||\nend**") end - it 'should support extensions' do - tce("<p>This is <u>underlined</u></p>\n", - "This is __underlined__") + it 'should support font styles below' do + tc("<p>This is <u>underlined</u></p>\n", + "This is __underlined__") - tce("<p>This is <del>deleted</del></p>\n", - "This is ~~deleted~~") + tc("<p>This is <del>deleted</del></p>\n", + "This is ~~deleted~~") - tce("<p>This is <sup>super</sup></p>\n", - "This is ^super^") + tc("<p>This is <sup>super</sup></p>\n", + "This is ^super^") - tce("<p>This is <sub>sub</sub></p>\n", - "This is ,,sub,,") + tc("<p>This is <sub>sub</sub></p>\n", + "This is ,,sub,,") + end - tce("<p>&#174;</p>\n", "(R)") - tce("<p>&#174;</p>\n", "(r)") - tce("<p>&#169;</p>\n", "(C)") - tce("<p>&#169;</p>\n", "(c)") + it 'should not support signs' do + TracWiki.render("(R)").should.not.equal "<p>&#174;</p>\n" + TracWiki.render("(r)").should.not.equal "<p>&#174;</p>\n" + TracWiki.render("(C)").should.not.equal "<p>&#169;</p>\n" + TracWiki.render("(c)").should.not.equal "<p>&#169;</p>\n" end it 'should support no_escape' do tc("<p><a href=\"a%2Fb%2Fc\">a/b/c</a></p>\n", "[[a/b/c]]") tc("<p><a href=\"a%2Fb%2Fc\">a/b/c</a></p>\n", "[a/b/c]")