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

Add AppendMarkdown function to RichText #4869

Merged
merged 3 commits into from
Jun 16, 2024

Conversation

dweymouth
Copy link
Contributor

Description:

Allows appending additional markdown text to an existing RichText

Fixes #4866

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.

@dweymouth dweymouth added this to the "Elgin" release, early 2024 milestone May 23, 2024
@coveralls
Copy link

coveralls commented May 23, 2024

Coverage Status

coverage: 65.571% (+0.5%) from 65.043%
when pulling 6672d89 on dweymouth:richtext-appendmarkdown
into 9810934 on fyne-io:develop.

@andydotxyz
Copy link
Member

This carries potential risks which we might need to think about or document.
For example a markdown document should only have one title (h1) - but with this addition you could have any number.

Also the interpretation of markdown may depend on what came before it.
I.e. this function cannot be used for streaming multiple chunks of a markdown file - unless it is carefully parsed first. Possibly it's only useful for concatenation of documents?

@dweymouth
Copy link
Contributor Author

dweymouth commented May 23, 2024

Concatenation of documents - or rather fragments of text that might have markdown elements like lists but aren't full documents per se - was the use case from Discord that made me think of this feature addition. Is there really anything preventing a markdown text from having multiple titles anyway?

# Title 1

### subsubheading
* some stuff

# Title 2

I agree though that the API is not intended for piecewise handling of a single markdown document - maybe it needs a naming update to reflect that? AppendMarkdownDocument?

@andydotxyz
Copy link
Member

Yes you can technically have multiple headings, it's the spec that disagrees.

Not sure if it's an API naming issue or just documentation. "ParseMarkdown" also requires that it be a full document so we shouldn't need to introduce new naming to reflect that.

I agree that fragments are ok, but they do need to be complete in their own right. Maybe that's what the doc needs?

@dweymouth
Copy link
Contributor Author

Updated API doc to include the caveat against processing a single markdown document piecewise.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should encourage piece-wise parsing in any way as it's not supported.

@@ -29,6 +29,11 @@ func (t *RichText) ParseMarkdown(content string) {

// AppendMarkdown parses the given markdown string and appends the
// content to the widget, with the appropriate formatting.
// This API is intended for appending complete markdown documents or
// standalone fragments, and should not be used to parse a single
// markdown document piecewise. Use ParseMarkdown for this case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indication that "ParseMarkdown" can work piecewise doesn't seem correct - that code is being used within this helper so I don't know how it could be true.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm sure this will be helpful

@dweymouth dweymouth merged commit bca1811 into fyne-io:develop Jun 16, 2024
12 checks passed
@dweymouth dweymouth deleted the richtext-appendmarkdown branch June 16, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants