Example #1
0
    def test_internal_links(self):
        # Make sure we turn mediawiki internal links into our-style
        # internal wiki links.

        # A link to a page that doesn't exist.
        html = """<p>Some text here</p>
<p>And now a link: <a href="/mediawiki-1.16.0/index.php?title=Waverly_Road&amp;action=edit&amp;redlink=1" class="new" title="Waverly Road (page does not exist)">Waverly Road</a> woo!</p>"""
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="Waverly%20Road">Waverly Road</a> woo!</p>"""
        self.assertTrue(is_html_equal(process_html(html), expected_html))

        # A link to a page that does exist.
        html = """<p>Some text here</p>
<p>And now a link: <a href="/mediawiki-1.16.0/index.php/Ann_Arbor" title="Ann Arbor">Ann Arbor</a> woo!</p>"""
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="Ann%20Arbor">Ann Arbor</a> woo!</p>"""
        self.assertTrue(is_html_equal(process_html(html), expected_html))

        # A link to a redirect in MW.
        html = """<a href="/mediawiki-1.16.0/index.php/Ypsilanti" title="Ypsilanti" class="mw-redirect">Ypsilanti</a>"""
        expected_html = """<a href="Ypsilanti">Ypsilanti</a>"""
Example #2
0
    def test_internal_links(self):
        # Make sure we turn mediawiki internal links into our-style
        # internal wiki links.

        # A link to a page that doesn't exist.
        html = """<p>Some text here</p>
<p>And now a link: <a href="/mediawiki-1.16.0/index.php?title=Waverly_Road&amp;action=edit&amp;redlink=1" class="new" title="Waverly Road (page does not exist)">Waverly Road</a> woo!</p>"""
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="Waverly%20Road">Waverly Road</a> woo!</p>"""
        self.assertTrue(is_html_equal(process_html(html), expected_html))

        # A link to a page that does exist.
        html = """<p>Some text here</p>
<p>And now a link: <a href="/mediawiki-1.16.0/index.php/Ann_Arbor" title="Ann Arbor">Ann Arbor</a> woo!</p>"""
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="Ann%20Arbor">Ann Arbor</a> woo!</p>"""
        self.assertTrue(is_html_equal(process_html(html), expected_html))

        # A link to a redirect in MW.
        html = """<a href="/mediawiki-1.16.0/index.php/Ypsilanti" title="Ypsilanti" class="mw-redirect">Ypsilanti</a>"""
        expected_html = """<a href="Ypsilanti">Ypsilanti</a>"""
Example #3
0
 def test_google_maps(self):
     html = """<p>stuff</p>&lt;googlemap lat="42.243338" lon="-83.616152" zoom="19" scale="yes" overview="yes"&gt; &lt;/googlemap&gt;"""
     expected_html = """<p>stuff</p>"""
     self.assertTrue(is_html_equal(process_html(html, "Test pagename"), expected_html))
Example #4
0
 def test_skip_small_tag(self):
     html = """<p>this is some <small>small text</small> here.</p>"""
     expected_html = """<p>this is some small text here.</p>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #5
0
 def test_remove_edit_labels(self):
     html = """<h2><span class="editsection">[<a href="/mediawiki-1.16.0/index.php?title=After-hours_emergency&amp;action=edit&amp;section=2" title="Edit section: Water">edit</a>]</span> <span class="mw-headline" id="Water"> Water </span></h2>"""
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #6
0
 def test_remove_headline_labels(self):
     html = """<h2><span class="mw-headline" id="Water"> Water </span></h2>"""
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #7
0
 def test_fix_i_b_tags(self):
     html = """<p>Some <i>text <b>here</b></i></p><p>and <i>then</i> <b>some</b> more</p>"""
     expected_html = """<p>Some <em>text <strong>here</strong></em></p><p>and <em>then</em> <strong>some</strong> more</p>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #8
0
 def test_google_maps(self):
     html = """<p>stuff</p>&lt;googlemap lat="42.243338" lon="-83.616152" zoom="19" scale="yes" overview="yes"&gt; &lt;/googlemap&gt;"""
     expected_html = """<p>stuff</p>"""
     self.assertTrue(
         is_html_equal(process_html(html, "Test pagename"), expected_html))
Example #9
0
 def test_skip_small_tag(self):
     html = """<p>this is some <small>small text</small> here.</p>"""
     expected_html = """<p>this is some small text here.</p>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #10
0
 def test_remove_edit_labels(self):
     html = """<h2><span class="editsection">[<a href="/mediawiki-1.16.0/index.php?title=After-hours_emergency&amp;action=edit&amp;section=2" title="Edit section: Water">edit</a>]</span> <span class="mw-headline" id="Water"> Water </span></h2>"""
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #11
0
 def test_remove_headline_labels(self):
     html = """<h2><span class="mw-headline" id="Water"> Water </span></h2>"""
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))
Example #12
0
 def test_fix_i_b_tags(self):
     html = """<p>Some <i>text <b>here</b></i></p><p>and <i>then</i> <b>some</b> more</p>"""
     expected_html = """<p>Some <em>text <strong>here</strong></em></p><p>and <em>then</em> <strong>some</strong> more</p>"""
     self.assertTrue(is_html_equal(process_html(html), expected_html))