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


Python HtmlFormatter.noclasses方法代码示例

本文整理汇总了Python中pygments.formatters.HtmlFormatter.noclasses方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlFormatter.noclasses方法的具体用法?Python HtmlFormatter.noclasses怎么用?Python HtmlFormatter.noclasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygments.formatters.HtmlFormatter的用法示例。


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

示例1: _dump_bb_ex

# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import noclasses [as 别名]
    def _dump_bb_ex(self, basic_block, print_ir=False):
        lines = []

        base_addr = basic_block.instrs[0].address

        formatter = HtmlFormatter()
        formatter.noclasses = True
        formatter.nowrap = True

        asm_mnemonic_max_width = 0

        for dinstr in basic_block:
            if len(dinstr.asm_instr.mnemonic) > asm_mnemonic_max_width:
                asm_mnemonic_max_width = len(dinstr.asm_instr.mnemonic)

        for instr in basic_block.instrs:
            asm_instr = self._dump_instr(instr.asm_instr, asm_mnemonic_max_width + 1, fill_char=" ")
            asm_instr = highlight(asm_instr, NasmLexer(), formatter)
            asm_instr = asm_instr.replace("span", "font")
            asm_instr = asm_instr.replace('style="color: ', 'color="')

            lines += ["<tr><td align='left'>    %08x [%02d] %s </td></tr>" % (instr.address, instr.asm_instr.size, asm_instr)]

            if print_ir:
                for ir_instr in instr.ir_instrs:
                    lines += ["              " + str(ir_instr) + "\\l"]

        return "".join(lines)
开发者ID:abforce,项目名称:barf-project,代码行数:30,代码来源:basicblock.py

示例2: format_html

# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import noclasses [as 别名]
    def format_html(self, bun, meat):
        html_headers = ('h1','h2','h2','h3','h4','h5','h6','h7','h8','h9')
        if bun in html_headers:
            #struct.add_header(meat)
            return "<{0}>{1}</{2}>\n".format(bun, meat, bun)
        elif 'ps' in bun:
            #child=struct.get_last(header).add_title(bun)
            ##ps=struct.get_last(header).append_ps(bun)
            ret = ""
            for line in meat.split('\n'):
                if '//#' in line:
                    l=line.split('//#')
                    #child.add_element(l[0], comment=l[1])
                    ##ps.append(l[0])
                    ret+='<p class="ps">{0}<span class="comment">{1}</span></p>\n'.format(l[0],l[1])
                else:
                    #child.add_element(line)
                    ##ps.append(l[0])
                    ret+='<p class="ps">{0}</p>\n'.format(line)
            return ret
        elif 'p' in bun:
            #struct.get_last(header).append_p(meat)
            if self.BR:
                meat=meat.split('\n')
                ret='<p>'
                for line in meat:
                    ret+=line+'<br />'
                ret+='</p>\n'
                return ret
            else:
                return '<p>{0}</p>'.format(meat)
        elif 'code' in bun:
            i = meat.find('>')
            lang = meat[:i]
            code = meat[i+2:-7] #-7 to remove endcode...
            #struct.get_last(header).append_code(lang, code)
            print "Get lexer by name"
            lang_=get_lexer_by_name(lang.lower())
            print lang_

            style_=HtmlFormatter(style='colorful').style
            format_=HtmlFormatter(style=style_)
            format_.noclasses = False
            format_.cssclass='code'
            format_.cssfile='code.css'
            return highlight(code, lang_, format_)
        else:
            print 'bun value was: ', bun
开发者ID:tomleo,项目名称:py_notes,代码行数:50,代码来源:parse.py

示例3: _render_asm

# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import noclasses [as 别名]
    def _render_asm(self, instr, mnemonic_width, options, fill_char=""):
        formatter = HtmlFormatter()
        formatter.noclasses = True
        formatter.nowrap = True

        oprnds_str = ", ".join([oprnd.to_string(**options) for oprnd in instr.operands])

        asm_str  = instr.prefix + " " if instr.prefix else ""
        asm_str += instr.mnemonic + fill_char * (mnemonic_width - len(instr.mnemonic))
        asm_str += " " + oprnds_str if oprnds_str else ""

        # TODO Highlight for ARM too.
        asm_str = highlight(asm_str, NasmLexer(), formatter)
        asm_str = asm_str.replace("span", "font")
        asm_str = asm_str.replace('style="color: ', 'color="')
        asm_str = asm_str.replace('style="border: 1px solid ', 'color="')

        return self.asm_tpl.format(address=instr.address, size=instr.size, assembly=asm_str)
开发者ID:chubbymaggie,项目名称:barf-project,代码行数:20,代码来源:basicblock.py

示例4: view_problem

# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import noclasses [as 别名]
def view_problem(request):

    problem = Problem.objects.get(id = request.GET.get('pid'))
    if problem.user != request.user :
        problem_list = Share.objects.filter(share_user = request.user).values_list('problem', flat=True)
        if problem.id in problem_list :
            pass
        else :
            raise Http404()
    f = open(str(problem.docfile), 'r')
    code = f.read()
    f.close()
    formatter = HtmlFormatter()
    formatter.noclasses = True
    lexer = get_lexer_for_filename(str(problem.docfile))
    context = Context({
        'problem' : problem,
        'highlighted_code' : highlight(code, lexer, formatter)
    })
    return render(request, 'index_view_problem.html', context)
开发者ID:sarthakgarg,项目名称:ccloud,代码行数:22,代码来源:views.py

示例5: __pygmentize

# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import noclasses [as 别名]
 def __pygmentize(self, text):
     lexer_name = "%s" % (self.comboBox.currentText())
     lexer = get_lexer_by_name(lexer_name.lower(), stripall=True)
     formatter = HtmlFormatter()
     formatter.noclasses = True
     return highlight(text, lexer, formatter)
开发者ID:solitaire,项目名称:pyNotes,代码行数:8,代码来源:snippet.py


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