Skip to content

Commit 6a1e23f

Browse files
committed
lib v0.2.2: fix #55
1 parent 3b0800e commit 6a1e23f

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

Cargo.lock

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

cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
22
name = "svg2gcode-cli"
3-
version = "0.0.10"
3+
version = "0.0.11"
44
authors = ["Sameer Puri <[email protected]>"]
55
edition = "2021"
66
description = "Command line interface for svg2gcode"
77
repository = "https://github.com/sameer/svg2gcode"
88
license = "MIT"
99

1010
[dependencies]
11-
svg2gcode = { version = "0.2.1", features = ["serde"]}
11+
svg2gcode = { version = "0.2.2", features = ["serde"]}
1212
env_logger = { version = "0", default-features = false, features = ["atty", "termcolor", "humantime"] }
1313
log = "0"
1414
g-code = "0.4.2"

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.2.1"
3+
version = "0.2.2"
44
authors = ["Sameer Puri <[email protected]>"]
55
edition = "2021"
66
description = "Convert paths in SVG files to GCode for a pen plotter, laser engraver, or other machine."

lib/src/converter/visit.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,27 @@ const CIRCLE_TAG_NAME: &str = "circle";
2323
const ELLIPSE_TAG_NAME: &str = "ellipse";
2424
const LINE_TAG_NAME: &str = "line";
2525
const GROUP_TAG_NAME: &str = "g";
26+
const DEFS_TAG_NAME: &str = "defs";
27+
const USE_TAG_NAME: &str = "use";
2628

2729
pub trait XmlVisitor {
2830
fn visit_enter(&mut self, node: Node);
2931
fn visit_exit(&mut self, node: Node);
3032
}
3133

3234
/// Used to skip over SVG elements that are explicitly marked as do not render
33-
fn is_valid_node(node: Node) -> bool {
34-
return node.is_element()
35+
fn should_render_node(node: Node) -> bool {
36+
node.is_element()
3537
&& !node
3638
.attribute("style")
37-
.map_or(false, |style| style.contains("display:none"));
39+
.map_or(false, |style| style.contains("display:none"))
40+
// Defs are not rendered
41+
&& node.tag_name().name() != DEFS_TAG_NAME
3842
}
3943

4044
pub fn depth_first_visit(doc: &Document, visitor: &mut impl XmlVisitor) {
4145
fn visit_node(node: Node, visitor: &mut impl XmlVisitor) {
42-
if !is_valid_node(node) {
46+
if !should_render_node(node) {
4347
return;
4448
}
4549
visitor.visit_enter(node);
@@ -352,6 +356,9 @@ impl<'a, T: Turtle> XmlVisitor for ConversionVisitor<'a, T> {
352356
}
353357
}
354358
}
359+
USE_TAG_NAME => {
360+
warn!("Unsupported node: {node:?}");
361+
}
355362
// No-op tags
356363
SVG_TAG_NAME | GROUP_TAG_NAME => {}
357364
_ => {

web/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "svg2gcode-web"
3-
version = "0.0.10"
3+
version = "0.0.11"
44
authors = ["Sameer Puri <[email protected]>"]
55
edition = "2021"
66
description = "Convert vector graphics to g-code for pen plotters, laser engravers, and other CNC machines"
@@ -10,7 +10,7 @@ license = "MIT"
1010

1111
[dependencies]
1212
wasm-bindgen = "0.2"
13-
svg2gcode = { version = "0.2.1", features = ["serde"] }
13+
svg2gcode = { version = "0.2.2", features = ["serde"] }
1414
roxmltree = "0.19"
1515
g-code = "0.4.2"
1616
codespan-reporting = "0.11"

0 commit comments

Comments
 (0)