summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-11-08 13:21:25 +0100
committerLaurenz <laurmaedje@gmail.com>2023-11-08 13:21:47 +0100
commit80b4ca4c04cb5d911947895d9d04c87efb97b0f4 (patch)
tree2de98314a524a0c5663408a51ccb13a5a74ddea4 /crates
parentec04c3de2fcc5b31d94dc2be8561e569f28cc0a1 (diff)
Extract `typst-svg` crate
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-cli/Cargo.toml1
-rw-r--r--crates/typst-cli/src/compile.rs2
-rw-r--r--crates/typst-svg/Cargo.toml27
-rw-r--r--crates/typst-svg/src/lib.rs (renamed from crates/typst/src/export/svg.rs)15
-rw-r--r--crates/typst/Cargo.toml2
-rw-r--r--crates/typst/src/export/mod.rs2
6 files changed, 36 insertions, 13 deletions
diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml
index 9a96c6b2..6e270bd8 100644
--- a/crates/typst-cli/Cargo.toml
+++ b/crates/typst-cli/Cargo.toml
@@ -23,6 +23,7 @@ doc = false
typst = { workspace = true }
typst-library = { workspace = true }
typst-render = { workspace = true }
+typst-svg = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true }
codespan-reporting = { workspace = true }
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs
index 80e19f1b..9eec36cb 100644
--- a/crates/typst-cli/src/compile.rs
+++ b/crates/typst-cli/src/compile.rs
@@ -226,7 +226,7 @@ fn export_image(
.map_err(|err| eco_format!("failed to write PNG file ({err})"))?;
}
ImageExportFormat::Svg => {
- let svg = typst::export::svg(frame);
+ let svg = typst_svg::svg(frame);
fs::write(path, svg.as_bytes())
.map_err(|err| eco_format!("failed to write SVG file ({err})"))?;
}
diff --git a/crates/typst-svg/Cargo.toml b/crates/typst-svg/Cargo.toml
new file mode 100644
index 00000000..628c34f8
--- /dev/null
+++ b/crates/typst-svg/Cargo.toml
@@ -0,0 +1,27 @@
+[package]
+name = "typst-svg"
+description = "SVG exporter for Typst."
+version.workspace = true
+rust-version.workspace = true
+authors.workspace = true
+edition.workspace = true
+homepage.workspace = true
+repository.workspace = true
+license.workspace = true
+categories.workspace = true
+keywords.workspace = true
+
+[lib]
+doctest = false
+bench = false
+
+[dependencies]
+typst = { workspace = true }
+base64 = { workspace = true }
+comemo = { workspace = true }
+ecow = { workspace = true}
+flate2 = { workspace = true }
+tracing = { workspace = true }
+ttf-parser = { workspace = true }
+xmlparser = { workspace = true }
+xmlwriter = { workspace = true }
diff --git a/crates/typst/src/export/svg.rs b/crates/typst-svg/src/lib.rs
index 06066428..c057566d 100644
--- a/crates/typst/src/export/svg.rs
+++ b/crates/typst-svg/src/lib.rs
@@ -6,18 +6,17 @@ use std::io::Read;
use base64::Engine;
use ecow::{eco_format, EcoString};
use ttf_parser::{GlyphId, OutlineBuilder};
-use xmlwriter::XmlWriter;
-
-use crate::doc::{Frame, FrameItem, FrameKind, GroupItem, TextItem};
-use crate::eval::Repr;
-use crate::font::Font;
-use crate::geom::{
+use typst::doc::{Frame, FrameItem, FrameKind, GroupItem, TextItem};
+use typst::eval::Repr;
+use typst::font::Font;
+use typst::geom::{
self, Abs, Angle, Axes, Color, FixedStroke, Geometry, Gradient, LineCap, LineJoin,
Paint, PathItem, Point, Quadrant, Ratio, RatioOrAngle, Relative, Shape, Size,
Transform,
};
-use crate::image::{Image, ImageFormat, RasterFormat, VectorFormat};
-use crate::util::hash128;
+use typst::image::{Image, ImageFormat, RasterFormat, VectorFormat};
+use typst::util::hash128;
+use xmlwriter::XmlWriter;
/// The number of segments in a conic gradient.
/// This is a heuristic value that seems to work well.
diff --git a/crates/typst/Cargo.toml b/crates/typst/Cargo.toml
index 34063979..4a095509 100644
--- a/crates/typst/Cargo.toml
+++ b/crates/typst/Cargo.toml
@@ -53,8 +53,6 @@ unicode-segmentation = { workspace = true }
unscanny = { workspace = true }
usvg = { workspace = true }
wasmi = { workspace = true }
-xmlparser = { workspace = true }
-xmlwriter = { workspace = true }
xmp-writer = { workspace = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
diff --git a/crates/typst/src/export/mod.rs b/crates/typst/src/export/mod.rs
index ef24c97b..bdcc9c40 100644
--- a/crates/typst/src/export/mod.rs
+++ b/crates/typst/src/export/mod.rs
@@ -1,7 +1,5 @@
//! Exporting into external formats.
mod pdf;
-mod svg;
pub use self::pdf::{pdf, PdfPageLabel, PdfPageLabelStyle};
-pub use self::svg::{svg, svg_merged};