move nbsp_at_start to utils
This commit is contained in:
parent
264e4f6b30
commit
edbe2e2395
|
@ -12,6 +12,7 @@ from .text import iter_lines, add_highlight
|
||||||
from werkzeug.debug.tbtools import get_current_traceback
|
from werkzeug.debug.tbtools import get_current_traceback
|
||||||
from jinja2 import evalcontextfilter, Markup
|
from jinja2 import evalcontextfilter, Markup
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from .utils import nbsp_at_start
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -135,21 +136,15 @@ def view_edl(username, hashid):
|
||||||
if item.type != 'xanadoc':
|
if item.type != 'xanadoc':
|
||||||
return abort(404)
|
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('/<username>/<hashid>/raw')
|
@bp.route('/<username>/<hashid>/raw')
|
||||||
def view_item_raw(username, hashid):
|
def view_item_raw(username, hashid):
|
||||||
return view_item(username, hashid, raw=True)
|
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('/<username>/<hashid>')
|
@bp.route('/<username>/<hashid>')
|
||||||
def view_item(username, hashid, raw=False):
|
def view_item(username, hashid, raw=False):
|
||||||
if ',' in hashid:
|
if ',' in hashid:
|
||||||
|
|
Loading…
Reference in a new issue