From 04505e5ccc8df619abc9ebbf1e4fcfaf1bd4ae68 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 08:32:22 -0500 Subject: [PATCH] Parse IDML footnote preferences in shared model --- crates/idml/src/model/mod.rs | 2 +- crates/idml/src/model/preferences.rs | 58 ++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/crates/idml/src/model/mod.rs b/crates/idml/src/model/mod.rs index 5ceeef2b5..b7e0c45ac 100644 --- a/crates/idml/src/model/mod.rs +++ b/crates/idml/src/model/mod.rs @@ -24,7 +24,7 @@ use craft_xml::{El, Local, Node}; pub use document::{ModelDocument, TopLevelKind, TopLevelNode}; pub use effects::{DirectionalFeatherValues, DropShadowValues, FeatherValues, GradientFeatherValues, OpacityStopValues, TransparencySetting}; pub use geometry::{MAX_PATH_POINTS, PathGeometry, PathGeometryError, PathPoint, SubPath}; -pub use preferences::{DocumentPreferences, GridPreferences, TextFramePreferences}; +pub use preferences::{DocumentPreferences, FootnotePreferences, GridPreferences, TextFramePreferences}; pub use resources::{ CharacterAppearanceValues, CharacterSpecialValues, CharacterTypographyValues, CjkCharacterValues, CjkParagraphValues, ColorDefinition, ColorGroup, ColorGroupDefinition, ColorGroupMember, ColorSpace, CompositeFontDefinition, CompositeFontEntryDefinition, EpubExportTagMap, diff --git a/crates/idml/src/model/preferences.rs b/crates/idml/src/model/preferences.rs index c3cd6dc40..389c3727d 100644 --- a/crates/idml/src/model/preferences.rs +++ b/crates/idml/src/model/preferences.rs @@ -135,6 +135,64 @@ pub struct GridPreferences { pub grids_in_back: Option, } +/// Parsed values from IDML `FootnoteOption` elements. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct FootnotePreferences { + pub start_at: Option, + pub prefix: Option, + pub suffix: Option, + pub paragraph_style: Option, + pub marker_style: Option, + pub separator: Option, + pub space_between: Option, + pub space_before: Option, + pub first_baseline: Option, + pub first_baseline_minimum: Option, + pub span_columns: Option, + pub rule_on: Option, + pub rule_weight: Option, + pub rule_tint: Option, + pub rule_left_indent: Option, + pub rule_width: Option, + pub rule_offset: Option, + pub rule_color: Option, + pub numbering_style: Option, + pub restart_numbering: Option, + pub show_prefix_suffix: Option, + pub marker_positioning: Option, +} + +impl FootnotePreferences { + /// Reads footnote preference attributes and properties from IDML. + pub fn from_el(el: &El) -> Self { + let values = Values::of(el); + Self { + start_at: values.num("StartAt"), + prefix: values.get("Prefix").map(str::to_owned), + suffix: values.get("Suffix").map(str::to_owned), + paragraph_style: values.get("FootnoteTextStyle").map(str::to_owned), + marker_style: values.get("FootnoteMarkerStyle").map(str::to_owned), + separator: values.get("SeparatorText").map(str::to_owned), + space_between: values.num("SpaceBetween"), + space_before: values.num("Spacer"), + first_baseline: values.prop("FootnoteFirstBaselineOffset"), + first_baseline_minimum: values.num("FootnoteMinimumFirstBaselineOffset"), + span_columns: values.boolean("EnableStraddling"), + rule_on: values.boolean("RuleOn"), + rule_weight: values.num("RuleLineWeight"), + rule_tint: values.num("RuleTint"), + rule_left_indent: values.num("RuleLeftIndent"), + rule_width: values.num("RuleWidth"), + rule_offset: values.num("RuleOffset"), + rule_color: values.prop("RuleColor"), + numbering_style: values.prop("FootnoteNumberingStyle"), + restart_numbering: values.prop("RestartNumbering"), + show_prefix_suffix: values.prop("ShowPrefixSuffix"), + marker_positioning: values.prop("MarkerPositioning"), + } + } +} + impl GridPreferences { /// Reads baseline and document-grid values. pub fn from_el(el: &El) -> Self {