def setText(self, text): text = htmlToPlainText(text) urls = re.findall(r'(https?://[^\s]+|file:///[^\s]+)', text) if urls: beg = 0 new_text = '' for url in urls: i = text.index(url, beg) new_text += text[beg:i] + '<a href="%s">%s</a>' % (url, url) beg = i + len(url) new_text += text[beg:] text = new_text.replace('\n', '<br>') super().setText(text)
def setText(self, text): text = htmlToPlainText(text) urls = re.findall(r'(https?://[^\s]+|file:///[^\s]+)', text) if urls: beg = 0 new_text = '' for url in urls: i = text.index(url, beg) new_text += text[beg:i] + '<a href="%s">%s</a>' % (url, url) beg = i + len(url) new_text += text[beg:] text = new_text.replace('\n', '<br>') super().setText(text)
def setText(self, text): text = htmlToPlainText(text) self.setPlainText(text)
def setText(self, text): text = htmlToPlainText(text) self.setPlainText(text)