mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Fix bug with pygmentize and just-newline lines
This commit is contained in:
@@ -43,7 +43,7 @@ def _pygmentize_lines(lines):
|
||||
# lines. However, we have seen cases where newlines are present in the code, e.g. in the case of the sentry_sdk's
|
||||
# integration w/ Django giving a TemplateSyntaxError (see assets/sentry-sdk-issues/django-templates.md).
|
||||
# we also add a space to the empty lines to make sure that they are not removed by the pygments formatter
|
||||
lines = [" " if line == "" else line.replace("\n", "") for line in lines]
|
||||
lines = [" " if line == "" else line for line in [l.replace("\n", "") for l in lines]]
|
||||
code = "\n".join(lines)
|
||||
result = _core_pygments(code).split('\n')[:-1] # remove the last empty line, which is a result of split()
|
||||
assert len(lines) == len(result), "%s != %s" % (len(lines), len(result))
|
||||
|
||||
@@ -49,3 +49,6 @@ class TestIssuesTemplateTags(TestCase):
|
||||
|
||||
def test_pygmentize_lines_newline_in_code(self):
|
||||
_pygmentize_lines(["print('hello world')\n"])
|
||||
|
||||
def test_pygmentize_lines_newline_on_otherwise_empty_line(self):
|
||||
_pygmentize_lines(["\n", "\n", "\n"])
|
||||
|
||||
Reference in New Issue
Block a user