A file was not properly added in the last commit. Added now.
This commit is contained in:
parent
7e898842b9
commit
e8361a60d1
2 changed files with 8 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ from django.utils.functional import Promise
|
||||||
from django.utils.encoding import force_unicode
|
from django.utils.encoding import force_unicode
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.utils import utils
|
from src.utils import utils
|
||||||
from src.utils.ansi2html import parse_html
|
from src.utils.text2html import parse_html
|
||||||
from src.config.models import ConnectScreen
|
from src.config.models import ConnectScreen
|
||||||
from src.server import session, sessionhandler
|
from src.server import session, sessionhandler
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,11 @@ class TextToHTMLparser(object):
|
||||||
"Extra method for cleaning linebreaks"
|
"Extra method for cleaning linebreaks"
|
||||||
return text.replace(r'\n', r'<br>')
|
return text.replace(r'\n', r'<br>')
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def do_sub(self, m):
|
def do_sub(self, m):
|
||||||
"Helper method to be passed to re.sub."
|
"Helper method to be passed to re.sub."
|
||||||
c = m.groupdict()
|
c = m.groupdict()
|
||||||
|
|
@ -118,13 +123,14 @@ class TextToHTMLparser(object):
|
||||||
result = self.remove_bells(result)
|
result = self.remove_bells(result)
|
||||||
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)
|
||||||
|
|
||||||
# clean out eventual ansi that was missed
|
# clean out eventual ansi that was missed
|
||||||
result = ansi.parse_ansi(result, strip_ansi=True)
|
result = ansi.parse_ansi(result, strip_ansi=True)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
HTML_PARSER = TextToTMLparser()
|
HTML_PARSER = TextToHTMLparser()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Access function
|
# Access function
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue