mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 23:36:30 +01:00
Fixed a webclient issue that caused urls to loose their following whitespace.
This commit is contained in:
parent
c56ede0fa2
commit
6d73b05d91
2 changed files with 19 additions and 17 deletions
|
|
@ -74,7 +74,7 @@ def create_objects():
|
|||
limbo_obj.id = 2
|
||||
string = " ".join([
|
||||
"Welcome to your new {wEvennia{n-based game. From here you are ready to begin development.",
|
||||
"If you should need help or would like to participate in community discussions, visit http://evennia.com.",
|
||||
"Visit http://evennia.com if you should need help or would like to participate in community discussions.",
|
||||
"If you are logged in as User #1 you can create a demo/tutorial area with '@batchcommand contrib.tutorial_world.build'.",
|
||||
"Log out and create a new non-admin account at the login screen to play the tutorial properly."])
|
||||
string = _(string)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TextToHTMLparser(object):
|
|||
normalcode = '\033[0m'
|
||||
tabstop = 4
|
||||
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<space>^[ \t]+)|(?P<lineend>\r\n|\r|\n)|(?P<protocol>(^|\s)((http|ftp)://.*?))(\s|$)',
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<space>^[ \t]+)|(?P<lineend>\r\n|\r|\n)',#|(?P<protocol>(^|\s)((http|ftp)://.*?))(\s|$)',
|
||||
re.S|re.M|re.I)
|
||||
|
||||
def re_color(self, text):
|
||||
|
|
@ -79,7 +79,7 @@ class TextToHTMLparser(object):
|
|||
def convert_urls(self, text):
|
||||
"Replace urls (http://...) by valid HTML"
|
||||
regexp = r"((ftp|www|http)(\W+\S+[^).,:;?\]\}(\<span\>) \r\n$]+))"
|
||||
return re.sub(regexp, r'<a href="\1">\1</a>', text)
|
||||
return re.sub(regexp, r'<a href="\1">\1</a> ', text)
|
||||
|
||||
def do_sub(self, m):
|
||||
"Helper method to be passed to re.sub."
|
||||
|
|
@ -88,23 +88,26 @@ class TextToHTMLparser(object):
|
|||
return cgi.escape(c['htmlchars'])
|
||||
if c['lineend']:
|
||||
return '<br>'
|
||||
elif c['space'] == '\t':
|
||||
return ' '*self.tabstop
|
||||
elif c['space']:
|
||||
t = m.group().replace('\t', ' '*self.tabstop)
|
||||
t = t.replace(' ', ' ')
|
||||
return t
|
||||
elif c['space'] == '\t':
|
||||
return ' '*self.tabstop
|
||||
else:
|
||||
url = m.group('protocol')
|
||||
if url.startswith(' '):
|
||||
prefix = ' '
|
||||
url = url[1:]
|
||||
else:
|
||||
prefix = ''
|
||||
last = m.groups()[-1]
|
||||
if last in ['\n', '\r', '\r\n']:
|
||||
last = '<br>'
|
||||
return '%s%s' % (prefix, url)
|
||||
# else:
|
||||
# return m.group('protocol') + ' '
|
||||
# url = m.group('protocol')
|
||||
# prefix, postfix = '',''
|
||||
# if url.startswith(' '):
|
||||
# prefix = ' '
|
||||
# url = url[1:]
|
||||
# if url.endswith(' '):
|
||||
# postfix = ' '
|
||||
# url = url[:-1]
|
||||
# last = m.groups()[-1]
|
||||
# if last in ['\n', '\r', '\r\n']:
|
||||
# last = '<br>'
|
||||
# return '%s%s%s' % (prefix, url, postfix)
|
||||
|
||||
def parse(self, text):
|
||||
"""
|
||||
|
|
@ -124,7 +127,6 @@ class TextToHTMLparser(object):
|
|||
result = self.convert_linebreaks(result)
|
||||
result = self.remove_backspaces(result)
|
||||
result = self.convert_urls(result)
|
||||
|
||||
# clean out eventual ansi that was missed
|
||||
result = ansi.parse_ansi(result, strip_ansi=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue