Urlencode links in tagclickedit

Julien LepillerSun Aug 19 11:56:53+0200 2018

a856dc8

Urlencode links in tagclickedit

offlate/tagclickedit.py

44
55
import re
66
import sys
7+
from urllib.parse import quote
78
89
class TagClickEdit(QTextBrowser):
910
    def __init__(self, *args):

1314
        text = self.toHtml()
1415
        for word_object in re.finditer(r'@[a-z]+{[^}]*}', text):
1516
            rep = word_object.string[word_object.span()[0] : word_object.span()[1]]
16-
            text = text.replace(rep, '<a href="#' + rep + '">' + rep + '</a>')
17+
            text = text.replace(rep, '<a href="#' + quote(rep) + '">' + rep + '</a>')
1718
        self.setHtml(text)
1819
1920
if __name__ == '__main__':