From 646e6414ae6b47f585e51ec67824f13e4486a3da Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Fri, 23 Dec 2011 22:15:22 -0800 Subject: [PATCH] Recognize www. as links --- convo.py | 1 + parsetools.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/convo.py b/convo.py index a74c9a5..6d6ebf3 100644 --- a/convo.py +++ b/convo.py @@ -405,6 +405,7 @@ class PesterText(QtGui.QTextEdit): if event.modifiers() == QtCore.Qt.ControlModifier: QtGui.QApplication.clipboard().setText(url) else: + if not unicode(url).startswith("http"): url = "http://" + url QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) QtGui.QTextEdit.mousePressEvent(self, event) def mouseMoveEvent(self, event): diff --git a/parsetools.py b/parsetools.py index 2509853..52caa5a 100644 --- a/parsetools.py +++ b/parsetools.py @@ -13,6 +13,7 @@ _gtag_begin = re.compile(r'(?i)') _ctag_end = re.compile(r'(?i)') _ctag_rgb = re.compile(r'\d+,\d+,\d+') _urlre = re.compile(r"(?i)https?://[^\s]+") +_url2re = re.compile(r"(?i)www.[^\s]+") _memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)") _handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)") _imgre = re.compile(r"""(?i)""") @@ -152,7 +153,8 @@ def lexMessage(string): lexlist = [(mecmd, _mecmdre), (colorBegin, _ctag_begin), (colorBegin, _gtag_begin), (colorEnd, _ctag_end), (imagelink, _imgre), - (hyperlink, _urlre), (memolex, _memore), + (hyperlink, _urlre), (hyperlink, _url2re), + (memolex, _memore), (chumhandlelex, _handlere), (smiley, _smilere)] @@ -428,7 +430,7 @@ smiledict = { ":olliesouty:": "olliesouty.gif", ":billiards:": "poolballS.gif", ":billiardslarge:": "poolballL.gif", - ":whatdidyoudo:": "whatdidyoudo.gif", + ":whatdidyoudo:": "whatdidyoudo.gif", } if ostools.isOSXBundle():