当前位置: 首页>>代码示例>>Python>>正文


Python textile.textile函数代码示例

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


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

示例1: save

  def save(self):
    if self.title:
      self.title_html       = OAAMarkupToHTML(self.title)
      self.title_text       = OAAMarkupToText(self.title)
      
    if self.description:  
      self.description_html = textile.textile(self.description)
      
    if self.keyboard:  
      self.keyboard_html = textile.textile(self.keyboard)
      
    if self.style:
      self.style_code   = OAAMarkupRemoveHighlightCode(self.style)
      self.style_source = HTMLToSourceCodeFormat(self.style)
      
    if self.html:
      self.html_code   = OAAMarkupRemoveHighlightCode(self.html)
      self.html_source = HTMLToSourceCodeFormat(self.html)

    if self.script:
      self.script_code   = OAAMarkupRemoveHighlightCode(self.script)
      self.script_source = HTMLToSourceCodeFormat(self.script)
      
      
    self.updated_date     = datetime.datetime.now()
    
    #self.rule_categories.clear()
    #self.success_criteria.clear()
    
   # for rr in self.rule_references.all():
    #  self.rule_categories.add(rr.rule.rule_category)
    #  self.success_criteria.add(rr.rule.wcag_primary)

    super(Example, self).save() # Call the "real" save() method.  
开发者ID:oaa-accessibility,项目名称:oaa-django,代码行数:34,代码来源:models.py

示例2: test_extended_pre_block_with_many_newlines

def test_extended_pre_block_with_many_newlines():
    """Extra newlines in an extended pre block should not get cut down to only
    two."""
    text = '''pre.. word

another

word


yet anothe word'''
    expect = '''<pre>word

another

word


yet anothe word</pre>'''
    result = textile.textile(text)
    assert result == expect

    text = 'p. text text\n\n\nh1. Hello\n'
    expect = '\t<p>text text</p>\n\n\n\t<h1>Hello</h1>'
    result = textile.textile(text)
    assert result == expect
开发者ID:sebix,项目名称:python-textile,代码行数:26,代码来源:test_block.py

示例3: TestIssue035

    def TestIssue035(self):
        result = textile.textile('"z"')
        expect = '\t<p>&#8220;z&#8221; </p>'
        eq_(result, expect)

        result = textile.textile('" z"')
        expect = '\t<p>&#8220; z&#8221; </p>'
        eq_(result, expect)
开发者ID:EnigmaCurry,项目名称:textile-py3k,代码行数:8,代码来源:test.py

示例4: test_issue_35

def test_issue_35():
    result = textile.textile('"z"')
    expect = '\t<p>&#8220;z&#8221; </p>'
    assert result == expect

    result = textile.textile('" z"')
    expect = '\t<p>&#8220; z&#8221; </p>'
    assert result == expect
开发者ID:crw,项目名称:python-textile,代码行数:8,代码来源:test_textile.py

示例5: index

 def index(self):
   try:
     article = get_article("index")
     data = {"content": textile(article["content"]),
             "title": article["title"]}
   except ErrorNoSuchRecord as not_found_err:
     data = {"content": textile(open("readme.textile").read())}
   self.response = Template.render(filename="index.html", **data)
开发者ID:rafacv,项目名称:cacilda,代码行数:8,代码来源:cacilda.py

示例6: test_github_issue_30

def test_github_issue_30():
    text ='"Tëxtíle (Tëxtíle)":http://lala.com'
    result = textile.textile(text)
    expect = '\t<p><a href="http://lala.com" title="Tëxtíle">Tëxtíle</a></p>'
    assert result == expect

    text ='!http://lala.com/lol.gif(♡ imáges)!'
    result = textile.textile(text)
    expect = '\t<p><img alt="♡ imáges" src="http://lala.com/lol.gif" title="♡ imáges" /></p>'
    assert result == expect
开发者ID:textile,项目名称:python-textile,代码行数:10,代码来源:test_github_issues.py

示例7: testRelativeURLs

    def testRelativeURLs(self):
        test = '!test/sample.jpg!'
        result = '\t<p><img src="http://example.com/imgs/test/sample.jpg" alt="" /></p>'
        expect = textile.textile(test, base_image_url='http://example.com/imgs/')
        eq_(result, expect)

        test = 'I searched "here":./?q=hello%20world.'
        result = '\t<p>I searched <a href="http://google.com/?q=hello%20world">here</a>.</p>'
        expect = textile.textile(test, base_url='http://google.com/')
        eq_(result, expect)
开发者ID:belak,项目名称:python-textile,代码行数:10,代码来源:__init__.py

示例8: TestIssue036

    def TestIssue036(self):
        test = '"signup":signup\n[signup]http://myservice.com/signup'
        result = textile.textile(test)
        expect = '\t<p><a href="http://myservice.com/signup">signup</a></p>'
        eq_(result, expect)

        test = '"signup":signup\n[signup]https://myservice.com/signup'
        result = textile.textile(test)
        expect = '\t<p><a href="https://myservice.com/signup">signup</a></p>'
        eq_(result, expect)
开发者ID:EnigmaCurry,项目名称:textile-py3k,代码行数:10,代码来源:test.py

示例9: render

def render(content, format=None, linenos=False):
    if re.match(linenos, "true", re.I) is not None:
        linenos = True
    else:
        linenos = False

    if format is "textile":
        html_content = textile(content, linenos)
    else:
        html_content = textile(content, linenos)
    return html_content
开发者ID:gsathya,项目名称:slyer,代码行数:11,代码来源:util.py

示例10: testNestedFormatting

    def testNestedFormatting(self):
        test = "*_test text_*"
        result = textile.textile(test)
        expect = "\t<p><strong><em>test text</em></strong></p>"

        eq_(result, expect)

        test = "_*test text*_"
        result = textile.textile(test)
        expect = "\t<p><em><strong>test text</strong></em></p>"

        eq_(result, expect)
开发者ID:rlz,项目名称:festival-site,代码行数:12,代码来源:__init__.py

示例11: test_github_issue_55

def test_github_issue_55():
    """Incorrect handling of quote entities in extended pre block"""
    test = ('pre.. this is the first line\n\nbut "quotes" in an extended pre '
            'block need to be handled properly.')
    result = textile.textile(test)
    expect = ('<pre>this is the first line\n\nbut &quot;quotes&quot; in an '
              'extended pre block need to be handled properly.</pre>')
    assert result == expect

    # supplied input
    test = ('pre.. import org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;'
            '\nimport ru.onyma.job.Context;\nimport ru.onyma.job.'
            'RescheduleTask;\n\nimport java.util.concurrent.'
            'ScheduledExecutorService;\nimport java.util.concurrent.TimeUnit;'
            '\n\n/**\n* @author ustits\n*/\npublic abstract class '
            'MainService<T> extends RescheduleTask implements Context<T> {\n\n'
            'private static final Logger log = LoggerFactory.getLogger('
            'MainService.class);\nprivate final ScheduledExecutorService '
            'scheduler;\n\nprivate boolean isFirstRun = true;\nprivate T '
            'configs;\n\npublic MainService(final ScheduledExecutorService '
            'scheduler) {\nsuper(scheduler);\nthis.scheduler = scheduler;\n}\n'
            '\[email protected]\npublic void setConfig(final T configs) {\nthis.'
            'configs = configs;\nif (isFirstRun) {\nscheduler.schedule(this, '
            '0, TimeUnit.SECONDS);\nisFirstRun = false;\n}\n}\n\[email protected]\n'
            'public void stop() {\nsuper.stop();\nscheduler.shutdown();\ntry {'
            '\nscheduler.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);\n} '
            'catch (InterruptedException ie) {\nlog.warn("Unable to wait for '
            'syncs termination", ie);\nThread.currentThread().interrupt();\n}'
            '\n}\n\nprotected final T getConfigs() {\nreturn configs;\n}\n}')
    result = textile.textile(test)
    expect = ('<pre>import org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;'
              '\nimport ru.onyma.job.Context;\nimport ru.onyma.job.'
              'RescheduleTask;\n\nimport java.util.concurrent.'
              'ScheduledExecutorService;\nimport java.util.concurrent.'
              'TimeUnit;\n\n/**\n* @author ustits\n*/\npublic abstract class '
              'MainService&lt;T&gt; extends RescheduleTask implements '
              'Context&lt;T&gt; {\n\nprivate static final Logger log = '
              'LoggerFactory.getLogger(MainService.class);\nprivate final '
              'ScheduledExecutorService scheduler;\n\nprivate boolean '
              'isFirstRun = true;\nprivate T configs;\n\npublic MainService('
              'final ScheduledExecutorService scheduler) {\nsuper(scheduler);'
              '\nthis.scheduler = scheduler;\n}\n\[email protected]\npublic void '
              'setConfig(final T configs) {\nthis.configs = configs;\nif ('
              'isFirstRun) {\nscheduler.schedule(this, 0, TimeUnit.SECONDS);'
              '\nisFirstRun = false;\n}\n}\n\[email protected]\npublic void stop() {'
              '\nsuper.stop();\nscheduler.shutdown();\ntry {\nscheduler.'
              'awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);\n} catch '
              '(InterruptedException ie) {\nlog.warn(&quot;Unable to wait '
              'for syncs termination&quot;, ie);\nThread.currentThread().'
              'interrupt();\n}\n}\n\nprotected final T getConfigs() {\n'
              'return configs;\n}\n}</pre>')
    assert result == expect
开发者ID:textile,项目名称:python-textile,代码行数:52,代码来源:test_github_issues.py

示例12: test_Footnote

def test_Footnote():
    html = textile.textile('This is covered elsewhere[1].\n\nfn1. Down here, in fact.\n\nfn2. Here is another footnote.')
    assert re.search(r'^\t<p>This is covered elsewhere<sup class="footnote" id="fnrev([a-f0-9]{32})-1"><a href="#fn\1-1">1</a></sup>.</p>\n\n\t<p class="footnote" id="fn\1-1"><sup>1</sup> Down here, in fact.</p>\n\n\t<p class="footnote" id="fn\1-2"><sup>2</sup> Here is another footnote.</p>$', html) is not None

    html = textile.textile('''See[1] for details -- or perhaps[100] at a push.\n\nfn1. Here are the details.\n\nfn100(footy#otherid). A totally unrelated footnote.''')
    assert re.search(r'^\t<p>See<sup class="footnote" id="fnrev([a-f0-9]{32})-1"><a href="#fn\1-1">1</a></sup> for details &#8212; or perhaps<sup class="footnote" id="fnrev\1-2"><a href="#fn\1-2">100</a></sup> at a push.</p>\n\n\t<p class="footnote" id="fn\1-1"><sup>1</sup> Here are the details.</p>\n\n\t<p class="footy" id="otherid"><sup id="fn\1-2">100</sup> A totally unrelated footnote.</p>$', html) is not None

    html = textile.textile('''See[2] for details, and later, reference it again[2].\n\nfn2^(footy#otherid)[en]. Here are the details.''')
    assert re.search(r'^\t<p>See<sup class="footnote" id="fnrev([a-f0-9]{32})-1"><a href="#fn\1-1">2</a></sup> for details, and later, reference it again<sup class="footnote"><a href="#fn\1-1">2</a></sup>.</p>\n\n\t<p class="footy" id="otherid" lang="en"><sup id="fn\1-1"><a href="#fnrev\1-1">2</a></sup> Here are the details.</p>$', html) is not None

    html = textile.textile('''See[3!] for details.\n\nfn3. Here are the details.''')
    assert re.search(r'^\t<p>See<sup class="footnote" id="fnrev([a-f0-9]{32})-1">3</sup> for details.</p>\n\n\t<p class="footnote" id="fn\1-1"><sup>3</sup> Here are the details.</p>$', html) is not None

    html = textile.textile('''See[4!] for details.\n\nfn4^. Here are the details.''')
    assert re.search(r'^\t<p>See<sup class="footnote" id="fnrev([a-f0-9]{32})-1">4</sup> for details.</p>\n\n\t<p class="footnote" id="fn\1-1"><sup><a href="#fnrev\1-1">4</a></sup> Here are the details.</p>$', html) is not None
开发者ID:crw,项目名称:python-textile,代码行数:15,代码来源:test_textile.py

示例13: new_entry

def new_entry(request):
    main = get_renderer(BASE_TEMPLATE).implementation()
    bibitex_form = BibitexForm.get_form()

    if 'submit' in request.POST:
        controls = request.POST.items()
        try:
            appstruct = bibitex_form.validate(controls)
        except deform.ValidationFailure, e:
            return{'main':main,
                   'form': e.render(),
                   'user':get_user(request),
                   }

        bibitex = appstruct.copy()
        del(bibitex['document'])
        appstruct['bibitex'] = create_bibitex(bibitex)

        if appstruct['wiki']:
            appstruct['wiki_as_html'] = textile(appstruct['wiki'])
        else:
            appstruct['wiki_as_html'] = ''

        appstruct['modified_at'] = str(datetime.now())
        bibitex = Bibitex.from_python(appstruct)
        bibitex.save(request.couchdb)  
        indexer.index(bibitex._id,appstruct)

        return HTTPFound(location='/biblio/%s' % bibitex._id)
开发者ID:alvesjnr,项目名称:bibishare,代码行数:29,代码来源:views.py

示例14: render

 def render(self, context):
     # pagelets can automagically use pagelets templatetags 
     # in order to remove boilerplate
     loaded_cms = AUTO_LOAD_TEMPLATE_TAGS + self.content
     """
     skip the first portions of render_to_string() ( finding the template )
      and go directly to compiling the template/pagelet
     render_to_string abbreviated: 
             def render_to_string(template_name, dictionary=None, context_instance=None):
                    t = select/get_template(template_name)
                            template = get_template_from_string(source, origin, template_name)
                                    return Template(source, origin, name)
                    t.render(context_instance)
     
     """
     #XXX is this what the origin should be?
     origin = StringOrigin('pagelet: %s' % self.slug)
     compiled = compile_string(loaded_cms, origin).render(context)
     try:
         if self.type in ('html', 'tinymce', 'wymeditor'):
             html = compiled
         elif self.type == "textile":
             from textile import textile
             html = textile(str(compiled))
         elif self.type == "markdown":
             from markdown import markdown
             html = markdown(compiled)
         return html
     except TemplateSyntaxError, e:
         return 'Syntax error, %s' % e
开发者ID:accella,项目名称:django-pagelets,代码行数:30,代码来源:models.py

示例15: text_content

    def text_content(self):
        if self.size <= MAX_TEXTFILE_SIZE and not self.is_image:
            possible_markdown = self.extension in (MARKDOWN_FILE_EXTENSIONS + TEXTILE_FILE_EXTENSIONS)
            fake_extension = self.extension if not possible_markdown else u'txt'
            fake_filename = u'.'.join((self.filename, fake_extension,))

            style = styles.get_style_by_name('friendly')
            formatter = formatters.HtmlFormatter(style=style)
            style = formatter.get_style_defs()

            f = urlopen(self.file_obj.cdn_url)
            data = f.read()
            f.close()

            try:
                data = data.decode('utf-8')
                lexer = lexers.guess_lexer_for_filename(fake_filename, data)
            except (ClassNotFound, UnicodeDecodeError):
                return None

            if isinstance(lexer, lexers.TextLexer) and possible_markdown:
                format_string = u'<div class="%s">%s</div>'

                if self.extension in MARKDOWN_FILE_EXTENSIONS:
                    data = format_string % ('markdown', markdown(data))

                if self.extension in TEXTILE_FILE_EXTENSIONS:
                    data = format_string % ('textile', textile(data))

            else:
                data = u'<style>%s</style>\n%s' % (style, highlight(data, lexer, formatter))

            return data
开发者ID:zeroasterisk,项目名称:ushare,代码行数:33,代码来源:models.py


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