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


Python smartypants.smartyPants函数代码示例

本文整理汇总了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
     )
开发者ID:31H0B1eV,项目名称:pepysdiary,代码行数:14,代码来源:views.py

示例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"]))))
开发者ID:mantis369,项目名称:better-code-review,代码行数:7,代码来源:sidenote.py

示例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))
开发者ID:mantis369,项目名称:better-code-review,代码行数:28,代码来源:sidenote.py

示例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
开发者ID:zw,项目名称:Anki-Plugins,代码行数:7,代码来源:SmartyPants.py

示例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
开发者ID:henare,项目名称:daily-paper,代码行数:7,代码来源:scraper.py

示例6: smartypants

def smartypants(text):
    """Applies smarty pants to curl quotes.

    >>> smartypants('The "Green" man')
    u'The &#8220;Green&#8221; man'
    """

    return _smartypants.smartyPants(text)
开发者ID:epicserve,项目名称:django-typogrify,代码行数:8,代码来源:typogrify_tags.py

示例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)
开发者ID:oysnet,项目名称:django-typographie,代码行数:8,代码来源:typographie.py

示例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
开发者ID:syncopated,项目名称:97bottles,代码行数:9,代码来源:text_parsing.py

示例9: smartquotes

def smartquotes(text):
    """Applies smarty pants to curl quotes.

    >>> smartquotes('The "Green" man')
    u'The &#8220;Green&#8221; man'
    """
    text = unicode(text)
    output = smartypants.smartyPants(text)
    return output
开发者ID:JustJenFelice,项目名称:oddsite,代码行数:9,代码来源:typogrify.py

示例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')
开发者ID:shaggytwodope,项目名称:dotfiles,代码行数:18,代码来源:my-rst2html.py

示例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)
开发者ID:jparise,项目名称:django-ink,代码行数:9,代码来源:markup.py

示例12: smartypants_filter

def smartypants_filter(text):
    """Applies smarty pants to curl quotes.
    
    >>> smartypants('The "Green" man')
    u'The &#8220;Green&#8221; man'
    """
    text = force_unicode(text)
    output = smartypants.smartyPants(text)
    return mark_safe(output)
开发者ID:pombredanne,项目名称:django-typogrify,代码行数:9,代码来源:typogrify.py

示例13: smartypants

def smartypants(text):
	"""Applies smarty pants to curl quotes.
	
	>>> smartypants('The "Green" man')
	u'The &#8220;Green&#8221; man'
	"""
	text = force_unicode(text)
	output = _smartypants.smartyPants(re.sub(ur'“|”', '"', re.sub(ur'‘|’', "'", text)))
	return output
开发者ID:karanlyons,项目名称:bestthing,代码行数:9,代码来源:typogrify.py

示例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)
开发者ID:AbdAllah-Ahmed,项目名称:flother,代码行数:10,代码来源:models.py

示例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))))
开发者ID:sebix,项目名称:acrylamid,代码行数:11,代码来源:typography.py


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