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 markdown widget #500

Closed
wants to merge 4 commits into from
Closed

Conversation

hepp3n
Copy link
Contributor

@hepp3n hepp3n commented Jun 15, 2024

Hello,

This PR extends text module with new markdown widget. Everything is hidden behind markdown feature which needs to be enabled to work with this widget. Access is from widget::text::markdown() via helper function. This function require passing text in markdown format as a String. The markdown parser and Markdown widget are in different files because it's easier to work with it. From my testing it works pretty good, the text is formatted. There are some problems with links and images, so I made them as a text with URL (not clickable ofc), the same with image.

The second problem and I don't know how to solve it, is with strings which comes from markdown crate. For spans in rich_text() we need string slices (or no?) so I used Box::leak() to achieve this. Maybe someone have better idea, or ideal would be if spans can contains Strings. But I did not test it yet.

Copy link
Member

Choose a reason for hiding this comment

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

This example should be called markdown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, that's what I did before this rename. However I don't know what's happened but it did not work with markdown crate, there was a dependency issue. I'm not sure but renaming this example fixed this issue 😅

@wiiznokes
Copy link
Contributor

Maybe this could be added directly in Iced, this is on the Iced roadmap: https://whimsical.com/roadmap-iced-7vhq6R35Lp3TmYH4WeYwLM

@mmstick
Copy link
Member

mmstick commented Jun 15, 2024

I'll check the string problem

@hepp3n
Copy link
Contributor Author

hepp3n commented Jun 15, 2024

Maybe this could be added directly in Iced, this is on the Iced roadmap: https://whimsical.com/roadmap-iced-7vhq6R35Lp3TmYH4WeYwLM

Yeah, I'm here after this comment: cosmic-utils/cosmic-ext-applet-ollama#1 (comment) ^^

I did know about Iced roadmap. They need to update cosmic-text tho if I'm correct.

@wiiznokes
Copy link
Contributor

Putting it in Iced would be better, but it will probably be merged after 2 years 😄, so nevermind my coment. I may use it in fan-control for an explanation screen so its nice to see this :)

Btw, are you using fedora ? I tried to package your applet 2 hours ago but i can't install Ollama.

@hepp3n
Copy link
Contributor Author

hepp3n commented Jun 15, 2024

Btw, are you using fedora ? I tried to package your applet 2 hours ago but i can't install Ollama.

No, only Pop_OS and openSUSE.

@hepp3n
Copy link
Contributor Author

hepp3n commented Jun 15, 2024

Hey @mmstick , I made some changes to Parser, tried to remove most of the Box::leak() with success. Some of them are still there but should not cause issues I hope :)

@mmstick
Copy link
Member

mmstick commented Jun 15, 2024

I will try to eliminate the remaining leaks soon.

Copy link
Member

@jackpot51 jackpot51 left a comment

Choose a reason for hiding this comment

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

This is a lot of code, and the code from cosmic-edit for rendering a Buffer is not ideal. I want to help optimize this before merging to ensure it renders using iced's Buffer rendering code so it can be GPU accelerated.

@hepp3n
Copy link
Contributor Author

hepp3n commented Jun 15, 2024

Thank you! :)

@wiiznokes
Copy link
Contributor

In case anyone missed it, there is now a markdown widget in iced: iced-rs/iced#2508

@hepp3n
Copy link
Contributor Author

hepp3n commented Jul 29, 2024

In case anyone missed it, there is now a markdown widget in iced: iced-rs/iced#2508

Thank you!

In this case I think we should use Iced's markdown. This one is... well, far from being good. There is still a lot of work to be done.

@mmstick mmstick force-pushed the master branch 3 times, most recently from 65f4422 to 2b7d171 Compare November 19, 2024 16:39
@hepp3n hepp3n closed this by deleting the head repository Dec 22, 2024
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.

4 participants