本文整理汇总了Python中pygments.formatters.HtmlFormatter.nowrap方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlFormatter.nowrap方法的具体用法?Python HtmlFormatter.nowrap怎么用?Python HtmlFormatter.nowrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.formatters.HtmlFormatter
的用法示例。
在下文中一共展示了HtmlFormatter.nowrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _dump_bb_ex
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import nowrap [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)
示例2: _render_asm
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import nowrap [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)