zed
                                
                                
                                
                                    zed copied to clipboard
                            
                            
                            
                        markdown_preview: Improved markdown rendering support
This PR improves support for rendering markdown documents.
After the updates
https://github.com/zed-industries/zed/assets/18583882/48315901-563d-44c6-8265-8390e8eed942
Before the updates
https://github.com/zed-industries/zed/assets/18583882/6d7ddb55-41f7-492e-af12-6ab54559f612
New features
- @SomeoneToIgnore's scrolling feature request.
 - Checkboxes (
- [ ]and- [x]) - Inline code blocks.
 - Ordered and unordered lists at an arbitrary depth.
 - Block quotes that render nested content, like code blocks.
 - Lists that render nested content, like code blocks.
 - Block quotes that support variable heading sizes and the other markdown features added here.
 - Users can see and click internal links (
[See the docs](./docs.md)). 
Notable changes
- Removed dependency on 
rich_text. - Added a new method for parsing markdown into renderable structs. This method uses recursive descent so it can easily support more complex markdown documents.
 - Parsing does not happen for every call to 
MarkdownPreviewView::renderanymore. 
TODO
- [ ] Typing should move the markdown preview cursor.
 
Future work under consideration
- If a title exists for a link, show it on hover.
 - Images.
 - Since this PR brings the most support for markdown, we can consolidate 
languages/markdownandrich_textto use this new renderer. Note that the updated inline text rendering method in this PR originated fromlangauges/markdown. - Syntax highlighting in code blocks.
 - Footnote references.
 
Release Notes
- Improved support for markdown rendering.
 
Hey @kierangilliam, thank you for your killer work here. We've been wanting this markdown preview for a long time and to see it appear and improve incrementally is awesome! I didn't check any code, but I did do some testing, and one thing I noticed: the text on tasks is gone now.
Main:
This branch:
I realize tasks weren't implemented before, but the text being gone now is a regression from its previous state.
I did do some testing, and one thing I noticed: the text on tasks is gone now.
...
I realize tasks weren't implemented before, but the text being gone now is a regression from its previous state.
@JosephTLyons
For whatever reason, I forgot to include tasks in my playground markdown file. Thanks for the callout. This was an easy add. They are now implemented in this PR:
How I render checked / unchecked is not ideal. I can revisit that when I get more free time.
@SomeoneToIgnore As always — thanks for the thorough feedback. I’ll look at the list rendering issue when I get a chance.
I agree that the scrolling UX isn’t the best. I’m not sure why the list state doesn’t persist as expected. @mikayla-maki and I had chatted about this previously. Mikayla, do you have any idea how I could work around this?
Would you all prefer deferring scrolling until I can more holistically address your comments?
I agree with the rest of your list. These sound like good follow-up issues.
I would rather prefer to have Zed's syntax tree behavior: there's always a single panel that renders things for whatever tab is active now. At least we should not split if there's already a split, rather adding the new rendered tab there.
Yes! This sounds like a very sane behavior.
❤️
(I'm slowly going through my list of things that are needed to make Zed my default editor instead of VSCode, one more checkmark!)