Skip to content
Open
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/markdown_preview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ anyhow.workspace = true
async-recursion.workspace = true
collections.workspace = true
editor.workspace = true
fs.workspace = true
gpui.workspace = true
html5ever.workspace = true
language.workspace = true
linkify.workspace = true
log.workspace = true
markup5ever_rcdom.workspace = true
pretty_assertions.workspace = true
pulldown-cmark.workspace = true
settings.workspace = true
theme.workspace = true
ui.workspace = true
util.workspace = true
workspace.workspace = true
workspace-hack.workspace = true
fs.workspace = true
workspace.workspace = true

[dev-dependencies]
editor = { workspace = true, features = ["test-support"] }
17 changes: 16 additions & 1 deletion crates/markdown_preview/src/markdown_elements.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use gpui::{
FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle, UnderlineStyle, px,
DefiniteLength, FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle,
UnderlineStyle, px,
};
use language::HighlightId;
use std::{fmt::Display, ops::Range, path::PathBuf};
Expand All @@ -15,6 +16,7 @@ pub enum ParsedMarkdownElement {
/// A paragraph of text and other inline elements.
Paragraph(MarkdownParagraph),
HorizontalRule(Range<usize>),
Image(Image),
}

impl ParsedMarkdownElement {
Expand All @@ -30,6 +32,7 @@ impl ParsedMarkdownElement {
MarkdownParagraphChunk::Image(image) => image.source_range.clone(),
},
Self::HorizontalRule(range) => range.clone(),
Self::Image(image) => image.source_range.clone(),
})
}

Expand Down Expand Up @@ -290,6 +293,8 @@ pub struct Image {
pub link: Link,
pub source_range: Range<usize>,
pub alt_text: Option<SharedString>,
pub width: Option<DefiniteLength>,
pub height: Option<DefiniteLength>,
}

impl Image {
Expand All @@ -303,10 +308,20 @@ impl Image {
source_range,
link,
alt_text: None,
width: None,
height: None,
})
}

pub fn set_alt_text(&mut self, alt_text: SharedString) {
self.alt_text = Some(alt_text);
}

pub fn set_width(&mut self, width: DefiniteLength) {
self.width = Some(width);
}

pub fn set_height(&mut self, height: DefiniteLength) {
self.height = Some(height);
}
}
Loading
Loading