diff --git a/Cargo.lock b/Cargo.lock index 83fb56e5b..9189a02d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1242,10 +1242,10 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=cbd672594#cbd672594eedcbb95624735e5c9f473720faf591" +source = "git+https://github.com/storytold/craft-libs?rev=632ad8800#632ad8800da272b74a2fe46831926c92be63d7e8" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", + "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", "thiserror 2.0.21", ] @@ -1653,6 +1653,15 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-xml" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=632ad8800#632ad8800da272b74a2fe46831926c92be63d7e8" +dependencies = [ + "quick-xml 0.41.0", + "thiserror 2.0.21", +] + [[package]] name = "craft-xml" version = "0.1.0" @@ -1671,15 +1680,6 @@ dependencies = [ "thiserror 2.0.21", ] -[[package]] -name = "craft-xml" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=cbd672594#cbd672594eedcbb95624735e5c9f473720faf591" -dependencies = [ - "quick-xml 0.41.0", - "thiserror 2.0.21", -] - [[package]] name = "craft-xml" version = "0.1.0" @@ -1727,6 +1727,16 @@ dependencies = [ "zip 9.1.1", ] +[[package]] +name = "craft-zip" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=632ad8800#632ad8800da272b74a2fe46831926c92be63d7e8" +dependencies = [ + "flate2", + "thiserror 2.0.21", + "zip 9.1.1", +] + [[package]] name = "craft-zip" version = "0.1.0" @@ -1747,16 +1757,6 @@ dependencies = [ "zip 9.1.1", ] -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=cbd672594#cbd672594eedcbb95624735e5c9f473720faf591" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip 9.1.1", -] - [[package]] name = "craft-zip" version = "0.1.0" @@ -2021,7 +2021,7 @@ dependencies = [ "craft-prepress", "craft-print", "craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)", "designcraft-color", "designcraft-compose", @@ -2103,9 +2103,9 @@ name = "designcraft-idml" version = "0.20.1" dependencies = [ "craft-file-formats", - "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", "craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", "designcraft-color", "designcraft-compose", "designcraft-doc", @@ -2222,7 +2222,7 @@ version = "0.20.1" dependencies = [ "craft-docx", "craft-file-formats", - "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cbd672594)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=632ad8800)", "craft-rtf", "craft-wordmodel", "craft-xlsx", diff --git a/Cargo.toml b/Cargo.toml index 4964732d1..23b055741 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,10 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4052591363 craft-designcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19692b6190465671e41967c75d0cd4c439d0c84c", version = "=0.1.0" } craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } craft-epub = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } -craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "cbd672594", version = "=0.1.0" } +craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "632ad8800", version = "=0.1.0" } craft-indd = { git = "https://github.com/storytold/craft-libs", rev = "47bf5650b0d503b97bfb5e841746c4957897d11f", version = "=0.1.0" } craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "cc23ffd4d26f3074808e2187d332564817624f8f", version = "=0.1.0", features = ["tree-render", "tree-text"] } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "cbd672594", version = "=0.1.0" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "632ad8800", version = "=0.1.0" } craft-xml-dtd = { package = "craft-xml", git = "https://github.com/storytold/craft-libs", rev = "f23b0f33f0d00b157476533a43cbbcfd901aa1f1", version = "=0.1.0" } craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } diff --git a/crates/idml/src/export.rs b/crates/idml/src/export.rs index 6bb014b26..5d7d15e9f 100644 --- a/crates/idml/src/export.rs +++ b/crates/idml/src/export.rs @@ -10,7 +10,7 @@ use designcraft_doc::{ use designcraft_geom::{Affine, PathData}; use crate::names::{self, CHAR_BUILTINS, OBJECT_BUILTINS, PARA_BUILTINS, escape_id, num, pt}; -use crate::xml::{El, Node, document, document_with_pi}; +use crate::xml::{El, Node, document}; use crate::{DOM_VERSION, base64_encode}; mod common; diff --git a/crates/idml/src/export/common.rs b/crates/idml/src/export/common.rs index 4e2d42e2c..53a38c497 100644 --- a/crates/idml/src/export/common.rs +++ b/crates/idml/src/export/common.rs @@ -1,25 +1,20 @@ -use super::{Affine, Color, DOM_VERSION, El, Node, PKG_NS, escape_id, num}; +use super::{Affine, Color, El, escape_id, num}; pub(crate) fn uid(n: u64) -> String { format!("u{n:x}") } pub(super) fn p(name: &str, ty: &str, val: impl Into) -> El { - El::new(name).attr("type", ty).text(val) + crate::xml::from_craft(craft_idml::prop(name, ty, val)) } /// Insert a `` element as the first child when there are any. -pub(super) fn with_props(mut el: El, props: Vec) -> El { - if !props.is_empty() { - let mut pe = El::new("Properties"); - pe.children = props.into_iter().map(Node::El).collect(); - el.children.insert(0, Node::El(pe)); - } - el +pub(super) fn with_props(el: El, props: Vec) -> El { + crate::xml::from_craft(craft_idml::with_props(crate::xml::to_craft(&el), props.into_iter().map(|p| crate::xml::to_craft(&p)).collect())) } pub(super) fn pkg_root(kind: &str) -> El { - El::new(&format!("idPkg:{kind}")).attr("xmlns:idPkg", PKG_NS).attr("DOMVersion", DOM_VERSION) + crate::xml::from_craft(craft_idml::part_root(kind)) } pub(super) fn bool_s(b: bool) -> &'static str { diff --git a/crates/idml/src/export/designmap.rs b/crates/idml/src/export/designmap.rs index ee1060d7a..bc1533e4c 100644 --- a/crates/idml/src/export/designmap.rs +++ b/crates/idml/src/export/designmap.rs @@ -1,5 +1,5 @@ use super::common::{anchor_self, bool_s, p, uid, with_props, xref_format_self}; -use super::{CHAR_BUILTINS, DOM_VERSION, Document, El, Ex, HashSet, PARA_BUILTINS, PKG_NS, document_with_pi, escape_id, names, num}; +use super::{CHAR_BUILTINS, DOM_VERSION, Document, El, Ex, HashSet, PARA_BUILTINS, PKG_NS, escape_id, names, num}; impl<'a> Ex<'a> { // ---------- designmap ---------- @@ -257,10 +257,7 @@ impl<'a> Ex<'a> { } self.next += 1; root.push(cg); - document_with_pi( - &root, - &format!(""), - ) + craft_idml::designmap_xml(&crate::xml::to_craft(&root)) } } diff --git a/crates/idml/src/xml.rs b/crates/idml/src/xml.rs index 65efb4674..75962a69d 100644 --- a/crates/idml/src/xml.rs +++ b/crates/idml/src/xml.rs @@ -181,18 +181,7 @@ pub fn escape_into(out: &mut String, s: &str, attr: bool) { /// Serialize a part: XML declaration + root element. pub fn document(root: &El) -> Vec { - let mut s = String::from("\n"); - s.push_str(&to_craft(root).to_xml_pretty("\t")); - s.into_bytes() -} - -/// Serialize with extra processing instructions after the declaration (designmap's ``). -pub fn document_with_pi(root: &El, pi: &str) -> Vec { - let mut s = String::from("\n"); - s.push_str(pi); - s.push('\n'); - s.push_str(&to_craft(root).to_xml_pretty("\t")); - s.into_bytes() + craft_idml::part_xml(&to_craft(root)) } pub(crate) fn to_craft(el: &El) -> craft_xml::El {