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