fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.11k stars 1.4k forks source link

Markdown: 2 spaces or more at line end should force line break inside paragraph #3813

Open matwachich opened 1 year ago

matwachich commented 1 year ago

Checklist

Describe the bug

According to markdown spec: When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

How to reproduce

Run the example

Screenshots

No response

Example code

package main

import (
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Test")

    rt := widget.NewRichText()
    rt.Wrapping = fyne.TextWrapWord
    in := widget.NewMultiLineEntry()
    in.Wrapping = fyne.TextWrapWord
    in.TextStyle = fyne.TextStyle{
        Monospace: true,
    }
    in.OnChanged = func(s string) {
        rt.ParseMarkdown(in.Text)
    }

    in.SetText(`We want to make a line break just here  
after the first line.

This is another paragraph`)

    w.SetContent(
        container.NewGridWithColumns(2, in, rt),
    )
    w.Resize(fyne.NewSize(800, 300))
    w.ShowAndRun()
}

Fyne version

2.3.2

Go compiler version

1.20

Operating system and version

Windows 10

Additional Information

No response

vinser commented 1 year ago

Hi I have to add a little This code will show flaws in Markdown implementation

package main

import (
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Fyne Markdown")

    richText := widget.NewRichTextFromMarkdown(`
![image](appIcon.png)
## Look at Fyne Markdown implementation ##
---
Heading
=======

Sub-heading
-----------

# Alternative heading

## Alternative sub-heading

Paragraphs are separated 
by a blank line.

Two spaces at the end of a line *here* 
produce a line break.

---
*Created using [Fyne](https://fyne.io) GUI library*

*App icon design by [Icon8](https://icon8.com)*`)

    w.SetContent(richText)
    w.ShowAndRun()
}

run it and you'll get image

  1. Image must be left aligned
  2. Two spaces must do line brake
  3. Links surrounded by italicized text must be italicized too
vinser commented 1 year ago

My feature request #3810 is the same theme

vinser commented 1 year ago

The above Markdown should look like this

appIcon

Look at Fyne Markdown implementation


Heading

Sub-heading

Alternative heading

Alternative sub-heading

Paragraphs are separated by a blank line.

Two spaces at the end of a line here produce a line break.


Created using Fyne GUI library

App icon design by Icon8