• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python parser.WikiParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wiki.parser.WikiParser的典型用法代码示例。如果您正苦于以下问题:Python WikiParser类的具体用法?Python WikiParser怎么用?Python WikiParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WikiParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_key_inline

 def test_key_inline(self):
     """{key} stays inline"""
     p = WikiParser()
     doc = pq(p.parse('{key Cmd+Shift+Q}'))
     eq_(1, len(doc('p')))
     eq_(u'<span class="key">Cmd</span> + <span class="key">Shift</span>'
         u' + <span class="key">Q</span>', doc.html().replace('\n', ''))
开发者ID:muratmeran,项目名称:kitsune,代码行数:7,代码来源:test_parser.py


示例2: test_simple_inline_custom

 def test_simple_inline_custom(self):
     """Simple custom inline syntax: menu, button, filepath, pref"""
     p = WikiParser()
     tags = ["menu", "button", "filepath", "pref"]
     for tag in tags:
         doc = pq(p.parse("{%s this is a %s}" % (tag, tag)))
         eq_("this is a " + tag, doc("span." + tag).text())
开发者ID:erikrose,项目名称:kitsune,代码行数:7,代码来源:test_parser.py


示例3: test_button_for_nesting

 def test_button_for_nesting(self):
     """You can nest {for}s inside {button}."""
     text = '{button start {for mac}mac{/for}{for win}win{/for} rest}'
     p = WikiParser()
     content = p.parse(text)
     eq_(u'<p><span class="button">start '
         u'<span class="for" data-for="mac">mac</span>'
         u'<span class="for" data-for="win">win</span> '
         u'rest</span>\n</p>', content)
开发者ID:muratmeran,项目名称:kitsune,代码行数:9,代码来源:test_parser.py


示例4: test_button_image_for_nesting

 def test_button_image_for_nesting(self):
     """You can nest [[Image:]] inside {for} inside {button}."""
     image(title="image-file.png")
     text = "{button {for mac}[[Image:image-file.png]]{/for} text}"
     p = WikiParser()
     doc = pq(p.parse(text))
     assert "frameless" in doc("img").attr("class")
     eq_(0, doc("div.caption").length)
     eq_(0, doc("div.img").length)
开发者ID:erikrose,项目名称:kitsune,代码行数:9,代码来源:test_parser.py


示例5: test_video_fallback_french

 def test_video_fallback_french(self):
     """English video is found in French."""
     p = WikiParser()
     self.test_video_english()
     doc = pq(p.parse('[[V:Some title]]', locale='fr'))
     eq_('video', doc('div.video').attr('class'))
     eq_(1, len(doc('video')))
     eq_(2, len(doc('source')))
     data_fallback = doc('video').attr('data-fallback')
     eq_(Video.objects.all()[0].flv.url, data_fallback)
开发者ID:muratmeran,项目名称:kitsune,代码行数:10,代码来源:test_parser.py


示例6: test_comments

    def test_comments(self):
        """Markup containing taggy comments shouldn't truncate afterward."""
        p = WikiParser()

        # This used to truncate after the comment when rendered:
        eq_(p.parse("Start <!-- <foo --> End"), "<p>Start <!-- <foo --> End\n</p>")

        # Just make sure these don't go awry either:
        eq_(p.parse("Start <!-- <foo> --> End"), "<p>Start <!-- <foo> --> End\n</p>")
        eq_(p.parse("Start <!-- foo> --> End"), "<p>Start <!-- foo> --> End\n</p>")
开发者ID:erikrose,项目名称:kitsune,代码行数:10,代码来源:test_parser.py


示例7: test_general_warning_note_inline_custom

 def test_general_warning_note_inline_custom(self):
     """A mix of custom inline syntax with warnings and notes"""
     p = WikiParser()
     doc = pq(p.parse('\n\n{warning}\n\nthis is a {button warning}\n{note}'
                      'this is a {menu note}{warning}!{/warning}{/note}'
                      "'''{filepath internal}''' ''{menu hi!}''{/warning}"))
     eq_('warning', doc('div.warning span.button').text())
     eq_('this is a note !', doc('div.note').text())
     eq_('note', doc('div.warning div.note span.menu').text())
     eq_('internal', doc('strong span.filepath').text())
     eq_('hi!', doc('em span.menu').text())
开发者ID:muratmeran,项目名称:kitsune,代码行数:11,代码来源:test_parser.py


示例8: test_adjacent_blocks

 def test_adjacent_blocks(self):
     """Make sure one block-level {for} doesn't absorb an adjacent one."""
     p = WikiParser()
     html = p.parse('{for fx4}\n'
                    '{for mac}Fx4{/for}\n'
                    '{/for}\n'
                    '{for fx3}\n'
                    '{for mac}Fx3{/for}\n'
                    '{/for}')
     # The two div.fors should be siblings, not nested:
     eq_([], pq(html)('div.for div.for'))
开发者ID:muratmeran,项目名称:kitsune,代码行数:11,代码来源:test_parser.py


示例9: test_youtube_video

    def test_youtube_video(self):
        """Verify youtube embeds."""
        urls = ['http://www.youtube.com/watch?v=oHg5SJYRHA0',
                'https://youtube.com/watch?v=oHg5SJYRHA0'
                'http://youtu.be/oHg5SJYRHA0'
                'https://youtu.be/oHg5SJYRHA0']
        parser = WikiParser()

        for url in urls:
            doc = pq(parser.parse('[[V:%s]]' % url))
            assert doc('iframe')[0].attrib['src'].startswith(
                '//www.youtube.com/embed/oHg5SJYRHA0')
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:12,代码来源:test_parser.py


示例10: test_general_warning_note

 def test_general_warning_note(self):
     """A bunch of wiki text with {warning} and {note}"""
     p = WikiParser()
     doc = pq(p.parse('\n\n{warning}\n\nthis is a warning\n\n{note}'
                      'this is a note{warning}!{/warning}{/note}'
                      "[[Installing Firefox]] '''internal''' ''link''"
                      '{/warning}\n\n'))
     eq_('!', doc('div.warning div.warning').text())
     eq_('this is a note !', doc('div.note').text())
     eq_('Installing Firefox', doc('a').text())
     eq_('internal', doc('strong').text())
     eq_('link', doc('em').text())
开发者ID:muratmeran,项目名称:kitsune,代码行数:12,代码来源:test_parser.py


示例11: test_for_in_template

 def test_for_in_template(self):
     """Verify that {for}'s render correctly in template."""
     d = document(title='Template:for')
     d.save()
     r = revision(document=d,
                  content='{for win}windows{/for}{for mac}mac{/for}')
     r.is_approved = True
     r.save()
     p = WikiParser()
     content = p.parse('[[Template:for]]')
     eq_('<p><span class="for" data-for="win">windows</span>'
         '<span class="for" data-for="mac">mac</span>\n\n</p>',
         content)
开发者ID:muratmeran,项目名称:kitsune,代码行数:13,代码来源:test_parser.py


示例12: test_general_warning_note_inline_custom

 def test_general_warning_note_inline_custom(self):
     """A mix of custom inline syntax with warnings and notes"""
     p = WikiParser()
     doc = pq(
         p.parse(
             "\n\n{warning}\n\nthis is a {button warning}\n{note}"
             "this is a {menu note}{warning}!{/warning}{/note}"
             "'''{filepath internal}''' ''{menu hi!}''{/warning}"
         )
     )
     eq_("warning", doc("div.warning span.button").text())
     eq_("this is a note !", doc("div.note").text())
     eq_("note", doc("div.warning div.note span.menu").text())
     eq_("internal", doc("strong span.filepath").text())
     eq_("hi!", doc("em span.menu").text())
开发者ID:erikrose,项目名称:kitsune,代码行数:15,代码来源:test_parser.py


示例13: test_general_warning_note

 def test_general_warning_note(self):
     """A bunch of wiki text with {warning} and {note}"""
     p = WikiParser()
     doc = pq(
         p.parse(
             "\n\n{warning}\n\nthis is a warning\n\n{note}"
             "this is a note{warning}!{/warning}{/note}"
             "[[Installing Firefox]] '''internal''' ''link''"
             "{/warning}\n\n"
         )
     )
     eq_("!", doc("div.warning div.warning").text())
     eq_("this is a note !", doc("div.note").text())
     eq_("Installing Firefox", doc("a").text())
     eq_("internal", doc("strong").text())
     eq_("link", doc("em").text())
开发者ID:erikrose,项目名称:kitsune,代码行数:16,代码来源:test_parser.py


示例14: test_internal_links

    def test_internal_links(self):
        """Make sure internal links work correctly when not to redirected
           articles and when to redirected articles"""
        p = WikiParser()

        # Create a new article
        rev = revision(is_approved=True, save=True)
        doc = rev.document
        doc.current_revision = rev
        doc.title = 'Real article'
        doc.save()

        # Change the slug of the article to create a redirected article
        old_slug = doc.slug
        doc.slug = 'real-article'
        doc.save()
        redirect = Document.objects.get(slug=old_slug)

        # Both internal links should link to the same article
        eq_(p.parse('[[%s]]' % doc.title),
            '<p><a href="/en-US/kb/%s">%s</a>\n</p>' % (doc.slug, doc.title))
        eq_(p.parse('[[%s]]' % redirect.title),
            '<p><a href="/en-US/kb/%s">%s</a>\n</p>' % (doc.slug, doc.title))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:23,代码来源:test_parser.py


示例15: test_unapproved_template

 def test_unapproved_template(self):
     document(title='Template:new').save()
     p = WikiParser()
     doc = pq(p.parse('[[T:new]]'))
     eq_('The template "new" does not exist or has no approved revision.',
         doc.text())
开发者ID:muratmeran,项目名称:kitsune,代码行数:6,代码来源:test_parser.py


示例16: test_block_level_section

 def test_block_level_section(self):
     """Make sure we recognize <section> as a block element."""
     p = WikiParser()
     html = p.parse('{for}<section>hi</section>{/for}')
     assert '<div' in html, "Didn't detect <section> tag as block level"
开发者ID:muratmeran,项目名称:kitsune,代码行数:5,代码来源:test_parser.py


示例17: test_warning_multiline

 def test_warning_multiline(self):
     """Multiline warning syntax"""
     p = WikiParser()
     doc = pq(p.parse("{warning}\nthis is a warning\n{/warning}"))
     eq_("this is a warning", doc("div.warning").text())
开发者ID:erikrose,项目名称:kitsune,代码行数:5,代码来源:test_parser.py


示例18: parsed_eq

def parsed_eq(want, to_parse):
    p = WikiParser()
    eq_(want, p.parse(to_parse).strip().replace("\n", ""))
开发者ID:erikrose,项目名称:kitsune,代码行数:3,代码来源:test_parser.py


示例19: test_warning_multiline_breaks

 def test_warning_multiline_breaks(self):
     """Multiline breaks warning syntax"""
     p = WikiParser()
     doc = pq(p.parse('\n\n{warning}\n\nthis is a warning\n\n'
                      '{/warning}\n\n'))
     eq_('this is a warning', doc('div.warning').text())
开发者ID:muratmeran,项目名称:kitsune,代码行数:6,代码来源:test_parser.py


示例20: parsed_eq

def parsed_eq(want, to_parse):
    p = WikiParser()
    eq_(want, p.parse(to_parse).strip().replace('\n', ''))
开发者ID:muratmeran,项目名称:kitsune,代码行数:3,代码来源:test_parser.py



注:本文中的wiki.parser.WikiParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tasks.schedule_rebuild_kb函数代码示例发布时间:2022-05-26
下一篇:
Python parser.wiki_to_html函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap