Tables: DeckCraft's own table styles still map back to their ids

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-12 18:00:42 -04:00
co-authored by Claude Opus 5.5
parent a38da4bff8
commit 35229a6409
2 changed files with 12 additions and 1 deletions
+6 -1
View File
@@ -402,8 +402,13 @@ fn table(imp: &mut Imp, part: &Part, tbl: &El) -> Table {
t.band_col = pr.bool("bandCol").unwrap_or(false);
if let Some(id) = pr.child("tableStyleId").map(|e| e.text()) {
// A style the file defines is drawn from its definition (by its GUID).
// DeckCraft's own styles (written with GUIDs derived from their ids) map back to them.
let up = id.trim().to_ascii_uppercase();
t.style = if imp.table_style_ids.contains(&up) { up } else { crate::tables::style_from_guid(id.trim()) };
t.style = if imp.table_style_ids.contains(&up) && !crate::tables::is_own_guid(&up) {
up
} else {
crate::tables::style_from_guid(id.trim())
};
}
}
t.cols = tbl
+6
View File
@@ -47,6 +47,12 @@ fn own_guid(style: &str) -> String {
guid(&format!("deckcraft-table-style:{style}"))
}
/// Is `g` the GUID DeckCraft writes for one of its own styles?
pub fn is_own_guid(g: &str) -> bool {
let up = g.to_ascii_uppercase();
deckcraft_model::table::table_styles().iter().any(|(id, _)| own_guid(id) == up)
}
/// Table style GUID → our style id (or the GUID itself when unknown).
pub fn style_from_guid(g: &str) -> String {
let up = g.to_ascii_uppercase();