fyne
fyne copied to clipboard
Text that is not empty on the next line of a hyperlink in a rich text widget cannot be wrapped correctly
Checklist
- [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- [X] This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
1、Text that is not empty on the next line of a hyperlink in a rich text widget cannot be wrapped correctly 2、Unable to recognize HTML code
How to reproduce
use example code
Screenshots
Example code
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
const info = `<h1 align="center">test title</h1>
<p align="center">hello<br/><br/></p>
> 123456789
111111
1111
[google](https://google.com/)
can't wrap
`
func main() {
a := app.New()
w := a.NewWindow("Test RichText")
rt := widget.NewRichTextFromMarkdown(info)
w.SetContent(rt)
w.ShowAndRun()
}
Fyne version
fyne.io/fyne/v2 v2.4.1-rc1.0.20231020171735-2921c115f4cc
Go compiler version
go1.20.1 windows/amd64
Operating system and version
windows11
Additional Information
No response
Probably related to #3393, it's possible they even share the same root cause. I wouldn't consider this a duplicate though, it's still its own issue.
I actually think they are separate issues and the use of "wrap" here is in a slightly different context. Notice that wrapping is not turned on in the code snippet. The problem seems to be that without some other content after an href it seems to get confused and does not respect the newline.
Just for clarity, if I turn on wrapping you can see that the wrapping applies to the text (and not the hyperlink as per #3393) but that the first letter of the next word is stuck to the link.
(note also the HTML included is not required to replicate, and indeed not supported).
I think I found a workaround for this issue.
The issue occurs when a link is at the end of a line. In the below example Fyne
will be rendered on the same line as the link.
"[google](http://www.google.com)\n\nFyne"
As a workaround an invisible space can be added at the end of the line with the URL. Then it be correctly wrapped and Fyne
appears on a next line.
"[google](http://www.google.com) \n\nFyne"
Note that a normal space will not work, because those are ignored by the markdown parser. Instead you can use an Unicode EM space (U+2003)
This is resolved on develop ready for v2.5.0