Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,224 changes: 1,178 additions & 46 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ notify = { git = "https://github.com/zed-industries/notify.git", rev = "b4588b2e
notify-types = { git = "https://github.com/zed-industries/notify.git", rev = "b4588b2e5aee68f4c0e100f140e808cbce7b1419" }
windows-capture = { git = "https://github.com/zed-industries/windows-capture.git", rev = "f0d6c1b6691db75461b732f6d5ff56eed002eeb9" }
calloop = { git = "https://github.com/zed-industries/calloop" }
jupyter-protocol = { git = "https://github.com/auriium2/runtimed" } #only needed until PR fixing the parsing bug in jupyter protocol is merged

[profile.dev]
split-debuginfo = "unpacked"
Expand Down
7 changes: 7 additions & 0 deletions crates/repl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ uuid.workspace = true
workspace.workspace = true
picker.workspace = true

mitex = "0.2.4"
typst = "0.14.1"
typst-svg = "0.14.1"
typst-assets = { version = "0.14.1", features = ["fonts"] }
fontdb = "0.23.0"

[dev-dependencies]
editor = { workspace = true, features = ["test-support"] }
env_logger.workspace = true
Expand All @@ -68,3 +74,4 @@ tree-sitter-md.workspace = true
tree-sitter-typescript.workspace = true
tree-sitter-python.workspace = true
util = { workspace = true, features = ["test-support"] }
mitex = "0.2.4"
6 changes: 6 additions & 0 deletions crates/repl/src/notebook/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,12 @@ impl Render for CodeCell {
Output::Image { content, .. } => {
Some(content.clone().into_any_element())
}
Output::Svg { content, .. } => {
Some(content.clone().into_any_element())
}
Output::Latex { content, .. } => {
Some(content.clone().into_any_element())
}
Output::Message(message) => Some(
div().child(message.clone()).into_any_element(),
),
Expand Down
42 changes: 41 additions & 1 deletion crates/repl/src/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ use ui::{
mod image;
use image::ImageView;

mod svg;
use svg::SvgView;

mod latex;
use latex::LatexView;

mod markdown;
use markdown::MarkdownView;

Expand All @@ -61,7 +67,9 @@ use workspace::Workspace;
/// When deciding what to render from a collection of mediatypes, we need to rank them in order of importance
fn rank_mime_type(mimetype: &MimeType) -> usize {
match mimetype {
MimeType::DataTable(_) => 6,
MimeType::DataTable(_) => 7,
MimeType::Svg(_) => 6,
MimeType::Latex(_) => 5,
MimeType::Png(_) => 4,
MimeType::Jpeg(_) => 3,
MimeType::Markdown(_) => 2,
Expand Down Expand Up @@ -114,6 +122,14 @@ pub enum Output {
content: Entity<ImageView>,
display_id: Option<String>,
},
Svg {
content: Entity<SvgView>,
display_id: Option<String>,
},
Latex {
content: Entity<LatexView>,
display_id: Option<String>,
},
ErrorOutput(ErrorView),
Message(String),
Table {
Expand Down Expand Up @@ -211,6 +227,8 @@ impl Output {
Self::Markdown { content, .. } => Some(content.clone().into_any_element()),
Self::Stream { content, .. } => Some(content.clone().into_any_element()),
Self::Image { content, .. } => Some(content.clone().into_any_element()),
Self::Svg { content, .. } => Some(content.clone().into_any_element()),
Self::Latex { content, .. } => Some(content.clone().into_any_element()),
Self::Message(message) => Some(div().child(message.clone()).into_any_element()),
Self::Table { content, .. } => Some(content.clone().into_any_element()),
Self::ErrorOutput(error_view) => error_view.render(window, cx),
Expand All @@ -236,6 +254,12 @@ impl Output {
Self::Image { content, .. } => {
Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::Svg { content, .. } => {
Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::Latex { content, .. } => {
Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::ErrorOutput(err) => {
// Add buttons for the traceback section
Some(
Expand Down Expand Up @@ -332,6 +356,8 @@ impl Output {
Output::Plain { display_id, .. } => display_id.clone(),
Output::Stream { .. } => None,
Output::Image { display_id, .. } => display_id.clone(),
Output::Svg { display_id, .. } => display_id.clone(),
Output::Latex { display_id, .. } => display_id.clone(),
Output::ErrorOutput(_) => None,
Output::Message(_) => None,
Output::Table { display_id, .. } => display_id.clone(),
Expand Down Expand Up @@ -365,6 +391,20 @@ impl Output {
},
Err(error) => Output::Message(format!("Failed to load image: {}", error)),
},
Some(MimeType::Svg(data)) => match SvgView::from(data, cx) {
Ok(view) => Output::Svg {
content: cx.new(|_| view),
display_id,
},
Err(error) => Output::Message(format!("Failed to load SVG: {}", error)),
},
Some(MimeType::Latex(data)) => match LatexView::from(data, cx) {
Ok(view) => Output::Latex {
content: cx.new(|_| view),
display_id,
},
Err(error) => Output::Message(format!("Failed to render LaTeX: {}", error)),
},
Some(MimeType::DataTable(data)) => Output::Table {
content: cx.new(|cx| TableView::new(data, window, cx)),
display_id,
Expand Down
Loading
Loading