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

RichText widget put extraneous space before last exclamation point in Markdown content #5530

Open
2 tasks done
jancona opened this issue Feb 12, 2025 · 0 comments
Open
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@jancona
Copy link

jancona commented Feb 12, 2025

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

My code is populating a RichText widget with Markdown text. When the content contains exclamation points, it displays an extra space before the last exclamation point.

How to reproduce

See the example code and output below.

Screenshots

No response

Example code

This code snippet:

	fmt.Println("widget.NewRichTextWithText:")
	rt := widget.NewRichTextWithText("First! Hi!")
	for i, s := range rt.Segments {
		fmt.Printf("rt.Segments[%d]: %#v\n", i, s)
	}
	fmt.Println("widget.NewRichTextFromMarkdown:")
	rt = widget.NewRichTextFromMarkdown("First! Hi!")
	for i, s := range rt.Segments {
		fmt.Printf("rt.Segments[%d]: %#v\n", i, s)
	}

produces this output:

widget.NewRichTextWithText:
rt.Segments[0]: &widget.TextSegment{Style:widget.RichTextStyle{Alignment:0, ColorName:"foreground", Inline:true, SizeName:"text", TextStyle:fyne.TextStyle{Bold:false, Italic:false, Monospace:false, Symbol:false, TabWidth:0, Underline:false}, concealed:false}, Text:"First! Hi!", parent:(*widget.RichText)(nil)}
widget.NewRichTextFromMarkdown:
rt.Segments[0]: &widget.TextSegment{Style:widget.RichTextStyle{Alignment:0, ColorName:"foreground", Inline:true, SizeName:"text", TextStyle:fyne.TextStyle{Bold:false, Italic:false, Monospace:false, Symbol:false, TabWidth:0, Underline:false}, concealed:false}, Text:"First! Hi ", parent:(*widget.RichText)(nil)}
rt.Segments[1]: &widget.TextSegment{Style:widget.RichTextStyle{Alignment:0, ColorName:"foreground", Inline:true, SizeName:"text", TextStyle:fyne.TextStyle{Bold:false, Italic:false, Monospace:false, Symbol:false, TabWidth:0, Underline:false}, concealed:false}, Text:"!", parent:(*widget.RichText)(nil)}
rt.Segments[2]: &widget.TextSegment{Style:widget.RichTextStyle{Alignment:0, ColorName:"foreground", Inline:false, SizeName:"text", TextStyle:fyne.TextStyle{Bold:false, Italic:false, Monospace:false, Symbol:false, TabWidth:0, Underline:false}, concealed:false}, Text:"", parent:(*widget.RichText)(nil)}

The first TextSegment in the Markdown case has an extra space after Hi that wasn't in the input text. The space is also shown in the rendered widget.

Fyne version

2.5.4

Go compiler version

go1.23.4 darwin/arm64

Operating system and version

MacOS Sequoia 15.3

Additional Information

A user has also reported the issue on Linux.

I'm new to Fyne, so it's possible that I'm doing something wrong.

My code is based on Fybro and the code in question is unchanged. See here https://github.com/andydotxyz/fybro/blob/main/ui_message.go#L113

@jancona jancona added the unverified A bug that has been reported but not verified label Feb 12, 2025
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

1 participant