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


Python pycompat.htmlescape函数代码示例

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


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


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