Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text that is not empty on the next line of a hyperlink in a rich text widget cannot be wrapped correctly #4340

Closed
2 tasks done
qiwentaidi opened this issue Oct 24, 2023 · 5 comments
Labels
unverified A bug that has been reported but not verified

Comments

@qiwentaidi
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • 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

image

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

@qiwentaidi qiwentaidi added the unverified A bug that has been reported but not verified label Oct 24, 2023
@dweymouth
Copy link
Contributor

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.

@andydotxyz
Copy link
Member

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.

hl-wrap

@andydotxyz
Copy link
Member

(note also the HTML included is not required to replicate, and indeed not supported).

@ErikKalkoken
Copy link
Contributor

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)

@andydotxyz
Copy link
Member

This is resolved on develop ready for v2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

4 participants