Skip to content

Commit

Permalink
feat(exporter::svg): embed html elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Oct 3, 2023
1 parent 4ef85dc commit 7c2e5d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exporter/svg/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,13 @@ fn render_path(path: &ir::PathItem) -> SvgText {
/// Render a [`ir::ImageItem`] into svg text.
#[comemo::memoize]
fn render_image_item(img: &ir::ImageItem) -> SvgText {
match &img.image.alt {
Some(t) if t.as_ref() == "!typst-inlined-svg" => {
return SvgText::Plain(String::from_utf8(img.image.data.clone()).unwrap())
}
_ => {}
}

SvgText::Plain(render_image(&img.image, img.size, true, ""))
}

Expand Down
16 changes: 16 additions & 0 deletions fuzzers/corpora/visualize/video_00.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#image.decode(```
<svg viewBox="0 0 1024 768" xmlns="http://www.w3.org/2000/svg">
<foreignObject width="641px" height="361px">
<iframe
src="https://player.bilibili.com/player.html?aid=80433022&amp;bvid=BV1GJ411x7h7&amp;cid=137649199&amp;page=1&amp;danmaku=0"
scrolling="no"
border="0"
width="640px"
height="360px"
frameborder="no"
framespacing="0"
allowfullscreen="true"
></iframe
></foreignObject>
</svg>```.text, alt: "!typst-inlined-svg")

0 comments on commit 7c2e5d8

Please sign in to comment.