From cb081910833758e7d3c224ee2ac7bf094fc97309 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sat, 3 Jan 2026 18:10:21 -0600 Subject: [PATCH] close #3451: support comma-separated stylesheet paths Enable multiple CSS files in stylesheet_path using comma separation. Files are loaded in order with natural CSS cascading behavior. Example: "base.css, overrides.css" --- .../bonsai/bim/module/drawing/svgwriter.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py index 2d8c4e60cf..d7ddd0b9f7 100644 --- a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py +++ b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py @@ -257,14 +257,16 @@ class SvgWriter: self.height = self.raw_height * self.svg_scale def add_stylesheet(self): - path = self.resource_paths["Stylesheet"] - if not path: + paths = self.resource_paths["Stylesheet"] + if not paths: return - if not os.path.exists(path): - print(f"WARNING. Couldn't find stylesheet for the drawing by the path: {path}") - return - with open(path, "r") as stylesheet: - self.svg.defs.add(self.svg.style(stylesheet.read())) + path_list = [p.strip() for p in paths.split(',')] + for path in path_list: + if not os.path.exists(path): + print(f"WARNING. Couldn't find stylesheet for the drawing by the path: {path}") + continue + with open(path, "r") as stylesheet: + self.svg.defs.add(self.svg.style(stylesheet.read())) def add_markers(self): path = self.resource_paths["Markers"]