From 7c2e5d8e54a6151337c592967ec4f606bf8f8d0e Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin Date: Tue, 3 Oct 2023 17:28:06 +0800 Subject: [PATCH] feat(exporter::svg): embed html elements --- exporter/svg/src/backend/mod.rs | 7 +++++++ fuzzers/corpora/visualize/video_00.typ | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 fuzzers/corpora/visualize/video_00.typ diff --git a/exporter/svg/src/backend/mod.rs b/exporter/svg/src/backend/mod.rs index 1b2cd4dc..adecf9b9 100644 --- a/exporter/svg/src/backend/mod.rs +++ b/exporter/svg/src/backend/mod.rs @@ -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, "")) } diff --git a/fuzzers/corpora/visualize/video_00.typ b/fuzzers/corpora/visualize/video_00.typ new file mode 100644 index 00000000..9325d6a7 --- /dev/null +++ b/fuzzers/corpora/visualize/video_00.typ @@ -0,0 +1,16 @@ + +#image.decode(``` + + + +```.text, alt: "!typst-inlined-svg")