Fix newline rendering in extended display

Rich Text is rendered a bit like HTML, where all of the whitespace gets changed into a single space. This is normally not so bad, but with newlines it's annoying. This preserves the newlines from the description.

Contributes to issue CURA-8565.
This commit is contained in:
Ghostkeeper 2021-11-30 15:01:39 +01:00
parent c1f0fb1faf
commit 02cf4ac440
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -60,6 +60,9 @@ class PackageModel(QObject):
url_regex = re.compile(r"(((http|https)://)[a-zA-Z0-9@:%._+~#?&/=]{2,256}\.[a-z]{2,12}(/[a-zA-Z0-9@:%.-_+~#?&/=]*)?)")
text = re.sub(url_regex, r'<a href="\1">\1</a>', text)
# Turn newlines into <br> so that they get displayed as newlines when rendering as rich text.
text = text.replace("\n", "<br>")
return text
@pyqtProperty(str, constant = True)