'PyQt5 incorrect label formatting with links

I have two issues with how PyQt is formatting my QLabels

Issue 1: When hyperlinks are added it displays as if there were no newlines in the string. For the input text:

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>    

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>    

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>

It's shown like this without newlines

enter image description here

Issue 2: Sometimes PyQt just doesn't even detect the 'a' tag this happens when the start of string is not a hyperlink but it is then followed by newlines with hyperlinks e.g. this input:

test

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>    

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>    

<a href = "https://www.google.co.uk/">https://www.google.co.uk/</a>

As you can see the newlines are properly shown but PyQt has no longer detected the hyperlinks

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source