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


Python html.decode_entities函数代码示例

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


在下文中一共展示了decode_entities函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: metablock

def metablock(parsed):
    """
    Remove HTML tags, entities and superfluous characters from
    meta blocks.
    """
    parsed = " ".join(parsed.replace("\n", "").split()).replace(" ,", ",")
    return escape(strip_tags(decode_entities(parsed)))
开发者ID:dfalk,项目名称:mezzanine,代码行数:7,代码来源:mezzanine_tags.py

示例2: add_post

    def add_post(self, title=None, pub_date=None, tags=None,
        content=None, comments=None, old_url=None, categories=None):
        """
        Adds a post to the post list for processing.

        Attributes:
            pub_date is assumed to be a datetime object.
        """
        if not title:
            title = decode_entities(strip_tags(content).split(". ")[0])
        if categories is None:
            categories = []
        if tags is None:
            tags = []
        if comments is None:
            comments = []
        self.posts.append({
            "title": title,
            "publish_date": pub_date,
            "content": content,
            "categories": categories,
            "tags": tags,
            "comments": comments,
            "old_url": old_url,
        })
        return self.posts[-1]
开发者ID:DanHoerst,项目名称:mezzanine,代码行数:26,代码来源:base.py

示例3: add_post

    def add_post(self, title=None, content=None, old_url=None, pub_date=None,
                 tags=None, categories=None, comments=None):
        """
        Adds a post to the post list for processing.

        - ``title`` and ``content`` are strings for the post.
        - ``old_url`` is a string that a redirect will be created for.
        - ``pub_date`` is assumed to be a ``datetime`` object.
        - ``tags`` and ``categories`` are sequences of strings.
        - ``comments`` is a sequence of dicts - each dict should be the
          return value of ``add_comment``.
        """
        if not title:
            title = strip_tags(content).split(". ")[0]
        title = decode_entities(title)
        if categories is None:
            categories = []
        if tags is None:
            tags = []
        if comments is None:
            comments = []
        self.posts.append({
            "title": force_text(title),
            "publish_date": pub_date,
            "content": force_text(content),
            "categories": categories,
            "tags": tags,
            "comments": comments,
            "old_url": old_url,
        })
        return self.posts[-1]
开发者ID:desecho,项目名称:mezzanine,代码行数:31,代码来源:base.py

示例4: metablock

def metablock(context, nodelist):
    """
    Remove HTML tags, entities and superfluous characters from meta blocks.
    """
    parsed = nodelist.render(context)
    parsed = " ".join(parsed.replace("\n", "").split()).replace(" ,", ",")
    return strip_tags(decode_entities(parsed))
开发者ID:iciclespider,项目名称:mezzanine,代码行数:7,代码来源:mezzanine_tags.py

示例5: add_page

 def add_page(self, title=None, content=None, old_url=None,
              tags=None, old_id=None, old_parent_id=None):
     """
     Adds a page to the list of pages to be imported - used by the
     Wordpress importer.
     """
     if not title:
         text = decode_entities(strip_tags(content)).replace("\n", " ")
         title = text.split(". ")[0]
     if tags is None:
         tags = []
     self.pages.append({
         "title": title,
         "content": content,
         "tags": tags,
         "old_url": old_url,
         "old_id": old_id,
         "old_parent_id": old_parent_id,
     })
开发者ID:desecho,项目名称:mezzanine,代码行数:19,代码来源:base.py


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