示例#1
0
 def test_convert_div(self):
     html = """<div>Blah</div>"""
     expected_html = """<table><tr><td>Blah</td></tr></table>"""
     self.assertTrue(is_html_equal(mediawiki.process_html(html, "Test convert div"), expected_html))
     html = """<div class="adr">123 Main Street</div>"""
     expected_html = """<span class="adr">123 Main Street</span>"""
     self.assertTrue(is_html_equal(mediawiki.process_html(html, "Test convert special div"), expected_html))
示例#2
0
 def test_convert_div(self):
     html = """<div>Blah</div>"""
     expected_html = """<table><tr><td>Blah</td></tr></table>"""
     self.assertTrue(
         is_html_equal(mediawiki.process_html(html, "Test convert div"),
                       expected_html))
     html = """<div class="adr">123 Main Street</div>"""
     expected_html = """<span class="adr">123 Main Street</span>"""
     self.assertTrue(
         is_html_equal(
             mediawiki.process_html(html, "Test convert special div"),
             expected_html))
示例#3
0
    def test_external_links(self):
        # Make sure we preserve external links.

        html = """<p>Some text here</p>
<p>And now a link: <a href="http://example.org/testing/?hi=1&what=there">Waverly Road</a> woo!</p>""" % self.env
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="http://example.org/testing/?hi=1&what=there">Waverly Road</a> woo!</p>""" % self.env
        self.assertTrue(is_html_equal(mediawiki.process_html(html), expected_html))

        html = """<p><a href="http://news.google.com/newspapers?id=eCVbAAAAIBAJ&amp;sjid=ZU8NAAAAIBAJ&amp;pg=3926%2C4841530" class="external text">Ann Arbor Argus</a>, Feb. 27, 1891.</p>"""
        expected_html = """<p><a href="http://news.google.com/newspapers?id=eCVbAAAAIBAJ&amp;sjid=ZU8NAAAAIBAJ&amp;pg=3926%2C4841530" class="external text">Ann Arbor Argus</a>, Feb. 27, 1891.</p>"""
        self.assertTrue(is_html_equal(mediawiki.process_html(html), expected_html))
示例#4
0
    def test_external_links(self):
        # Make sure we preserve external links.

        html = """<p>Some text here</p>
<p>And now a link: <a href="http://example.org/testing/?hi=1&what=there">Waverly Road</a> woo!</p>""" % self.env
        expected_html = """<p>Some text here</p>
<p>And now a link: <a href="http://example.org/testing/?hi=1&what=there">Waverly Road</a> woo!</p>""" % self.env
        self.assertTrue(
            is_html_equal(mediawiki.process_html(html), expected_html))

        html = """<p><a href="http://news.google.com/newspapers?id=eCVbAAAAIBAJ&amp;sjid=ZU8NAAAAIBAJ&amp;pg=3926%2C4841530" class="external text">Ann Arbor Argus</a>, Feb. 27, 1891.</p>"""
        expected_html = """<p><a href="http://news.google.com/newspapers?id=eCVbAAAAIBAJ&amp;sjid=ZU8NAAAAIBAJ&amp;pg=3926%2C4841530" class="external text">Ann Arbor Argus</a>, Feb. 27, 1891.</p>"""
        self.assertTrue(
            is_html_equal(mediawiki.process_html(html), expected_html))
示例#5
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="%(SCRIPT_PATH)s?title=Waverly_Road&amp;action=edit&amp;redlink=1" class="new" title="Waverly Road (page does not exist)">Waverly Road</a> woo!</p>""" % self.env
        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(mediawiki.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="%(SCRIPT_PATH)s/Ann_Arbor" title="Ann Arbor">Ann Arbor</a> woo!</p>""" % self.env
        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(mediawiki.process_html(html), expected_html))

        # A link to a redirect in MW.
        html = """<a href="%(SCRIPT_PATH)s/Ypsilanti" title="Ypsilanti" class="mw-redirect">Ypsilanti</a>""" % self.env
        expected_html = """<a href="Ypsilanti">Ypsilanti</a>"""
示例#6
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="%(SCRIPT_PATH)s?title=Waverly_Road&amp;action=edit&amp;redlink=1" class="new" title="Waverly Road (page does not exist)">Waverly Road</a> woo!</p>""" % self.env
        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(mediawiki.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="%(SCRIPT_PATH)s/Ann_Arbor" title="Ann Arbor">Ann Arbor</a> woo!</p>""" % self.env
        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(mediawiki.process_html(html), expected_html))

        # A link to a redirect in MW.
        html = """<a href="%(SCRIPT_PATH)s/Ypsilanti" title="Ypsilanti" class="mw-redirect">Ypsilanti</a>""" % self.env
        expected_html = """<a href="Ypsilanti">Ypsilanti</a>"""
示例#7
0
 def test_fix_embed(self):
     html = """<p><object width="320" height="245"><param name="movie" value="http://www.archive.org/flow/FlowPlayerLight.swf?config=%7Bembedded%3Atrue%2CshowFullScreenButton%3Atrue%2CshowMuteVolumeButton%3Atrue%2CshowMenu%3Atrue%2CautoBuffering%3Atrue%2CautoPlay%3Afalse%2CinitialScale%3A%27fit%27%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Ctrue%2Cfalse%5D%2CusePlayOverlay%3Afalse%2CshowPlayListButtons%3Atrue%2CplayList%3A%5B%7Burl%3A%27ssfGNSTRIK1%2FssfGNSTRIK1%5F512kb%2Emp4%27%7D%5D%2CcontrolBarGloss%3A%27high%27%2CshowVolumeSlider%3Atrue%2CbaseURL%3A%27http%3A%2F%2Fwww%2Earchive%2Eorg%2Fdownload%2F%27%2Cloop%3Afalse%2CcontrolBarBackgroundColor%3A%270x000000%27%7D"/><param name="wmode" value="transparent"/><embed height="245" width="320" wmode="transparent" type="application/x-shockwave-flash" src="http://www.archive.org/flow/FlowPlayerLight.swf?config=%7Bembedded%3Atrue%2CshowFullScreenButton%3Atrue%2CshowMuteVolumeButton%3Atrue%2CshowMenu%3Atrue%2CautoBuffering%3Atrue%2CautoPlay%3Afalse%2CinitialScale%3A%27fit%27%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Ctrue%2Cfalse%5D%2CusePlayOverlay%3Afalse%2CshowPlayListButtons%3Atrue%2CplayList%3A%5B%7Burl%3A%27ssfGNSTRIK1%2FssfGNSTRIK1%5F512kb%2Emp4%27%7D%5D%2CcontrolBarGloss%3A%27high%27%2CshowVolumeSlider%3Atrue%2CbaseURL%3A%27http%3A%2F%2Fwww%2Earchive%2Eorg%2Fdownload%2F%27%2Cloop%3Afalse%2CcontrolBarBackgroundColor%3A%270x000000%27%7D"/></object></p>"""
     expected_html = '<p><span class="plugin embed">&lt;iframe width="320" height="245" src="http://www.archive.org/embed/ssfGNSTRIK1"/&gt;</span></p>'
     self.assertEqual(mediawiki.process_html(html, "Test fix embeds"), expected_html)
示例#8
0
    def test_double_table(self):
        html = """<table>
	<tbody>
		<tr>
			<td>
				<table style="width: 30em;">
					<tbody>
						<tr>
							<th colspan="2" style="background-color: #ccccff; text-align: center;">
								<strong>Lube Cruise</strong></th>
						</tr>
						<tr>
							<th>
								Business Name</th>
							<td>
								Lube Cruise</td>
						</tr>
						<tr>
							<th>
								Address</th>
							<td>
								5794 Fake</td>
						</tr>
						<tr>
							<th>
								City</th>
							<td>
								Fake</td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>"""
        expected_html = """<table style="width: 30em;">
					<tbody>
						<tr>
							<th colspan="2" style="background-color: #ccccff; text-align: center;">
								<strong>Lube Cruise</strong></th>
						</tr>
						<tr>
							<th>
								Business Name</th>
							<td>
								Lube Cruise</td>
						</tr>
						<tr>
							<th>
								Address</th>
							<td>
								5794 Fake</td>
						</tr>
						<tr>
							<th>
								City</th>
							<td>
								Fake</td>
						</tr>
					</tbody>
				</table>
"""
        self.assertTrue(is_html_equal(mediawiki.process_html(html, "Test double table"), expected_html))
示例#9
0
 def test_remove_spans(self):
     html = """<p><span class="fn something">hi there <a href="http://example.com/">dude</a></span></p>"""
     expected_html = """<p>hi there <a href="http://example.com/">dude</a></p>"""
     self.assertTrue(
         is_html_equal(mediawiki.process_html(html, "Test remove span"),
                       expected_html))
示例#10
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(mediawiki.process_html(html), expected_html))
示例#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(mediawiki.process_html(html), expected_html))
示例#12
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(mediawiki.process_html(html), expected_html))
示例#13
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(mediawiki.process_html(html), expected_html))
示例#14
0
 def test_fix_embed(self):
     html = """<p><object width="320" height="245"><param name="movie" value="http://www.archive.org/flow/FlowPlayerLight.swf?config=%7Bembedded%3Atrue%2CshowFullScreenButton%3Atrue%2CshowMuteVolumeButton%3Atrue%2CshowMenu%3Atrue%2CautoBuffering%3Atrue%2CautoPlay%3Afalse%2CinitialScale%3A%27fit%27%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Ctrue%2Cfalse%5D%2CusePlayOverlay%3Afalse%2CshowPlayListButtons%3Atrue%2CplayList%3A%5B%7Burl%3A%27ssfGNSTRIK1%2FssfGNSTRIK1%5F512kb%2Emp4%27%7D%5D%2CcontrolBarGloss%3A%27high%27%2CshowVolumeSlider%3Atrue%2CbaseURL%3A%27http%3A%2F%2Fwww%2Earchive%2Eorg%2Fdownload%2F%27%2Cloop%3Afalse%2CcontrolBarBackgroundColor%3A%270x000000%27%7D"/><param name="wmode" value="transparent"/><embed height="245" width="320" wmode="transparent" type="application/x-shockwave-flash" src="http://www.archive.org/flow/FlowPlayerLight.swf?config=%7Bembedded%3Atrue%2CshowFullScreenButton%3Atrue%2CshowMuteVolumeButton%3Atrue%2CshowMenu%3Atrue%2CautoBuffering%3Atrue%2CautoPlay%3Afalse%2CinitialScale%3A%27fit%27%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Ctrue%2Cfalse%5D%2CusePlayOverlay%3Afalse%2CshowPlayListButtons%3Atrue%2CplayList%3A%5B%7Burl%3A%27ssfGNSTRIK1%2FssfGNSTRIK1%5F512kb%2Emp4%27%7D%5D%2CcontrolBarGloss%3A%27high%27%2CshowVolumeSlider%3Atrue%2CbaseURL%3A%27http%3A%2F%2Fwww%2Earchive%2Eorg%2Fdownload%2F%27%2Cloop%3Afalse%2CcontrolBarBackgroundColor%3A%270x000000%27%7D"/></object></p>"""
     expected_html = '<p><span class="plugin embed">&lt;iframe width="320" height="245" src="http://www.archive.org/embed/ssfGNSTRIK1"/&gt;</span></p>'
     self.assertEqual(mediawiki.process_html(html, "Test fix embeds"),
                      expected_html)
示例#15
0
    def test_double_table(self):
        html = """<table>
	<tbody>
		<tr>
			<td>
				<table style="width: 30em;">
					<tbody>
						<tr>
							<th colspan="2" style="background-color: #ccccff; text-align: center;">
								<strong>Lube Cruise</strong></th>
						</tr>
						<tr>
							<th>
								Business Name</th>
							<td>
								Lube Cruise</td>
						</tr>
						<tr>
							<th>
								Address</th>
							<td>
								5794 Fake</td>
						</tr>
						<tr>
							<th>
								City</th>
							<td>
								Fake</td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>"""
        expected_html = """<table style="width: 30em;">
					<tbody>
						<tr>
							<th colspan="2" style="background-color: #ccccff; text-align: center;">
								<strong>Lube Cruise</strong></th>
						</tr>
						<tr>
							<th>
								Business Name</th>
							<td>
								Lube Cruise</td>
						</tr>
						<tr>
							<th>
								Address</th>
							<td>
								5794 Fake</td>
						</tr>
						<tr>
							<th>
								City</th>
							<td>
								Fake</td>
						</tr>
					</tbody>
				</table>
"""
        self.assertTrue(
            is_html_equal(mediawiki.process_html(html, "Test double table"),
                          expected_html))
示例#16
0
 def test_remove_edit_labels(self):
     html = """<h2><span class="editsection">[<a href="%(SCRIPT_PATH)s?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>""" % self.env
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(
         is_html_equal(mediawiki.process_html(html), expected_html))
示例#17
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(mediawiki.process_html(html), expected_html))
示例#18
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(mediawiki.process_html(html), expected_html))
示例#19
0
 def test_remove_edit_labels(self):
     html = """<h2><span class="editsection">[<a href="%(SCRIPT_PATH)s?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>""" % self.env
     expected_html = """<h2>Water</h2>"""
     self.assertTrue(is_html_equal(mediawiki.process_html(html), expected_html))
示例#20
0
 def test_remove_spans(self):
     html = """<p><span class="fn something">hi there <a href="http://example.com/">dude</a></span></p>"""
     expected_html = """<p>hi there <a href="http://example.com/">dude</a></p>"""
     self.assertTrue(is_html_equal(mediawiki.process_html(html, "Test remove span"), expected_html))
示例#21
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(mediawiki.process_html(html, "Test pagename"), expected_html))
示例#22
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(mediawiki.process_html(html, "Test pagename"),
                       expected_html))