From b45c58f2e3ff4603f2ae1fe9c8cf12e5980574a2 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 08:43:04 -0500 Subject: [PATCH] Use shared IDML cross-reference and EPUB models --- Cargo.lock | 20 ++++++++-------- Cargo.toml | 4 ++-- crates/idml/src/import/document.rs | 38 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d5e00421..fb2d691d1 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=0768614fb180f780451fb7340a08153f06b42558#0768614fb180f780451fb7340a08153f06b42558" +source = "git+https://github.com/storytold/craft-libs?rev=8275db94e#8275db94eae6ea31feb580250c6080de3bc2ba83" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=0768614fb180f780451fb7340a08153f06b42558)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=0768614fb180f780451fb7340a08153f06b42558)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", + "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", "thiserror 2.0.21", ] @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=0768614fb180f780451fb7340a08153f06b42558#0768614fb180f780451fb7340a08153f06b42558" +source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f" dependencies = [ "quick-xml 0.41.0", "thiserror 2.0.21", @@ -1656,7 +1656,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f" +source = "git+https://github.com/storytold/craft-libs?rev=8275db94e#8275db94eae6ea31feb580250c6080de3bc2ba83" dependencies = [ "quick-xml 0.41.0", "thiserror 2.0.21", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=0768614fb180f780451fb7340a08153f06b42558#0768614fb180f780451fb7340a08153f06b42558" +source = "git+https://github.com/storytold/craft-libs?rev=8275db94e#8275db94eae6ea31feb580250c6080de3bc2ba83" dependencies = [ "flate2", "thiserror 2.0.21", @@ -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=0768614fb180f780451fb7340a08153f06b42558)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", "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=0768614fb180f780451fb7340a08153f06b42558)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", "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=0768614fb180f780451fb7340a08153f06b42558)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", "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=0768614fb180f780451fb7340a08153f06b42558)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8275db94e)", "craft-rtf", "craft-wordmodel", "craft-xlsx", diff --git a/Cargo.toml b/Cargo.toml index a7f41d0e0..41f24ffe8 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 = "93d0998383aa150fa50a2ffbf49ef37786e37eca", 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 = "0768614fb180f780451fb7340a08153f06b42558", version = "=0.1.0" } +craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "8275db94e", 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 = "0768614fb180f780451fb7340a08153f06b42558", version = "=0.1.0" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8275db94e", 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/import/document.rs b/crates/idml/src/import/document.rs index 85e75d98d..300d65c18 100644 --- a/crates/idml/src/import/document.rs +++ b/crates/idml/src/import/document.rs @@ -197,28 +197,27 @@ impl<'r> Importer<'r> { } pub(super) fn xref_format(&mut self, e: &El) { - let name = e.get("Name").unwrap_or("Format").to_string(); + let values = craft_idml::model::CrossReferenceFormatValues::from_el(&crate::xml::to_craft(e)); + let name = values.name; let mut def = String::new(); - for b in e.find_all("BuildingBlock") { - let text = |k: &str| b.get(k).filter(|v| *v != "$ID/").unwrap_or("").to_string(); - match b.get("BlockType").unwrap_or("") { - "CustomStringBuildingBlock" => def.push_str(&text("CustomText")), - "FullParagraphBuildingBlock" => def.push_str(""), - "ParagraphTextBuildingBlock" => def.push_str(""), - "ParagraphNumberBuildingBlock" => def.push_str(""), - "PageNumberBuildingBlock" => def.push_str(""), - "BookmarkNameBuildingBlock" => def.push_str(""), - "ChapterNumberBuildingBlock" => def.push_str(""), - "FileNameBuildingBlock" => def.push_str(""), - "PartialParagraphBuildingBlock" => def.push_str(&format!( + for block in values.blocks { + use craft_idml::model::CrossReferenceBuildingBlock as Block; + match block { + Block::CustomText(text) => def.push_str(&text), + Block::FullParagraph => def.push_str(""), + Block::ParagraphText => def.push_str(""), + Block::ParagraphNumber => def.push_str(""), + Block::PageNumber => def.push_str(""), + Block::BookmarkName => def.push_str(""), + Block::ChapterNumber => def.push_str(""), + Block::FileName => def.push_str(""), + Block::PartialParagraph { delimiter, include_delimiter } => def.push_str(&format!( "", - text("AppliedDelimiter"), - b.get("IncludeDelimiter") == Some("true") + delimiter, include_delimiter )), - _ => {} } } - if let Some(me) = e.get("Self") { + if let Some(me) = values.self_id { self.xref_format_names.insert(me.to_string(), name.clone()); } match self.xref_formats.iter_mut().find(|f| f.name == name) { @@ -230,10 +229,11 @@ impl<'r> Importer<'r> { /// Preferences › `EPubExportPreference`: Split Document (after styles: it can name one). An /// empty style name splits on the styles' export tags; a style the file lacks splits nothing. pub(super) fn epub_split(&mut self, e: &El) { - if e.boolean("BreakDocument") != Some(true) { + let values = craft_idml::model::EpubSplitValues::from_el(&crate::xml::to_craft(e)); + if !values.break_document { return; } - let name = e.get("ParagraphStyleName").unwrap_or("$ID/NormalParagraphStyle"); + let name = values.paragraph_style.as_deref().unwrap_or("$ID/NormalParagraphStyle"); self.settings.epub_split = if name.trim().is_empty() { designcraft_doc::EpubSplit::ExportTags } else {