From 6fa4e6d7a638199d514e446ea75cacb49995a9dc Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Sat, 24 Mar 2018 09:26:12 +0100 Subject: [PATCH] Use Zero Width Space for empty lines. https://en.wikipedia.org/wiki/Zero-width_space --- dpaste/highlight.py | 2 +- dpaste/templates/dpaste/highlight/code.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 59ba8f8..f0d247d 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -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(['{}'.format(escape(l)) + return '\n'.join(['{}'.format(escape(l) or '​') for l in code_string.splitlines()]) # Everything else is handled by Pygments. diff --git a/dpaste/templates/dpaste/highlight/code.html b/dpaste/templates/dpaste/highlight/code.html index ae45cff..569a2e3 100644 --- a/dpaste/templates/dpaste/highlight/code.html +++ b/dpaste/templates/dpaste/highlight/code.html @@ -1 +1 @@ -
    {% for line in snippet.highlight_lines %}
  1. {{ line|safe|default:" " }}
  2. {% endfor %}
+
    {% for line in snippet.highlight_lines %}
  1. {{ line|safe|default:"​" }}
  2. {% endfor %}