Skip to content

Commit b2629e4

Browse files
committed
Never render <marker> or <symbol> directly
Related to #57, neither of these elements are meant to be directly rendered.
1 parent 5b78fb8 commit b2629e4

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "svg2gcode"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
authors = ["Sameer Puri <crates@purisa.me>"]
55
edition = "2021"
66
description = "Convert paths in SVG files to GCode for a pen plotter, laser engraver, or other machine."

lib/src/converter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use svgtypes::Length;
99
use uom::si::f64::Length as UomLength;
1010
use uom::si::length::{inch, millimeter};
1111

12-
use crate::{turtle::*, Machine};
1312
use self::units::CSS_DEFAULT_DPI;
13+
use crate::{turtle::*, Machine};
1414

1515
#[cfg(feature = "serde")]
1616
mod length_serde;

lib/src/converter/visit.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const LINE_TAG_NAME: &str = "line";
2525
const GROUP_TAG_NAME: &str = "g";
2626
const DEFS_TAG_NAME: &str = "defs";
2727
const USE_TAG_NAME: &str = "use";
28+
const MARKER_TAG_NAME: &str = "marker";
29+
const SYMBOL_TAG_NAME: &str = "symbol";
2830

2931
pub trait XmlVisitor {
3032
fn visit_enter(&mut self, node: Node);
@@ -37,8 +39,10 @@ fn should_render_node(node: Node) -> bool {
3739
&& !node
3840
.attribute("style")
3941
.map_or(false, |style| style.contains("display:none"))
40-
// Defs are not rendered
41-
&& node.tag_name().name() != DEFS_TAG_NAME
42+
// - Defs are not rendered
43+
// - Markers are not directly rendered
44+
// - Symbols are not directly rendered
45+
&& !matches!(node.tag_name().name(), DEFS_TAG_NAME | MARKER_TAG_NAME | SYMBOL_TAG_NAME)
4246
}
4347

4448
pub fn depth_first_visit(doc: &Document, visitor: &mut impl XmlVisitor) {

0 commit comments

Comments
 (0)