mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
parent
12ce59954e
commit
bc2777031d
2 changed files with 19 additions and 6 deletions
|
|
@ -1946,6 +1946,7 @@ class DefaultCharacter(DefaultObject):
|
|||
Kwargs:
|
||||
description (str): Brief description for this object.
|
||||
ip (str): IP address of creator (for object auditing).
|
||||
All other kwargs will be passed into the create_object call.
|
||||
|
||||
Returns:
|
||||
character (Object): A newly created Character of the given typeclass.
|
||||
|
|
@ -1953,8 +1954,7 @@ class DefaultCharacter(DefaultObject):
|
|||
|
||||
"""
|
||||
errors = []
|
||||
obj = None
|
||||
|
||||
obj = Noneo
|
||||
# Get IP address of creator, if available
|
||||
ip = kwargs.pop('ip', '')
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,9 @@ class TextToHTMLparser(object):
|
|||
re_uline = re.compile("(?:%s)(.*?)(?=%s|%s)" % (underline.replace("[", r"\["), fgstop, bgstop))
|
||||
re_blink = re.compile("(?:%s)(.*?)(?=%s|%s)" % (blink.replace("[", r"\["), fgstop, bgstop))
|
||||
re_inverse = re.compile("(?:%s)(.*?)(?=%s|%s)" % (inverse.replace("[", r"\["), fgstop, bgstop))
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<firstspace>(?<=\S) {2,})|(?P<space> [ \t]+)|'
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<firstspace>(?<=\S) )|(?P<space> [ \t]+)|'
|
||||
r'(?P<spacestart>^ )|(?P<lineend>\r\n|\r|\n)', re.S | re.M | re.I)
|
||||
re_dblspace = re.compile(r' {2,}', re.M)
|
||||
re_url = re.compile(r'((?:ftp|www|https?)\W+(?:(?!\.(?:\s|$)|&\w+;)[^"\',;$*^\\(){}<>\[\]\s])+)(\.(?:\s|$)|&\w+;|)')
|
||||
re_mxplink = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL)
|
||||
|
||||
|
|
@ -259,6 +260,13 @@ class TextToHTMLparser(object):
|
|||
# change pages (and losing our webclient session).
|
||||
return self.re_url.sub(r'<a href="\1" target="_blank">\1</a>\2', text)
|
||||
|
||||
def re_double_space(self, text):
|
||||
"""
|
||||
HTML will swallow any normal space after the first, so if any slipped
|
||||
through we must make sure to replace them with " "
|
||||
"""
|
||||
return self.re_dblspace.sub(self.sub_dblspace, text)
|
||||
|
||||
def sub_mxp_links(self, match):
|
||||
"""
|
||||
Helper method to be passed to re.sub,
|
||||
|
|
@ -296,15 +304,19 @@ class TextToHTMLparser(object):
|
|||
return '<br>'
|
||||
elif cdict['firstspace']:
|
||||
return ' '
|
||||
|
||||
elif cdict['space'] == '\t':
|
||||
return ' ' * self.tabstop
|
||||
elif cdict['space'] or cdict["spacestart"] or cdict['firstspace']:
|
||||
text = match.group()
|
||||
return ' ' if tabstop == 1 else ' ' + " " * tabstop
|
||||
elif cdict['space'] or cdict["spacestart"]:
|
||||
text = match.group().replace('\t', ' ' * self.tabstop)
|
||||
text = text.replace(' ', ' ')
|
||||
return text
|
||||
return None
|
||||
|
||||
def sub_dblspace(self, match):
|
||||
"clean up double-spaces"
|
||||
return ' ' + ' ' * (len(match.group()) - 1)
|
||||
|
||||
def parse(self, text, strip_ansi=False):
|
||||
"""
|
||||
Main access function, converts a text containing ANSI codes
|
||||
|
|
@ -331,6 +343,7 @@ class TextToHTMLparser(object):
|
|||
result = self.convert_linebreaks(result)
|
||||
result = self.remove_backspaces(result)
|
||||
result = self.convert_urls(result)
|
||||
result = self.re_double_space(result)
|
||||
# clean out eventual ansi that was missed
|
||||
# result = parse_ansi(result, strip_ansi=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue