mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Use shared IDML cross-reference and EPUB models
This commit is contained in:
3 files changed
+31
-31
No files matched your search
Generated
+10
-10
@@ -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",
|
||||
|
||||
+2
-2
@@ -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" }
|
||||
|
||||
@@ -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("<fullPara />"),
|
||||
"ParagraphTextBuildingBlock" => def.push_str("<paraText />"),
|
||||
"ParagraphNumberBuildingBlock" => def.push_str("<paraNum />"),
|
||||
"PageNumberBuildingBlock" => def.push_str("<pageNum />"),
|
||||
"BookmarkNameBuildingBlock" => def.push_str("<txtAnchrName />"),
|
||||
"ChapterNumberBuildingBlock" => def.push_str("<chapNum />"),
|
||||
"FileNameBuildingBlock" => def.push_str("<fileName />"),
|
||||
"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("<fullPara />"),
|
||||
Block::ParagraphText => def.push_str("<paraText />"),
|
||||
Block::ParagraphNumber => def.push_str("<paraNum />"),
|
||||
Block::PageNumber => def.push_str("<pageNum />"),
|
||||
Block::BookmarkName => def.push_str("<txtAnchrName />"),
|
||||
Block::ChapterNumber => def.push_str("<chapNum />"),
|
||||
Block::FileName => def.push_str("<fileName />"),
|
||||
Block::PartialParagraph { delimiter, include_delimiter } => def.push_str(&format!(
|
||||
"<partialPara delim=\"{}\" includeDelim=\"{}\" />",
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user