Urlencode links in tagclickedit
offlate/tagclickedit.py
4 | 4 | ||
5 | 5 | import re | |
6 | 6 | import sys | |
7 | + | from urllib.parse import quote | |
7 | 8 | ||
8 | 9 | class TagClickEdit(QTextBrowser): | |
9 | 10 | def __init__(self, *args): | |
… | |||
13 | 14 | text = self.toHtml() | |
14 | 15 | for word_object in re.finditer(r'@[a-z]+{[^}]*}', text): | |
15 | 16 | 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>') | |
17 | 18 | self.setHtml(text) | |
18 | 19 | ||
19 | 20 | if __name__ == '__main__': |