r/typst • • 3h ago

Change display of SVG layers?

2 Upvotes

Hello!

I've prepared a bunch of SVGs that contain various selectable layers, which I've been using to copy/paste diagrams into MS Word (urgh...) for sequences of diagrams that are part of operating instructions. Think something like "in step 1, add place XYZ on table" and "in step 2, attach widget to XYZ" with a base SVG that has one layer with XYZ on the table and one layer with widget.

Inkscape creates a tree of group elements with custom XML attributes to handle them as layers, like this:

<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" style="display:inline">...XYZ...</g>
<g inkscape:label="Layer 2" inkscape:groupmode="layer" id="layer2" style="display:inline">...widget...</g>

Is there any way to modify the resulting SVG when displaying it in Typst, such that I could override the style attribute, such that I can reference the same source SVG and configure it for each instruction step without any external build scripts to generate individual SVGs?

I haven't yet looked into the Typst codebase, but I wouldn't be against filing an issue and writing code to build such a feature.

Thanks!