本文整理汇总了Python中smartypants.smartyPants函数的典型用法代码示例。如果您正苦于以下问题:Python smartyPants函数的具体用法?Python smartyPants怎么用?Python smartyPants使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smartyPants函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_item_content_encoded
def make_item_content_encoded(self, text1, text2, url, comment_name):
"""
Called from item_content_encoded() in children.
text1 and text2 are chunks of HTML text (or empty strings).
url is the URL of the item (no domain needed, eg '/diary/1666/10/31/').
comment_name is one of 'comment' or 'annotation'.
"""
return '%s %s <p><strong><a href="%s#%ss">Read the %ss</a></strong></p>' % (
force_unicode(smartypants.smartyPants(text1)),
force_unicode(smartypants.smartyPants(text2)),
add_domain(Site.objects.get_current().domain, url),
comment_name,
comment_name
)
示例2: sidenoteLinkToMarkdown
def sidenoteLinkToMarkdown(match):
group = match.groupdict()
return ("[%s](javascript:Sidenote.openColumnLoud\('#%s','#%s','%s'\))" %
(group["linktext"],
escapeQuotes(source),
escapeQuotes(group["identifier"]),
escapeQuotes(smartypants.smartyPants(group["linktext"]))))
示例3: keywordToSidenoteLink
def keywordToSidenoteLink(match):
keyword = match.group()
begin = end = ""
if re.match("\W", keyword[0]):
begin = keyword[0]
keyword = keyword[1:]
if re.match("\W", keyword[-1]):
end = keyword[-1]
keyword = keyword[:-1]
pageId = keywordIndex[keyword.lower()]
if pageId == source:
return "%s%s%s" % (begin, keyword, end)
if keyword in observedKeywords:
loudness = "Quiet"
else:
loudness = "Loud"
observedKeywords.add(keyword)
return ("%s[%s](javascript:Sidenote.openColumn%s\('#%s','#%s','%s'\))%s" %
(begin,
keyword,
loudness,
escapeQuotes(source),
escapeQuotes(pageId),
escapeQuotes(smartypants.smartyPants(keyword)),
end))
示例4: formatQA
def formatQA(html, type, cid, mid, fact, tags, cm):
logger.debug(u"before smartypants, html is:\n" + html)
if NO_SMARTYPANTS_TAG not in tags:
html = smartypants.smartyPants(html, attr="2")
logger.debug(u"after smartypants, html is:\n" + html)
return html
示例5: prettify_text
def prettify_text(self, text):
"""
Make text more nicerer. Run it through SmartyPants and Widont.
"""
text = self.widont(text)
text = smartypants.smartyPants(text)
return text
示例6: smartypants
def smartypants(text):
"""Applies smarty pants to curl quotes.
>>> smartypants('The "Green" man')
u'The “Green” man'
"""
return _smartypants.smartyPants(text)
示例7: typographie
def typographie(text):
text = html_parser.unescape(text)
text = force_unicode(text)
text = smartyPants(text)
text = ellipsis(text)
text = spaces(text)
text = widont(text)
return mark_safe(text)
示例8: unsmartypants
def unsmartypants(value):
"""
Normalizes a string which has been processed by smartypants.py.
"""
try:
import smartypants
return smartypants.smartyPants(value, '-1')
except ImportError:
return value
示例9: smartquotes
def smartquotes(text):
"""Applies smarty pants to curl quotes.
>>> smartquotes('The "Green" man')
u'The “Green” man'
"""
text = unicode(text)
output = smartypants.smartyPants(text)
return output
示例10: main
def main():
with open(sys.argv[1]) as f:
source = f.read()
doc_parts = publish_parts(
source,
settings_overrides={'output_encoding': 'utf8',
'initial_header_level': 2,
},
writer_name="html")
RE = smartypants.tags_to_skip_regex
pattern = RE.pattern.replace('|code', '|code|tt')
pattern = pattern.replace('|script', '|script|style')
RE = re.compile(pattern, RE.flags)
smartypants.tags_to_skip_regex = RE
print smartyPants(doc_parts['fragment']).encode('utf-8')
示例11: _smartypants
def _smartypants(text):
"""Applies SmartyPants transformations to a block of text."""
text = force_unicode(text)
try:
import smartypants
except ImportError:
return text
else:
return smartypants.smartyPants(text)
示例12: smartypants_filter
def smartypants_filter(text):
"""Applies smarty pants to curl quotes.
>>> smartypants('The "Green" man')
u'The “Green” man'
"""
text = force_unicode(text)
output = smartypants.smartyPants(text)
return mark_safe(output)
示例13: smartypants
def smartypants(text):
"""Applies smarty pants to curl quotes.
>>> smartypants('The "Green" man')
u'The “Green” man'
"""
text = force_unicode(text)
output = _smartypants.smartyPants(re.sub(ur'“|”', '"', re.sub(ur'‘|’', "'", text)))
return output
示例14: save
def save(self, force_insert=False, force_update=False):
"""
Use Markdown to convert the ``copy`` field from plain-text to
HTMl. Smartypants is also used to bring in curly quotes.
"""
from markdown import markdown
from smartypants import smartyPants
self.copy_html = smartyPants(markdown(self.copy, ['abbr',
'headerid(level=2)']))
super(Entry, self).save(force_insert=False, force_update=False)
示例15: typogrify
def typogrify(content):
"""The super typography filter
Applies the following filters: widont, smartypants, caps, amp, initial_quotes"""
return number_suffix(
initial_quotes(
caps(
smartypants.smartyPants(
widont(
amp(content)), mode))))