Skip to content

Conversation

@theaniketgiri
Copy link

Implements #2879: When exporting artwork as SVG, group elements ( tags) now include an 'id' attribute set to the layer's display name.

Changes:

  • Add node_names HashMap to RenderParams and RenderConfig to pass layer names from editor to rendering system
  • Add sanitize_svg_id() to convert layer names to valid SVG IDs:
    • Replaces spaces and colons with underscores
    • Strips invalid XML Name characters
    • Ensures ID starts with letter or underscore
  • Add make_unique_svg_id() to handle duplicate names with _2, _3 suffixes
  • Modify Table::render_svg() to add id attribute during export
  • Collect layer names recursively including nested layers/groups
  • Skip default 'Untitled Layer' and 'Untitled Node' names
  • Add comprehensive unit tests for ID sanitization and deduplication

Example: A layer named 'my:square' exports as
Duplicate names get suffixes: 'Layer', 'Layer_2', 'Layer_3'

Closes #2879

Implements GraphiteEditor#2879: When exporting artwork as SVG, group elements (<g> tags)
now include an 'id' attribute set to the layer's display name.

Changes:
- Add node_names HashMap to RenderParams and RenderConfig to pass layer
  names from editor to rendering system
- Add sanitize_svg_id() to convert layer names to valid SVG IDs:
  - Replaces spaces and colons with underscores
  - Strips invalid XML Name characters
  - Ensures ID starts with letter or underscore
- Add make_unique_svg_id() to handle duplicate names with _2, _3 suffixes
- Modify Table<Graphic>::render_svg() to add id attribute during export
- Collect layer names recursively including nested layers/groups
- Skip default 'Untitled Layer' and 'Untitled Node' names
- Add comprehensive unit tests for ID sanitization and deduplication

Example: A layer named 'my:square' exports as <g id='my_square'>
Duplicate names get suffixes: 'Layer', 'Layer_2', 'Layer_3'

Closes GraphiteEditor#2879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set exported SVG tag ID to its source layer name

1 participant