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

Python textile.textile函数代码示例

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

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



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


示例16: get_html

    def get_html(self, string):
        """Returns html string of a textile content.

        string -- string to process
        
        """
        return textile.textile(string)
开发者ID:spaetz,项目名称:volt,代码行数:7,代码来源:textile_parser.py


示例17: textile

def textile(value):
    try:
        import textile
    except ImportError:
        raise jinja2.TemplateError('textile is not installed!')

    return textile.textile(value)
开发者ID:Farthen,项目名称:cyrax,代码行数:7,代码来源:templatefilters.py


示例18: convert

 def convert(self, orig, data, **kwargs):
     if HAS_TEXTILE:
         html = textile_transformer.textile(orig, encoding='utf-8', output='utf-8')
     else:
         html = orig
     data.setData(html)
     return data
开发者ID:dtgit,项目名称:dtedu,代码行数:7,代码来源:textile_to_html.py


示例19: test_github_issue_28

def test_github_issue_28():
    test = """So here I am porting my ancient "newspipe":newspipe "front-end":blog/2006/09/30/0950 to "Snakelets":Snakelets and "Python":Python, and I've just trimmed down over 20 lines of "PHP":PHP down to essentially one line of "BeautifulSoup":BeautifulSoup retrieval:

<pre>
def parseWapProfile(self, url):
  result = fetch.fetchURL(url)
  soup = BeautifulStoneSoup(result['data'], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
  try:
    width, height = soup('prf:screensize')[0].contents[0].split('x')
  except:
    width = height = None
  return {"width": width, "height": height}
</pre>

Of course there's a lot more error handling to do (and useful data to glean off the "XML":XML), but being able to cut through all the usual parsing crap is immensely gratifying."""
    result = textile.textile(test)
    expect = ("""\t<p>So here I am porting my ancient <a href="newspipe">newspipe</a> <a href="blog/2006/09/30/0950">front-end</a> to <a href="Snakelets">Snakelets</a> and <a href="Python">Python</a>, and I&#8217;ve just trimmed down over 20 lines of <a href="PHP"><span class="caps">PHP</span></a> down to essentially one line of <a href="BeautifulSoup">BeautifulSoup</a> retrieval:</p>

<pre>
def parseWapProfile(self, url):
  result = fetch.fetchURL(url)
  soup = BeautifulStoneSoup(result[&#39;data&#39;], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
  try:
    width, height = soup(&#39;prf:screensize&#39;)[0].contents[0].split(&#39;x&#39;)
  except:
    width = height = None
  return {&quot;width&quot;: width, &quot;height&quot;: height}
</pre>

\t<p>Of course there&#8217;s a lot more error handling to do (and useful data to glean off the <a href="XML"><span class="caps">XML</span></a>), but being able to cut through all the usual parsing crap is immensely gratifying.</p>""")
    assert result == expect
开发者ID:textile,项目名称:python-textile,代码行数:31,代码来源:test_github_issues.py


示例20: dofile

def dofile(srcpath):
    if not issrcfile(srcpath):
        print("Skipping '%s'" % srcpath)
        return
    dstpath = outfilename(srcpath)
    if dstpath is None:
        print("Ignoring file '%s'" % srcpath)
        return
    tmppath = tmpfilename(srcpath)
    (txt, tokens, keys) = parse_textile(srcpath)
    title = ""
    if "Title" in keys:
        title = keys["Title"]
    hdr = header()
    hdr = hdr.replace("$title", title)
    ftr = footer()
    # write(tmppath, txt)
    html = textile.textile(txt)
    if g_do_tokens:
        # print tokens.keys()
        for token in tokens.keys():
            codetxt = tokens[token][1]
            filename = os.path.basename(tokens[token][0])
            c = code_for_filename(tokens[token][0])
            srclinktxt = src_html_link(filename)
            codehtml = srclinktxt + "\n<pre>" + c + "\n" + htmlify(codetxt) + "</code></pre>\n"
            token = token.strip()
            html = html.replace(token, codehtml)
    write(dstpath, hdr + html + ftr)
开发者ID:ragsagar,项目名称:web-blog,代码行数:29,代码来源:rebuild.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python textract.process函数代码示例发布时间:2022-05-27
下一篇:
Python textformats.formatData函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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