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

Python smartypants.smartyPants函数代码示例

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

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



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


示例16: smartypants

def smartypants(value):
    """
    Filters the value through SmartyPants for converting plain 
    ASCII punctuation characters into typographically correct versions
    """
    try:
        from smartypants import smartyPants
        
        return smartyPants(value)
    except ImportError:
        return value
开发者ID:taylanpince,项目名称:taylanpince,代码行数:11,代码来源:core_utils.py


示例17: curlify

 def curlify(text):
     """Replace quotes in `text` with curly equivalents."""
     if config.options.smartypants == 'off':
         return text
     # Replace any ampersands with an entity so we don't harm the text.
     text = text.replace('&', '&#38;')
     # Use smartypants to curl the quotes, creating HTML entities
     text = smartypants.smartyPants(text, config.options.smartypants)
     # Replace the entities with real Unicode characters.
     text = re.sub('&#(\d+);', lambda m: unichr(int(m.group(1))), text)
     return text
开发者ID:VCTLabs,项目名称:bruce,代码行数:11,代码来源:rst_parser.py


示例18: smartypants

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

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

    t = _smartypants.smartyPants(text)
    # replace "curly" quotes with russian-style quotes (&laquo; and &raquo;)
    t = t.replace('&#8220;', '&#171;')
    t = t.replace('&#8221;', '&#187;')
    return t
开发者ID:Usetech,项目名称:django-typogrify,代码行数:12,代码来源:typogrify_tags.py


示例19: markdown_filter

def markdown_filter(data, img_path=None):
    if data is None:
        return ''

    if img_path:
        # replace relative paths to images with absolute
        data = RELATIVE_PATH_RE.sub('[\g<1>](' + img_path + '/\g<2>)', data)

    data = convert_legacy_people_to_at_names(data)
    result = markdown(data, extensions=['codehilite', 'fenced_code'])
    result = smartyPants(result)
    return result
开发者ID:Lancey6,项目名称:redwind,代码行数:12,代码来源:util.py


示例20: smartypants

def smartypants(text):
    """Applies smarty pants to curl quotes.
    
    >>> smartypants('The "Green" man')
    'The &#8220;Green&#8221; man'
    """
    try:
        import smartypants
    except ImportError:
        return text
    else:
        return smartypants.smartyPants(text)
开发者ID:braveulysses,项目名称:backwater,代码行数:12,代码来源:typogrify.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python smartypants.smartypants函数代码示例发布时间:2022-05-27
下一篇:
Python twitter_user.TwitterUser类代码示例发布时间: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