def build_phantoms(view, errs, formatter):
phantoms = []
show_focus_links = len(errs) > 1
for tbck in errs:
line = tbck['line']
text = tbck['text']
testcase = tbck.get('testcase')
if text == '':
continue
pt = view.text_point(line - 1, 0)
indentation = get_indentation_at(view, pt)
text = formatter.format_text(text, indentation)
if show_focus_links and testcase:
focus_link = (
' <a href="focus:{}">focus test</a>'.format(testcase))
lines = text.split('<br />')
text = '<br />'.join([lines[0] + focus_link] + lines[1:])
phantoms.append(sublime.Phantom(
sublime.Region(pt, view.line(pt).b),
('<body id=inline-error>' + STYLESHEET +
'<div class="error">' +
'<span class="message">' + text + '</span>' +
'</div>' +
'</body>'),
sublime.LAYOUT_BELOW, _on_navigate))
return phantoms
评论列表
文章目录