diff --git a/sourcing/templates/view.html b/sourcing/templates/view.html index 3c65d7e..fb888e7 100644 --- a/sourcing/templates/view.html +++ b/sourcing/templates/view.html @@ -14,6 +14,7 @@ div#text { font-family: Courier; } {% if doc.type == 'xanadoc' %} fulfil {% endif %} + raw
@@ -24,10 +25,10 @@ div#text { font-family: Courier; } {% for i in line %} {%- if i.highlight -%} {% if i.highlight != '\n' and i.highlight != '\r\n' %} - {{- i.highlight -}} + {{- nbsp_at_start(i.highlight) -}} {% endif %} {%- else -%} - {{- i.text -}} + {{- nbsp_at_start(i.text) -}} {%- endif -%} {% endfor %} @@ -36,7 +37,7 @@ div#text { font-family: Courier; } {%- for start, line in iter_lines(doc.text) if line -%} {#{% if line != "\n" and line != "\r\n" %}{{ line }}{% else %} {% endif %}
#} -{{ line }}
+{{ nbsp_at_start(line) }}
{%- endfor -%} {% endif %} diff --git a/sourcing/view.py b/sourcing/view.py index 902c316..5817a41 100644 --- a/sourcing/view.py +++ b/sourcing/view.py @@ -141,6 +141,15 @@ def view_edl(username, hashid): def view_item_raw(username, hashid): return view_item(username, hashid, raw=True) +def nbsp_at_start(text): + ''' Protect spaces at the start of a string. ''' + space_count = 0 + for c in text: + if c != ' ': + break + space_count += 1 + return Markup(' ') * space_count + text[space_count:] + @bp.route('/