Просмотр исходного кода

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.
Ghostkeeper 3 лет назад
Родитель
Сommit
02cf4ac440
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      plugins/Marketplace/PackageModel.py

+ 3 - 0
plugins/Marketplace/PackageModel.py

@@ -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)