本文整理汇总了Python中wiki.tests.normalize_html函数的典型用法代码示例。如果您正苦于以下问题:Python normalize_html函数的具体用法?Python normalize_html怎么用?Python normalize_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalize_html函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_raw_section_source
def test_raw_section_source(self):
"""The raw source for a document section can be requested"""
client = LocalizingClient()
client.login(username='admin', password='testpass')
d, r = doc_rev("""
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
""")
expected = """
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
"""
response = client.get('%s?section=s2&raw=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:26,代码来源:test_views.py
示例2: test_form_save_section
def test_form_save_section(self):
d, r = doc_rev(
"""
<h1 id="s1">s1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">s2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">s3</h1>
<p>test</p>
<p>test</p>
"""
)
replace_content = """
<h1 id="s2">New stuff</h1>
<p>new stuff</p>
"""
expected = """
<h1 id="s1">s1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">New stuff</h1>
<p>new stuff</p>
<h1 id="s3">s3</h1>
<p>test</p>
<p>test</p>
"""
rev_form = RevisionForm({"content": replace_content}, instance=r, section_id="s2")
new_rev = rev_form.save(r.creator, d)
eq_(normalize_html(expected), normalize_html(new_rev.content))
开发者ID:Boldewyn,项目名称:kuma,代码行数:35,代码来源:test_forms.py
示例3: test_keep_markup
def test_keep_markup(self):
content = """
<h2 id="Summary">Summary</h2>
<p>The <strong>Document Object Model </strong>
(<strong>DOM</strong>) is an API for <a href="/en-US/docs/HTML"
title="en-US/docs/HTML">HTML</a> and <a href="/en-US/docs/XML"
title="en-US/docs/XML">XML</a> documents. It provides a structural
representation of the document, enabling you to modify its content
and visual presentation by using a scripting language such as <a
href="/en-US/docs/JavaScript"
title="https://developer.mozilla.org/en-US/docs/JavaScript">
JavaScript</a>.</span></p>
"""
expected = """
The <strong>Document Object Model </strong>
(<strong>DOM</strong>) is an API for <a href="/en-US/docs/HTML"
title="en-US/docs/HTML">HTML</a> and <a href="/en-US/docs/XML"
title="en-US/docs/XML">XML</a> documents. It provides a structural
representation of the document, enabling you to modify its content
and visual presentation by using a scripting language such as <a
href="/en-US/docs/JavaScript"
title="https://developer.mozilla.org/en-US/docs/JavaScript">
JavaScript</a>.</span>
"""
eq_(normalize_html(expected), normalize_html(get_seo_description(content, "en-US", False)))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:25,代码来源:test_content.py
示例4: test_basic_section_replace
def test_basic_section_replace(self):
doc_src = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
replace_src = """
<h1 id="s2">Head 2</h1>
<p>replacement worked</p>
"""
expected = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>replacement worked</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
result = wiki.content.parse(doc_src).replaceSection(id="s2", replace_src=replace_src).serialize()
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:28,代码来源:test_content.py
示例5: test_raw_with_editing_links_source
def test_raw_with_editing_links_source(self):
"""The raw source for a document can be requested, with section editing
links"""
client = LocalizingClient()
client.login(username='admin', password='testpass')
d, r = doc_rev("""
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
""")
expected = """
<h1 id="s1"><a class="edit-section" data-section-id="s1" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s1" href="/en-US/docs/%(slug)s$edit?section=s1&edit_links=true" title="Edit section">Edit</a>Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2"><a class="edit-section" data-section-id="s2" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s2" href="/en-US/docs/%(slug)s$edit?section=s2&edit_links=true" title="Edit section">Edit</a>Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3"><a class="edit-section" data-section-id="s3" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s3" href="/en-US/docs/%(slug)s$edit?section=s3&edit_links=true" title="Edit section">Edit</a>Head 3</h1>
<p>test</p>
<p>test</p>
""" % {'slug': d.slug}
response = client.get('%s?raw=true&edit_links=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:33,代码来源:test_views.py
示例6: test_section_edit_links
def test_section_edit_links(self):
doc_src = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h2 id="s2">Head 2</h2>
<p>test</p>
<p>test</p>
<h3 id="s3">Head 3</h3>
<p>test</p>
<p>test</p>
"""
expected = """
<h1 id="s1"><a class="edit-section" data-section-id="s1" data-section-src-url="/en-US/docs/some-slug?raw=true&section=s1" href="/en-US/docs/some-slug$edit?section=s1&edit_links=true" title="Edit section">Edit</a>Head 1</h1>
<p>test</p>
<p>test</p>
<h2 id="s2"><a class="edit-section" data-section-id="s2" data-section-src-url="/en-US/docs/some-slug?raw=true&section=s2" href="/en-US/docs/some-slug$edit?section=s2&edit_links=true" title="Edit section">Edit</a>Head 2</h2>
<p>test</p>
<p>test</p>
<h3 id="s3"><a class="edit-section" data-section-id="s3" data-section-src-url="/en-US/docs/some-slug?raw=true&section=s3" href="/en-US/docs/some-slug$edit?section=s3&edit_links=true" title="Edit section">Edit</a>Head 3</h3>
<p>test</p>
<p>test</p>
"""
result = wiki.content.parse(doc_src).injectSectionEditingLinks("some-slug", "en-US").serialize()
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:25,代码来源:test_content.py
示例7: test_ignore_heading_section_replace
def test_ignore_heading_section_replace(self):
doc_src = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
replace_src = """
<p>replacement worked yay hooray</p>
"""
expected = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>replacement worked yay hooray</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
result = (wiki.content
.parse(doc_src)
.replaceSection(id="s2",
replace_src=replace_src,
ignore_heading=True)
.serialize())
eq_(normalize_html(expected), normalize_html(result))
开发者ID:arkanDEV,项目名称:kuma,代码行数:32,代码来源:test_content.py
示例8: test_form_loaded_with_section
def test_form_loaded_with_section(self):
"""RevisionForm given section_id should load initial content for only
one section"""
d, r = doc_rev(
"""
<h1 id="s1">s1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">s2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">s3</h1>
<p>test</p>
<p>test</p>
"""
)
expected = """
<h1 id="s2">s2</h1>
<p>test</p>
<p>test</p>
"""
rev_form = RevisionForm(instance=r, section_id="s2")
eq_(normalize_html(expected), normalize_html(rev_form.initial["content"]))
开发者ID:Boldewyn,项目名称:kuma,代码行数:25,代码来源:test_forms.py
示例9: test_editor_safety_filter
def test_editor_safety_filter(self):
"""Markup that's hazardous for editing should be stripped"""
doc_src = """
<svg><circle onload=confirm(3)>
<h1 class="header1">Header One</h1>
<p>test</p>
<section>
<h1 class="header2">Header Two</h1>
<p>test</p>
</section>
<h1 class="header3">Header Three</h1>
<p>test</p>
"""
expected_src = """
<svg><circle>
<h1 class="header1">Header One</h1>
<p>test</p>
<section>
<h1 class="header2">Header Two</h1>
<p>test</p>
</section>
<h1 class="header3">Header Three</h1>
<p>test</p>
"""
result_src = (wiki.content.parse(doc_src)
.filterEditorSafety()
.serialize())
eq_(normalize_html(expected_src), normalize_html(result_src))
开发者ID:arkanDEV,项目名称:kuma,代码行数:28,代码来源:test_content.py
示例10: test_code_syntax_conversion
def test_code_syntax_conversion(self):
doc_src = """
<h2>Some JavaScript</h2>:
<pre class="deki-transform" function="syntax.JavaScript">
function foo(){
alert("bar");
}
</pre>
<pre>Some CSS:</pre>
<pre class="dek-trans" function="syntax.CSS">
.dek-trans { color: red; }
</pre>
"""
expected = """
<h2>Some JavaScript</h2>:
<pre class="brush: js">
function foo(){
alert("bar");
}
</pre>
<pre>Some CSS:</pre>
<pre class="brush: css">
.dek-trans { color: red; }
</pre>
"""
result = wiki.content.parse(doc_src).filter(CodeSyntaxFilter).serialize()
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:27,代码来源:test_content.py
示例11: test_generate_toc_h2
def test_generate_toc_h2(self):
doc_src = """
<h2 id="HTML">HTML</h2>
<h3 id="HTML5_canvas_element">HTML5 <code>canvas</code> element</h3>
<h2 id="JavaScript">JavaScript</h2>
JavaScript is awesome.
<h3 id="WebGL">WebGL</h3>
<h3 id="Audio">Audio</h3>
<h4 id="Audio-API">Audio API</h4>
<h2 id="CSS">CSS</h2>
<h4 id="CSS_transforms">CSS transforms</h4>
<h3 id="Gradients">Gradients</h3>
<h4 id="Scaling_backgrounds">Scaling backgrounds</h4>
"""
expected = """
<li><a rel="internal" href="#HTML">HTML</a>
</li>
<li><a rel="internal" href="#JavaScript">JavaScript</a>
</li>
<li><a rel="internal" href="#CSS">CSS</a>
</li>
"""
result = (wiki.content
.parse(doc_src)
.filter(H2TOCFilter).serialize())
eq_(normalize_html(expected), normalize_html(result))
开发者ID:arkanDEV,项目名称:kuma,代码行数:26,代码来源:test_content.py
示例12: test_multilevel_implicit_section_extract
def test_multilevel_implicit_section_extract(self):
doc_src = """
<p>test</p>
<h1 id="s4">Head 4</h1>
<p>test</p>
<p>test</p>
<h2 id="s4-1">Head 4-1</h2>
<p>test</p>
<p>test</p>
<h3 id="s4-2">Head 4-1-1</h3>
<p>test</p>
<p>test</p>
<h1 id="s4-next">Head</h1>
<p>test</p>
"""
expected = """
<h1 id="s4">Head 4</h1>
<p>test</p>
<p>test</p>
<h2 id="s4-1">Head 4-1</h1>
<p>test</p>
<p>test</p>
<h3 id="s4-2">Head 4-1-1</h1>
<p>test</p>
<p>test</p>
"""
result = wiki.content.parse(doc_src).extractSection(id="s4").serialize()
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:30,代码来源:test_content.py
示例13: test_generate_toc
def test_generate_toc(self):
doc_src = """
<h1 id="HTML">HTML</h1>
<h2 id="HTML5">HTML5</h2>
<h1 id="JavaScript">JavaScript</h1>
JavaScript is awesome.
<h2 id="WebGL">WebGL</h2>
<h2 id="Audio">Audio</h2>
<h3 id="Audio-API">Audio API</h3>
<h1 id="CSS">CSS</h1>
"""
expected = """
<li><a rel="internal" href="#HTML">HTML</a>
<ol>
<li><a rel="internal" href="#HTML5">HTML5</a></li>
</ol>
</li>
<li><a rel="internal" href="#JavaScript">JavaScript</a>
<ol>
<li><a rel="internal" href="#WebGL">WebGL</a>
<li><a rel="internal" href="#Audio">Audio</a>
<ol>
<li><a rel="internal" href="#Audio-API">Audio API</a></li>
</ol>
</li>
</ol>
</li>
<li><a rel="internal" href="#CSS">CSS</a></li>
"""
result = (wiki.content
.parse(doc_src)
.filter(SectionTOCFilter).serialize())
eq_(normalize_html(expected), normalize_html(result))
开发者ID:adherang,项目名称:kuma,代码行数:33,代码来源:test_content.py
示例14: test_stripped_ie_comment
def test_stripped_ie_comment(self):
"""bug 801046: strip IE conditional comments"""
content = """
<p>Hi there.</p>
<!--[if]><script>alert(1)</script -->
<!--[if<img src=x onerror=alert(2)//]> -->
<p>Goodbye</p>
"""
expected = """
<p>Hi there.</p>
<p>Goodbye</p>
"""
result = Document.objects.clean_content(content)
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:14,代码来源:test_content.py
示例15: test_section_extract
def test_section_extract(self):
src = """
<h2>Foo</h2>
<p>Bar</p>
<h3 id="Quick_Links">Quick Links</h3>
<p>Foo, yay</p>
<h2>Baz</h2>
<p>Baz</p>
"""
expected = """
<p>Foo, yay</p>
"""
result = section_extract(src, 'Quick_Links')
eq_(normalize_html(expected), normalize_html(result))
开发者ID:PatMart,项目名称:kuma,代码行数:14,代码来源:test_helpers.py
示例16: test_iframe_host_contents_filter
def test_iframe_host_contents_filter(self):
"""Any contents inside an <iframe> should be removed"""
doc_src = """
<iframe>
<iframe src="javascript:alert(1);"></iframe>
</iframe>
"""
expected_src = """
<iframe>
</iframe>
"""
result_src = (wiki.content.parse(doc_src)
.filterIframeHosts('^https?\:\/\/sampleserver')
.serialize())
eq_(normalize_html(expected_src), normalize_html(result_src))
开发者ID:arkanDEV,项目名称:kuma,代码行数:15,代码来源:test_content.py
示例17: test_bug_925043
def test_bug_925043(self):
'''Bug 925043 - Redesign TOC has a bunch of empty <code> tags in markup'''
doc_src = """
<h2 id="Print">Mastering <code>print</code></h2>
<code>print 'Hello World!'</code>
"""
expected = """
<li>
<a href="#Print" rel="internal">Mastering<code>print</code></a>
</li>
"""
result = (wiki.content
.parse(doc_src)
.filter(SectionTOCFilter).serialize())
eq_(normalize_html(expected), normalize_html(result))
开发者ID:dkns,项目名称:kuma,代码行数:15,代码来源:test_content.py
示例18: test_raw_section_edit
def test_raw_section_edit(self):
client = LocalizingClient()
client.login(username='admin', password='testpass')
d, r = doc_rev("""
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
""")
replace = """
<h1 id="s2">Replace</h1>
<p>replace</p>
"""
expected = """
<h1 id="s2">Replace</h1>
<p>replace</p>
"""
response = client.post('%s?section=s2&raw=true' %
reverse('wiki.edit_document', args=[d.slug]),
{"form": "rev",
"content": replace},
follow=True)
eq_(normalize_html(expected),
normalize_html(response.content))
expected = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Replace</h1>
<p>replace</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
response = client.get('%s?raw=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:48,代码来源:test_views.py
示例19: test_simple_implicit_section_extract
def test_simple_implicit_section_extract(self):
doc_src = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
"""
expected = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
"""
result = wiki.content.parse(doc_src).extractSection(id="s1").serialize()
eq_(normalize_html(expected), normalize_html(result))
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:17,代码来源:test_content.py
示例20: test_dekiscript_macro_conversion
def test_dekiscript_macro_conversion(self):
doc_src = u"""
<span>Just a span</span>
<span class="notascript">Hi there</span>
<li><span class="script">Warning("Performing synchronous IO on the main thread can cause serious performance problems. As a result, this method of modifying the database is <strong>strongly</strong> discouraged!")</span></li>
<li><span class="script">Note("Performing synchronous IO on the main thread can cause serious performance problems. As a result, this method of modifying the database is <strong class="important">strongly</strong> discouraged!")</span></li>
<li><span class="script">MixedCaseName('parameter1', 'parameter2')</span></li>
<li><span class="script">bug(689641)</span></li>
<li><span class="script">template.lowercasename('border')</span></li>
<li><span class="script">Template.UpperCaseTemplate("foo")</span></li>
<li><span class="script">wiki.template('英語版章題', [ "Reusing tabs" ])</span></li>
<li><span class="script">template("non-standard_inline", ["Reusing tabs", "YAY"])</span></li>
<li><span class="script">wiki.template('英語版章題')</span></li>
<li><span class="script">template("non-standard_inline")</span></li>
"""
expected = u"""
<span>Just a span</span>
<span class="notascript">Hi there</span>
<li>{{ Warning("Performing synchronous IO on the main thread can cause serious performance problems. As a result, this method of modifying the database is <strong>strongly</strong> discouraged!") }}</li>
<li>{{ Note("Performing synchronous IO on the main thread can cause serious performance problems. As a result, this method of modifying the database is <strong class="important">strongly</strong> discouraged!") }}</li>
<li>{{ MixedCaseName('parameter1', 'parameter2') }}</li>
<li>{{ bug("689641") }}</li>
<li>{{ lowercasename('border') }}</li>
<li>{{ UpperCaseTemplate("foo") }}</li>
<li>{{ 英語版章題("Reusing tabs") }}</li>
<li>{{ non-standard_inline("Reusing tabs", "YAY") }}</li>
<li>{{ 英語版章題() }}</li>
<li>{{ non-standard_inline() }}</li>
"""
# Check line-by-line, to help work out any issues failure-by-failure
doc_src_lines = doc_src.split("\n")
expected_lines = expected.split("\n")
for i in range(0, len(doc_src_lines)):
result = (wiki.content
.parse(doc_src_lines[i])
.filter(DekiscriptMacroFilter).serialize())
eq_(normalize_html(expected_lines[i]), normalize_html(result))
# But, the whole thing should work in the filter, as well.
result = (wiki.content
.parse(doc_src)
.filter(DekiscriptMacroFilter).serialize())
eq_(normalize_html(expected), normalize_html(result))
开发者ID:adherang,项目名称:kuma,代码行数:44,代码来源:test_content.py
注:本文中的wiki.tests.normalize_html函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论