Model IDML EPUB export tag maps

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 09:05:19 -05:00
1 parent 6ee8c75b06
commit f3e59accad
2 files changed
+35 -3

No files matched your search

+3 -3
View File
@@ -27,9 +27,9 @@ pub use geometry::{MAX_PATH_POINTS, PathGeometry, PathGeometryError, PathPoint,
pub use preferences::TextFramePreferences;
pub use resources::{
ColorDefinition, ColorGroup, ColorGroupDefinition, ColorGroupMember, ColorSpace, CompositeFontDefinition, CompositeFontEntryDefinition,
FontDefinition, FontFamilyDefinition, FontsPart, GradientDefinition, GradientStop, GradientStopDefinition, GradientStopValue, GraphicPart, Ink,
InkDefinition, StrokeDefinition, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleGroupWriter, StyleKind, StyleNode, Swatch, SwatchKind,
TintDefinition, color_groups, inks, named, preference, stroke_styles, style_groups, swatches,
EpubExportTagMap, FontDefinition, FontFamilyDefinition, FontsPart, GradientDefinition, GradientStop, GradientStopDefinition, GradientStopValue,
GraphicPart, Ink, InkDefinition, StrokeDefinition, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleGroupWriter, StyleKind, StyleNode,
Swatch, SwatchKind, TintDefinition, color_groups, inks, named, preference, stroke_styles, style_groups, swatches,
};
pub use spread::{
Graphic, GraphicChild, GraphicKind, Guide, ItemChild, ItemKind, Link, MarginPreference, Page, PageChild, PageItem, Spread, SpreadChild, TextPath,
+32
View File
@@ -140,6 +140,38 @@ pub enum StyleNode {
Other(El),
}
/// EPUB export tagging stored on a style in IDML.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct EpubExportTagMap {
pub tag: String,
pub class: String,
pub split_document: bool,
}
impl EpubExportTagMap {
/// Reads an EPUB `StyleExportTagMap`; other export types are not this record.
pub fn from_el(el: &El) -> Option<Self> {
let values = Values::of(el);
(el.local() == "StyleExportTagMap" && values.get("ExportType") == Some("EPUB")).then(|| Self {
tag: values.get("ExportTag").unwrap_or("").to_owned(),
class: values.get("ExportClass").unwrap_or("").to_owned(),
split_document: values.get("SplitDocument") == Some("true"),
})
}
/// Writes the EPUB tag map with its caller-assigned IDML `Self` identifier.
pub fn to_el(&self, self_id: &str) -> El {
El::new("StyleExportTagMap")
.with_attr("Self", self_id)
.with_attr("ExportType", "EPUB")
.with_attr("ExportTag", &self.tag)
.with_attr("ExportClass", &self.class)
.with_attr("ExportAttributes", "")
.with_attr("SplitDocument", if self.split_document { "true" } else { "false" })
.with_attr("EmitCss", "true")
}
}
/// A style, its values as written: `Name`, `Self`, `Properties/BasedOn`, its attributes; and its
/// other children (an object style's `TextFramePreference`, effect settings, …).
#[derive(Clone, Debug, PartialEq)]