本文整理汇总了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.
示例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
示例3: TestIssue035
def TestIssue035(self):
result = textile.textile('"z"')
expect = '\t<p>“z” </p>'
eq_(result, expect)
result = textile.textile('" z"')
expect = '\t<p>“ z” </p>'
eq_(result, expect)
示例4: test_issue_35
def test_issue_35():
result = textile.textile('"z"')
expect = '\t<p>“z” </p>'
assert result == expect
result = textile.textile('" z"')
expect = '\t<p>“ z” </p>'
assert result == expect
示例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)
示例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
示例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)
示例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)
示例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
示例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)
示例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 "quotes" 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<T> extends RescheduleTask implements '
'Context<T> {\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("Unable to wait '
'for syncs termination", ie);\nThread.currentThread().'
'interrupt();\n}\n}\n\nprotected final T getConfigs() {\n'
'return configs;\n}\n}</pre>')
assert result == expect
示例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 — 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
示例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)
示例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
示例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