Follow-up: https://github.com/zed-industries/zed/pull/38590 **Note**: this PR contains changes from the [previous PR](https://github.com/zed-industries/zed/pull/38590), when that PR gets merged we should see the real changes. This PR fixes 4 things in order to make: 1. Add html/markdown minifier to remove all the **\t** and **\n** characters. This is needed as you cannot create new lines with markdown by just adding an enter to the source file. 2. The event Event::HTML only contained a chunk of the real html for multiline HTML code. I fixed this by storing the currently watched HTML inside a buffer and at the end we parse it into the right elements. Instead of trying to parse a chunck into multiple elements which would always fail before. 3. Add support for html tables. 4. Fixed panic that occured when table does not have an header. I also decided to keep the html minifier inside Zed, because making it a dependency for just a few 100 lines seems to be an overkill. The original crate had a few cve in their dependencies, so figured this would be the best. **Html table support** <img width="1439" height="801" alt="Screenshot 2025-09-27 at 12 19 07" src="https://github.com/user-attachments/assets/a884cc6f-cf47-45a2-81fa-91300c7bbf3f" /> **Before & after Zed's README (no changes)** <img width="3440" height="1378" alt="Screenshot 2025-09-27 at 12 34 47" src="https://github.com/user-attachments/assets/1273b094-fb24-4abd-bffa-56ef3b44670c" /> Release Notes: - Markdown: Added support for html tables
35 lines
929 B
Rust
35 lines
929 B
Rust
use gpui::{App, actions};
|
|
use workspace::Workspace;
|
|
|
|
pub mod markdown_elements;
|
|
mod markdown_minifier;
|
|
pub mod markdown_parser;
|
|
pub mod markdown_preview_view;
|
|
pub mod markdown_renderer;
|
|
|
|
actions!(
|
|
markdown,
|
|
[
|
|
/// Scrolls up by one page in the markdown preview.
|
|
MovePageUp,
|
|
/// Scrolls down by one page in the markdown preview.
|
|
MovePageDown,
|
|
/// Opens a markdown preview for the current file.
|
|
OpenPreview,
|
|
/// Opens a markdown preview in a split pane.
|
|
OpenPreviewToTheSide,
|
|
/// Opens a following markdown preview that syncs with the editor.
|
|
OpenFollowingPreview
|
|
]
|
|
);
|
|
|
|
pub fn init(cx: &mut App) {
|
|
cx.observe_new(|workspace: &mut Workspace, window, cx| {
|
|
let Some(window) = window else {
|
|
return;
|
|
};
|
|
markdown_preview_view::MarkdownPreviewView::register(workspace, window, cx);
|
|
})
|
|
.detach();
|
|
}
|