本文整理汇总了Python中pygments.formatters.HtmlFormatter.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlFormatter.wrap方法的具体用法?Python HtmlFormatter.wrap怎么用?Python HtmlFormatter.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.formatters.HtmlFormatter
的用法示例。
在下文中一共展示了HtmlFormatter.wrap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import wrap [as 别名]
def wrap(self, source, outfile):
line_no = 1
for i, t in HtmlFormatter.wrap(self, source, outfile):
# If this is a source code line we want to add a span tag at the
# end.
if i == 1:
for error in self.errors:
if error['line'] == line_no:
try:
if error['inconclusive'] == 'true':
# only print verbose msg if it really differs
# from actual message
if error.get('verbose') and (error['verbose'] != error['msg']):
index = t.rfind('\n')
t = t[:index] + HTML_EXPANDABLE_INCONCLUSIVE % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
else:
t = t.replace('\n', HTML_INCONCLUSIVE % error['msg'])
except KeyError:
if error.get('verbose') and (error['verbose'] != error['msg']):
index = t.rfind('\n')
t = t[:index] + HTML_EXPANDABLE_ERROR % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
else:
t = t.replace('\n', HTML_ERROR % error['msg'])
line_no = line_no + 1
yield i, t
示例2: wrap
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import wrap [as 别名]
def wrap(self, source, outfile):
line_no = 1
for i, t in HtmlFormatter.wrap(self, source, outfile):
# If this is a source code line we want to add a span tag at the
# end.
if i == 1:
for error in self.errors:
if error['line'] == line_no:
t = t.replace('\n', HTML_ERROR % error['msg'])
line_no = line_no + 1
yield i, t
示例3: wrap
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import wrap [as 别名]
def wrap(self, source, outfile):
for i, (c, t) in enumerate(HtmlFormatter.wrap(self, source, outfile)):
as_functions = self.lines.get(i-1, None)
if as_functions is not None:
yield 0, ('<div title=%s style="background: #ccffcc">[%2d]' %
(quoteattr('as ' + ', '.join(as_functions)),
len(as_functions)))
else:
yield 0, ' '
yield c, t
if as_functions is not None:
yield 0, '</div>'
示例4: wrap
# 需要导入模块: from pygments.formatters import HtmlFormatter [as 别名]
# 或者: from pygments.formatters.HtmlFormatter import wrap [as 别名]
def wrap(self, source, outfile):
return self._wrap_lines(HtmlFormatter.wrap(self, source, outfile))