zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.47k stars 3.12k forks source link

Support rendering tables in markdown / documentation #5386

Open bennetbo opened 10 months ago

bennetbo commented 10 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

While looking at some rust documentation I noticed that Zed seems to lack support for rendering tables in markdown comments.

It looks like |,- and line break characters are ignored, the remaining text is displayed in a single line. The screenshot shows a table which is used in the documentation of the std::mem::size_of function in rust std.

zed_table_md

The actual table looks like this:

/// The following table gives the size for primitives.
///
/// Type | `size_of::<Type>()`
/// ---- | ---------------
/// () | 0
/// bool | 1
/// u8 | 1
/// u16 | 2
/// u32 | 4
/// u64 | 8
/// u128 | 16
/// i8 | 1
/// i16 | 2
/// i32 | 4
/// i64 | 8
/// i128 | 16
/// f32 | 4
/// f64 | 8
/// char | 4

Looks like it is not supported in Zed 118.1 and Zed Preview 0.119.16. Would be a nice feature to render tables correctly, or just show the tables as is without cutting off characters.

Environment

Zed: v0.118.1 (Zed) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

bennetbo commented 10 months ago

Edit: Im not sure if the example above is valid "extended" markdown syntax.

But something like this doesn't work either: Screenshot 2024-01-23 at 16 34 22

VSCode seems to handle both cases I showcased. E.g.: Screenshot 2024-01-23 at 16 31 27

Syntax: https://www.markdownguide.org/extended-syntax/

bennetbo commented 10 months ago

Here are my observations looking at the markdown code.

Markdown is parsed into a gpui InteractiveText element, which is then rendered by RichText. In order to support rendering tables, task lists, ... we would probably need to introduce a container element which can render different blocks of tables, rich text, images, ... So table support seems to actually go hand in hand with displaying images inside a chat message.

pulldown_cmark supports parsing tables with Parser::new_ext(..., Options::ENABLE_TABLES), which is already done is zed, but the responding tags just get ignored. So that's why the |, - characters are not displayed in the popup as seen on my screenshot above.

CurbaiCode commented 9 months ago

I think this could be part of #5313.

github-actions[bot] commented 1 month ago

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed. Thanks for your help!

JosephTLyons commented 1 month ago

Still valid in:

Zed: v0.156.0 (Zed Nightly 6167688a63eed63791814e39b3b8fd1a10da0e9b)
OS: macOS 14.4.0
Memory: 64 GiB
Architecture: aarch64