Use Zero Width Space for empty lines.

https://en.wikipedia.org/wiki/Zero-width_space
This commit is contained in:
Martin Mahner 2018-03-24 09:26:12 +01:00
parent 91560b567c
commit 6fa4e6d7a6
2 changed files with 2 additions and 2 deletions

View file

@ -150,7 +150,7 @@ def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
# Plain code is not highlighted, but we wrap with with regular
# Pygments syntax to keep the frontend aligned.
if lexer_name == PLAIN_CODE:
return '\n'.join(['<span class="plain">{}</span>'.format(escape(l))
return '\n'.join(['<span class="plain">{}</span>'.format(escape(l) or '&#8203;')
for l in code_string.splitlines()])
# Everything else is handled by Pygments.

View file

@ -1 +1 @@
<ol>{% for line in snippet.highlight_lines %}<li id="l{{ forloop.counter }}">{{ line|safe|default:"&nbsp;" }}</li>{% endfor %}</ol>
<ol>{% for line in snippet.highlight_lines %}<li id="l{{ forloop.counter }}">{{ line|safe|default:"&#8203;" }}</li>{% endfor %}</ol>