jendrikseipp / rednotebook

RedNotebook is a cross-platform journal
https://rednotebook.app
GNU General Public License v2.0
488 stars 110 forks source link

Preview mode: Urls containing hashtags are broken and not styled properly #704

Open laraconda opened 1 year ago

laraconda commented 1 year ago

Describe the bug

When you add an url with '/#', the preview shows the string that follows the # as a tag. Moreover, the href in <a> tags contains <span> tags that should not be there.

Example of one of the links after being processed by t2t: <a href="http://www.mywebsite.org/<span style="color:red">#foo</span>/bar">http://www.mywebsite.org/<span style="color:red">#foo</span>/bar</a>

Visual:

Screenshot from 2023-06-01 16-29-59

When I disable the hashtag recognition in util/markup.py, the bug goes away, except that the full url is still not recognized as such correctly:

Screenshot from 2023-06-01 16-29-31

Trying to fix this problem by adding a '/' in the right regex in external/txt2tags.py makes the whole (from beginning to end) url to be marked as such, as it should be, but the hashtag is still recognized as a hashtag and the problem regarding spans in hrefs is still there.

Versions:

laraconda commented 1 year ago

I think this problem is going to require some tinkering with t2t given how it is modifying href.