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

Python pycompat.htmlescape函数代码示例

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

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



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

示例1: write_toc

    def write_toc(self, node, indentlevel=4):
        # XXX this should return a Unicode string, not a bytestring
        parts = []
        if self.isdocnode(node):
            refnode = node.children[0][0]
            link = refnode['refuri']
            title = htmlescape(refnode.astext()).replace('"', '"')
            item = '<section title="%(title)s" ref="%(ref)s">' % \
                {'title': title, 'ref': link}
            parts.append(' '*4*indentlevel + item)
            for subnode in node.children[1]:
                parts.extend(self.write_toc(subnode, indentlevel+1))
            parts.append(' '*4*indentlevel + '</section>')
        elif isinstance(node, nodes.list_item):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))
        elif isinstance(node, nodes.reference):
            link = node['refuri']
            title = htmlescape(node.astext()).replace('"','&quot;')
            item = section_template % {'title': title, 'ref': link}
            item = u' ' * 4 * indentlevel + item
            parts.append(item.encode('ascii', 'xmlcharrefreplace'))
        elif isinstance(node, nodes.bullet_list):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))
        elif isinstance(node, addnodes.compact_paragraph):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))

        return parts
开发者ID:lehmannro,项目名称:sphinx-mirror,代码行数:30,代码来源:qthelp.py


示例2: write_toc

    def write_toc(self, node, indentlevel=4):
        # XXX this should return a Unicode string, not a bytestring
        parts = []
        if self.isdocnode(node):
            refnode = node.children[0][0]
            link = refnode["refuri"]
            title = htmlescape(refnode.astext()).replace('"', "&quot;")
            item = '<section title="%(title)s" ref="%(ref)s">' % {"title": title, "ref": link}
            parts.append(" " * 4 * indentlevel + item)
            for subnode in node.children[1]:
                parts.extend(self.write_toc(subnode, indentlevel + 1))
            parts.append(" " * 4 * indentlevel + "</section>")
        elif isinstance(node, nodes.list_item):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))
        elif isinstance(node, nodes.reference):
            link = node["refuri"]
            title = htmlescape(node.astext()).replace('"', "&quot;")
            item = section_template % {"title": title, "ref": link}
            item = u" " * 4 * indentlevel + item
            parts.append(item.encode("ascii", "xmlcharrefreplace"))
        elif isinstance(node, nodes.bullet_list):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))
        elif isinstance(node, addnodes.compact_paragraph):
            for subnode in node:
                parts.extend(self.write_toc(subnode, indentlevel))

        return parts
开发者ID:TimKam,项目名称:sphinx,代码行数:29,代码来源:qthelp.py


示例3: page_link

 def page_link(path, name):
     uri = app.builder.get_relative_uri(pagename, path)
     return (
         '<a href="%s" class="reference internal%s">%s</a>'
     ) % (
         htmlescape(uri),
         ' current' if pagename == path else '',
         htmlescape(name),
     )
开发者ID:getsentry,项目名称:sentry-doc-support,代码行数:9,代码来源:sentryext.py


示例4: _parse_comment_text

 def _parse_comment_text(self, text):
     settings = {"file_insertion_enabled": False, "raw_enabled": False, "output_encoding": "unicode"}
     try:
         ret = publish_parts(text, writer_name="html", settings_overrides=settings)["fragment"]
     except Exception:
         ret = htmlescape(text)
     return ret
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:7,代码来源:__init__.py


示例5: write_index

 def write_index(title, refs, subitems):
     # type: (unicode, List[Tuple[unicode, unicode]], List[Tuple[unicode, List[Tuple[unicode, unicode]]]]) -> None  # NOQA
     def write_param(name, value):
         # type: (unicode, unicode) -> None
         item = '    <param name="%s" value="%s">\n' % \
             (name, value)
         f.write(item)
     title = htmlescape(title)
     f.write('<LI> <OBJECT type="text/sitemap">\n')
     write_param('Keyword', title)
     if len(refs) == 0:
         write_param('See Also', title)
     elif len(refs) == 1:
         write_param('Local', refs[0][1])
     else:
         for i, ref in enumerate(refs):
             # XXX: better title?
             write_param('Name', '[%d] %s' % (i, ref[1]))
             write_param('Local', ref[1])
     f.write('</OBJECT>\n')
     if subitems:
         f.write('<UL> ')
         for subitem in subitems:
             write_index(subitem[0], subitem[1], [])
         f.write('</UL>')
开发者ID:mgeier,项目名称:sphinx,代码行数:25,代码来源:htmlhelp.py


示例6: hl

 def hl(no, line):
     line = '<a name="L%s"> </a>' % no + htmlescape(line)
     for x in hltext:
         if x in line:
             line = '<span class="hl">%s</span>' % line
             break
     return line
开发者ID:861008761,项目名称:standard_flask_web,代码行数:7,代码来源:changes.py


示例7: hl

 def hl(self, text, version):
     # type: (unicode, unicode) -> unicode
     text = htmlescape(text)
     for directive in ['versionchanged', 'versionadded', 'deprecated']:
         text = text.replace('.. %s:: %s' % (directive, version),
                             '<b>.. %s:: %s</b>' % (directive, version))
     return text
开发者ID:atodorov,项目名称:sphinx,代码行数:7,代码来源:changes.py


示例8: get_objects

 def get_objects(self, fn2index):
     rv = {}
     otypes = self._objtypes
     onames = self._objnames
     for domainname, domain in sorted(iteritems(self.env.domains)):
         for fullname, dispname, type, docname, anchor, prio in \
                 sorted(domain.get_objects()):
             # XXX use dispname?
             if docname not in fn2index:
                 continue
             if prio < 0:
                 continue
             fullname = htmlescape(fullname)
             prefix, name = rpartition(fullname, '.')
             pdict = rv.setdefault(prefix, {})
             try:
                 typeindex = otypes[domainname, type]
             except KeyError:
                 typeindex = len(otypes)
                 otypes[domainname, type] = typeindex
                 otype = domain.object_types.get(type)
                 if otype:
                     # use unicode() to fire translation proxies
                     onames[typeindex] = (domainname, type,
                                          text_type(domain.get_type_name(otype)))
                 else:
                     onames[typeindex] = (domainname, type, type)
             if anchor == fullname:
                 shortanchor = ''
             elif anchor == type + '-' + fullname:
                 shortanchor = '-'
             else:
                 shortanchor = anchor
             pdict[name] = (fn2index[docname], typeindex, prio, shortanchor)
     return rv
开发者ID:jschueller,项目名称:sphinx,代码行数:35,代码来源:__init__.py


示例9: _parse_comment_text

 def _parse_comment_text(self, text):
     settings = {'file_insertion_enabled': False,
                 'raw_enabled': False,
                 'output_encoding': 'unicode'}
     try:
         ret = publish_parts(text, writer_name='html',
                             settings_overrides=settings)['fragment']
     except Exception:
         ret = htmlescape(text)
     return ret
开发者ID:861008761,项目名称:standard_flask_web,代码行数:10,代码来源:__init__.py


示例10: unhighlighted

 def unhighlighted(self, source):
     if self.dest == 'html':
         return '<pre>' + htmlescape(source) + '</pre>\n'
     else:
         # first, escape highlighting characters like Pygments does
         source = source.translate(escape_hl_chars)
         # then, escape all characters nonrepresentable in LaTeX
         source = source.translate(tex_hl_escape_map_new)
         return '\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + \
                source + '\\end{Verbatim}\n'
开发者ID:Titan-C,项目名称:sphinx,代码行数:10,代码来源:highlighting.py


示例11: new_build_keywords

def new_build_keywords(self, title, refs, subitems):
  old_items = old_build_keywords(self, title, refs, subitems)
  new_items = []
  for item in old_items:
    before, rest = item.split("ref=\"", 1)
    ref, after = rest.split("\"")
    if ("<" in ref and ">" in ref):
      new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after)
    else:
      new_items.append(item)
  return new_items
开发者ID:drbenmorgan,项目名称:cetbuildtools2,代码行数:11,代码来源:cmake.py


示例12: new_build_keywords

def new_build_keywords(self, title, refs, subitems):
    old_items = old_build_keywords(self, title, refs, subitems)
    new_items = []
    for item in old_items:
        before, rest = item.split('ref="', 1)
        ref, after = rest.split('"')
        if "<" in ref and ">" in ref:
            new_items.append(before + 'ref="' + htmlescape(ref) + '"' + after)
        else:
            new_items.append(item)
    return new_items
开发者ID:Baoqi,项目名称:CMake,代码行数:11,代码来源:cmake.py


示例13: unhighlighted

 def unhighlighted(self, source):
     # type: (unicode) -> unicode
     warnings.warn('PygmentsBridge.unhighlighted() is now deprecated.',
                   RemovedInSphinx30Warning)
     if self.dest == 'html':
         return '<pre>' + htmlescape(source) + '</pre>\n'
     else:
         # first, escape highlighting characters like Pygments does
         source = source.translate(escape_hl_chars)
         # then, escape all characters nonrepresentable in LaTeX
         source = source.translate(tex_hl_escape_map_new)
         return '\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + \
                source + '\\end{Verbatim}\n'
开发者ID:willingc,项目名称:sphinx,代码行数:13,代码来源:highlighting.py


示例14: keyword_item

    def keyword_item(self, name, ref):
        # type: (unicode, Any) -> unicode
        matchobj = _idpattern.match(name)  # type: ignore
        if matchobj:
            groupdict = matchobj.groupdict()
            shortname = groupdict['title']
            id = groupdict.get('id')
            # descr = groupdict.get('descr')
            if shortname.endswith('()'):
                shortname = shortname[:-2]
            id = '%s.%s' % (id, shortname)
        else:
            id = None

        nameattr = htmlescape(name, quote=True)
        refattr = htmlescape(ref[1], quote=True)
        if id:
            item = ' ' * 12 + '<keyword name="%s" id="%s" ref="%s"/>' % (nameattr, id, refattr)
        else:
            item = ' ' * 12 + '<keyword name="%s" ref="%s"/>' % (nameattr, refattr)
        item.encode('ascii', 'xmlcharrefreplace')
        return item
开发者ID:papadeltasierra,项目名称:sphinx,代码行数:22,代码来源:qthelp.py


示例15: write_toc

 def write_toc(node, ullevel=0):
     if isinstance(node, nodes.list_item):
         f.write('<LI> ')
         for subnode in node:
             write_toc(subnode, ullevel)
     elif isinstance(node, nodes.reference):
         link = node['refuri']
         title = htmlescape(node.astext()).replace('"', '&quot;')
         f.write(object_sitemap % (title, link))
     elif isinstance(node, nodes.bullet_list):
         if ullevel != 0:
             f.write('<UL>\n')
         for subnode in node:
             write_toc(subnode, ullevel+1)
         if ullevel != 0:
             f.write('</UL>\n')
     elif isinstance(node, addnodes.compact_paragraph):
         for subnode in node:
             write_toc(subnode, ullevel)
开发者ID:avirshup,项目名称:sphinx,代码行数:19,代码来源:htmlhelp.py


示例16: build_keywords

    def build_keywords(self, title, refs, subitems):
        keywords = []

        title = htmlescape(title)
#        if len(refs) == 0: # XXX
#            write_param('See Also', title)
        if len(refs) == 1:
            keywords.append(self.keyword_item(title, refs[0]))
        elif len(refs) > 1:
            for i, ref in enumerate(refs):  # XXX
#                item = (' '*12 +
#                        '<keyword name="%s [%d]" ref="%s"/>' % (
#                                                        title, i, ref))
#                item.encode('ascii', 'xmlcharrefreplace')
#                keywords.append(item)
                keywords.append(self.keyword_item(title, ref))

        if subitems:
            for subitem in subitems:
                keywords.extend(self.build_keywords(subitem[0], subitem[1], []))

        return keywords
开发者ID:lehmannro,项目名称:sphinx-mirror,代码行数:22,代码来源:qthelp.py


示例17: write_index

            def write_index(title, refs, subitems):
                def write_param(name, value):
                    item = '    <param name="%s" value="%s">\n' % (name, value)
                    f.write(item)

                title = htmlescape(title)
                f.write('<LI> <OBJECT type="text/sitemap">\n')
                write_param("Keyword", title)
                if len(refs) == 0:
                    write_param("See Also", title)
                elif len(refs) == 1:
                    write_param("Local", refs[0][1])
                else:
                    for i, ref in enumerate(refs):
                        # XXX: better title?
                        write_param("Name", "[%d] %s" % (i, ref[1]))
                        write_param("Local", ref[1])
                f.write("</OBJECT>\n")
                if subitems:
                    f.write("<UL> ")
                    for subitem in subitems:
                        write_index(subitem[0], subitem[1], [])
                    f.write("</UL>")
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:23,代码来源:htmlhelp.py


示例18: get_objects

 def get_objects(self):
     for kv in self.data['objects'].items():
         (fullid, (docname, objtype, fullname, shortname, specname, displaytype)) = kv
         yield (htmlescape(fullname), specname, objtype, docname, fullid, 0)
开发者ID:abeaumont,项目名称:sphinx-extensions,代码行数:4,代码来源:dylandomain.py


示例19: build_qhp

    def build_qhp(self, outdir, outname):
        self.info("writing project file...")

        # sections
        tocdoc = self.env.get_and_resolve_doctree(self.config.master_doc, self, prune_toctrees=False)

        def istoctree(node):
            return isinstance(node, addnodes.compact_paragraph) and "toctree" in node

        sections = []
        for node in tocdoc.traverse(istoctree):
            sections.extend(self.write_toc(node))

        for indexname, indexcls, content, collapse in self.domain_indices:
            item = section_template % {"title": indexcls.localname, "ref": "%s.html" % indexname}
            sections.append(" " * 4 * 4 + item)
        # sections may be unicode strings or byte strings, we have to make sure
        # they are all unicode strings before joining them
        new_sections = []
        for section in sections:
            if not isinstance(section, text_type):
                new_sections.append(force_decode(section, None))
            else:
                new_sections.append(section)
        sections = u"\n".join(new_sections)

        # keywords
        keywords = []
        index = self.env.create_index(self, group_entries=False)
        for (key, group) in index:
            for title, (refs, subitems, key_) in group:
                keywords.extend(self.build_keywords(title, refs, subitems))
        keywords = u"\n".join(keywords)

        # files
        if not outdir.endswith(os.sep):
            outdir += os.sep
        olen = len(outdir)
        projectfiles = []
        staticdir = path.join(outdir, "_static")
        imagesdir = path.join(outdir, self.imagedir)
        for root, dirs, files in os.walk(outdir):
            resourcedir = root.startswith(staticdir) or root.startswith(imagesdir)
            for fn in files:
                if (resourcedir and not fn.endswith(".js")) or fn.endswith(".html"):
                    filename = path.join(root, fn)[olen:]
                    projectfiles.append(file_template % {"filename": htmlescape(filename)})
        projectfiles = "\n".join(projectfiles)

        # it seems that the "namespace" may not contain non-alphanumeric
        # characters, and more than one successive dot, or leading/trailing
        # dots, are also forbidden
        nspace = "org.sphinx.%s.%s" % (outname, self.config.version)
        nspace = re.sub("[^a-zA-Z0-9.]", "", nspace)
        nspace = re.sub(r"\.+", ".", nspace).strip(".")
        nspace = nspace.lower()

        # write the project file
        with codecs.open(path.join(outdir, outname + ".qhp"), "w", "utf-8") as f:
            f.write(
                project_template
                % {
                    "outname": htmlescape(outname),
                    "title": htmlescape(self.config.html_title),
                    "version": htmlescape(self.config.version),
                    "project": htmlescape(self.config.project),
                    "namespace": htmlescape(nspace),
                    "masterdoc": htmlescape(self.config.master_doc),
                    "sections": sections,
                    "keywords": keywords,
                    "files": projectfiles,
                }
            )

        homepage = "qthelp://" + posixpath.join(nspace, "doc", self.get_target_uri(self.config.master_doc))
        startpage = "qthelp://" + posixpath.join(nspace, "doc", "index.html")

        self.info("writing collection project file...")
        with codecs.open(path.join(outdir, outname + ".qhcp"), "w", "utf-8") as f:
            f.write(
                collection_template
                % {
                    "outname": htmlescape(outname),
                    "title": htmlescape(self.config.html_short_title),
                    "homepage": htmlescape(homepage),
                    "startpage": htmlescape(startpage),
                }
            )
开发者ID:TimKam,项目名称:sphinx,代码行数:88,代码来源:qthelp.py


示例20: __init__

    def __init__(self, source, proposal):
        proposal = htmlescape(proposal)

        differ = Differ()
        self.diff = list(differ.compare(source.splitlines(1),
                                        proposal.splitlines(1)))
开发者ID:4grim,项目名称:hackbright-django,代码行数:6,代码来源:differ.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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