From edbe2e2395b7fdfd2b0f64c605779bf941325b50 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 22 Feb 2017 21:53:21 +0000 Subject: [PATCH] move nbsp_at_start to utils --- sourcing/view.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sourcing/view.py b/sourcing/view.py index 5817a41..1735b16 100644 --- a/sourcing/view.py +++ b/sourcing/view.py @@ -12,6 +12,7 @@ from .text import iter_lines, add_highlight from werkzeug.debug.tbtools import get_current_traceback from jinja2 import evalcontextfilter, Markup from functools import wraps +from .utils import nbsp_at_start import re @@ -135,21 +136,15 @@ def view_edl(username, hashid): if item.type != 'xanadoc': return abort(404) - return render_template('view.html', doc=item, iter_lines=iter_lines) + return render_template('view.html', + doc=item, + iter_lines=iter_lines, + nbsp_at_start=nbsp_at_start) @bp.route('///raw') 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('//') def view_item(username, hashid, raw=False): if ',' in hashid: