mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
Add shared designmap root and include builders
This commit is contained in:
2 files changed
+23
-1
No files matched your search
@@ -39,7 +39,10 @@ pub mod value;
|
||||
|
||||
pub use craft_xml::{El, Local, Node};
|
||||
pub use package::{Document, Limits, Package, write_package};
|
||||
pub use part::{CONTAINER_XML, Props, designmap_xml, designmap_xml_with_pi, parse_part, part_root, part_xml, prop, with_props, xml_limits};
|
||||
pub use part::{
|
||||
CONTAINER_XML, Props, designmap_include, designmap_root, designmap_xml, designmap_xml_with_pi, parse_part, part_root, part_xml, prop, with_props,
|
||||
xml_limits,
|
||||
};
|
||||
|
||||
/// The IDML package mimetype (content of the first, stored `mimetype` entry).
|
||||
pub const MIMETYPE: &str = "application/vnd.adobe.indesign-idml-package";
|
||||
|
||||
@@ -16,6 +16,25 @@ pub const fn xml_limits() -> craft_xml::Limits {
|
||||
/// `META-INF/container.xml` of a package.
|
||||
pub const CONTAINER_XML: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n\t<rootfiles>\n\t\t<rootfile full-path=\"designmap.xml\" media-type=\"text/xml\"/>\n\t</rootfiles>\n</container>\n";
|
||||
|
||||
/// The standard root element for `designmap.xml`, including its required namespace and core
|
||||
/// document identity fields. The caller supplies DesignCraft-independent values; children are
|
||||
/// appended after construction.
|
||||
pub fn designmap_root(self_id: &str, story_list: &str, name: &str, zero_point: &str, active_layer: &str) -> El {
|
||||
El::new("Document")
|
||||
.with_attr("xmlns:idPkg", PACKAGING_NS)
|
||||
.with_attr("DOMVersion", DOM_VERSION)
|
||||
.with_attr("Self", self_id)
|
||||
.with_attr("StoryList", story_list)
|
||||
.with_attr("Name", name)
|
||||
.with_attr("ZeroPoint", zero_point)
|
||||
.with_attr("ActiveLayer", active_layer)
|
||||
}
|
||||
|
||||
/// An `idPkg` reference in `designmap.xml` to a part stored at `src`.
|
||||
pub fn designmap_include(kind: &str, src: &str) -> El {
|
||||
El::new(format!("idPkg:{kind}")).with_attr("src", src)
|
||||
}
|
||||
|
||||
/// Parses a part into its root element with [`xml_limits`].
|
||||
///
|
||||
/// Names are kept as written (`idPkg:Story`), text is kept exactly (it is story content), CDATA
|
||||
|
||||
Reference in new issue
Block a user