svg_conform 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -1
  3. data/.github/workflows/release.yml +6 -2
  4. data/.rubocop_todo.yml +273 -10
  5. data/Gemfile +1 -0
  6. data/README.adoc +54 -37
  7. data/config/profiles/metanorma.yml +4 -4
  8. data/docs/remediation.adoc +541 -542
  9. data/docs/requirements.adoc +800 -357
  10. data/examples/readme_usage.rb +67 -0
  11. data/examples/requirements_demo.rb +4 -4
  12. data/lib/svg_conform/document.rb +7 -1
  13. data/lib/svg_conform/element_proxy.rb +101 -0
  14. data/lib/svg_conform/fast_document_analyzer.rb +82 -0
  15. data/lib/svg_conform/node_index_builder.rb +47 -0
  16. data/lib/svg_conform/remediations/no_external_css_remediation.rb +4 -4
  17. data/lib/svg_conform/requirements/allowed_elements_requirement.rb +202 -0
  18. data/lib/svg_conform/requirements/base_requirement.rb +27 -0
  19. data/lib/svg_conform/requirements/color_restrictions_requirement.rb +53 -0
  20. data/lib/svg_conform/requirements/font_family_requirement.rb +18 -0
  21. data/lib/svg_conform/requirements/forbidden_content_requirement.rb +26 -0
  22. data/lib/svg_conform/requirements/id_reference_requirement.rb +96 -0
  23. data/lib/svg_conform/requirements/invalid_id_references_requirement.rb +91 -0
  24. data/lib/svg_conform/requirements/link_validation_requirement.rb +30 -0
  25. data/lib/svg_conform/requirements/namespace_attributes_requirement.rb +59 -0
  26. data/lib/svg_conform/requirements/namespace_requirement.rb +74 -0
  27. data/lib/svg_conform/requirements/no_external_css_requirement.rb +74 -0
  28. data/lib/svg_conform/requirements/no_external_fonts_requirement.rb +58 -0
  29. data/lib/svg_conform/requirements/no_external_images_requirement.rb +40 -0
  30. data/lib/svg_conform/requirements/style_requirement.rb +12 -0
  31. data/lib/svg_conform/requirements/viewbox_required_requirement.rb +72 -0
  32. data/lib/svg_conform/sax_document.rb +46 -0
  33. data/lib/svg_conform/sax_validation_handler.rb +158 -0
  34. data/lib/svg_conform/validation_context.rb +84 -2
  35. data/lib/svg_conform/validator.rb +74 -6
  36. data/lib/svg_conform/version.rb +1 -1
  37. data/lib/svg_conform.rb +1 -0
  38. data/spec/fixtures/namespace/repair/basic_violations.svg +3 -3
  39. data/spec/fixtures/namespace_attributes/repair/basic_violations.svg +2 -2
  40. data/spec/fixtures/no_external_css/repair/basic_violations.svg +2 -2
  41. data/spec/fixtures/style_promotion/repair/basic_test.svg +2 -2
  42. data/svg_conform.gemspec +1 -1
  43. metadata +12 -6
@@ -1,732 +1,731 @@
1
- = SVG Remediations
1
+ = SvgConform remediations
2
2
  :toc: left
3
3
  :toclevels: 3
4
4
  :sectlinks:
5
5
  :sectanchors:
6
6
  :source-highlighter: rouge
7
7
 
8
- == Overview
8
+ == Purpose
9
9
 
10
- **Remediations** are automatic fixing actions that can resolve requirement failures. Each remediation targets one or more specific requirements through a mapping system.
10
+ Remediations are automatic fixing actions that resolve requirement failures.
11
11
 
12
- Remediations are configured with specific parameters to customize their behavior and can be mapped to requirements using the `targets` configuration in profile YAML files.
12
+ Each remediation targets one or more specific requirements through a mapping
13
+ system configured in profile YAML files.
13
14
 
14
- == Remediation System
15
-
16
- === Targeting System
17
-
18
- Remediations are mapped to requirements using the `targets` configuration:
19
-
20
- [source,yaml]
21
- ----
22
- remediations:
23
- - id: "fix_invalid_colors"
24
- type: "ColorRemediation"
25
- description: "Convert invalid colors to black or white"
26
- targets: ["color_restrictions"] # Maps to ColorRestrictionsRequirement
27
- ----
28
-
29
- This mapping system allows:
30
- * **Targeted fixes**: Remediations only run when their target requirements fail
31
- * **Flexible configuration**: Multiple remediations can target the same requirement
32
- * **Conditional application**: Remediations can be enabled/disabled per profile
33
-
34
- === Remediation Types
15
+ == Available remediations
35
16
 
36
- Remediations are categorized by the type of fix they apply:
17
+ [[color-remediation]]
18
+ === Color remediation
37
19
 
38
- **Convert**: Transform invalid content to valid alternatives
39
- **Remove**: Delete non-compliant elements or attributes
40
- **Add**: Insert missing required content
41
- **Promote**: Change content structure while preserving meaning
20
+ ==== General
42
21
 
43
- == Available remediations
22
+ Converts invalid colors to allowed alternatives using the enhanced CssColor
23
+ system with threshold-based conversion.
44
24
 
45
- SvgConform provides 9 different remediation types that automatically fix validation violations.
25
+ Implemented as `ColorRemediation`.
46
26
 
47
- === Content conversion remediations
27
+ ==== Configuration options
48
28
 
49
- [[color-remediation]]
50
- ==== ColorRemediation
29
+ `conversion_strategy`:: Strategy for color conversion: `"threshold"`,
30
+ `"nearest"`, or `"strict"`. Default: `"threshold"`.
51
31
 
52
- Converts invalid colors to allowed alternatives using the enhanced CssColor system with threshold-based conversion.
32
+ `fallback_color`:: Default color when conversion is not possible. Default:
33
+ `"black"`.
53
34
 
54
- **Configuration Options**:
35
+ `preserve_transparency`:: Boolean flag to preserve alpha channel information.
36
+ Default: `false`.
55
37
 
56
- `conversion_strategy`:: Strategy for color conversion: `"threshold"`, `"nearest"`, or `"strict"`. Default: `"threshold"`.
57
- `fallback_color`:: Default color when conversion is not possible. Default: `"black"`.
58
- `preserve_transparency`:: Boolean flag to preserve alpha channel information. Default: `false`.
38
+ ==== Configuration
59
39
 
60
- Configuration:
40
+ .Example configuration of ColorRemediation
41
+ [example]
42
+ ====
61
43
  [source,yaml]
62
44
  ----
63
45
  - id: "fix_colors"
64
46
  type: "ColorRemediation"
65
47
  description: "Convert colors to allowed equivalents"
66
48
  targets: ["color_restrictions"]
67
- config:
68
- conversion_strategy: "threshold"
69
- fallback_color: "black"
70
- preserve_transparency: false
49
+ conversion_strategy: "threshold"
50
+ fallback_color: "black"
51
+ preserve_transparency: false
71
52
  ----
53
+ ====
72
54
 
73
- Where,
74
-
75
- `targets`:: List of requirement IDs that this remediation addresses.
55
+ ==== Example from svg_1_2_rfc profile
76
56
 
77
- .Using ColorRemediation with threshold-based conversion
78
57
  [example]
79
58
  ====
80
59
  [source,yaml]
81
60
  ----
82
- remediations:
83
- - id: "color_conversion"
84
- type: "ColorRemediation"
85
- description: "Convert colors to black and white using RGB threshold"
86
- targets: ["color_restrictions"]
87
- config:
88
- conversion_strategy: "threshold"
89
- fallback_color: "black"
61
+ - id: "color_conversion"
62
+ type: "ColorRemediation"
63
+ description: "Convert colors to black and white only per RFC 7996"
64
+ targets: ["color_restrictions"]
90
65
  ----
66
+
67
+ When the target ColorRestrictionsRequirement has a `black_and_white_threshold`
68
+ configured, the remediation applies threshold-based conversion: RGB sum ≤
69
+ threshold → black, RGB sum > threshold → white.
91
70
  ====
92
71
 
93
- When the target ColorRestrictionsRequirement has a `black_and_white_threshold` configured, the remediation applies threshold-based conversion:
94
- - RGB sum ≤ threshold → converted to `black`
95
- - RGB sum > threshold converted to `white`
72
+ ==== Threshold-based conversion
73
+
74
+ When `black_and_white_threshold` is configured in the target requirement:
96
75
 
97
- **Targets**: link:requirements.adoc#color-restrictions-requirement[ColorRestrictionsRequirement] violations
98
- **Remediation Type**: Convert
99
- **Confidence**: Automatic
76
+ * Colors with RGB sum ≤ 764 convert to `black`
77
+ * Colors with RGB sum > 764 convert to `white`
78
+ * Preserves color intent (dark → black, light → white)
100
79
 
101
- Features:
102
- * **Smart color conversion** using CssColor equivalence and threshold logic
103
- * **Threshold-based conversion**: When `black_and_white_threshold` is configured, applies RGB sum logic
104
- * **Preserves color intent** when possible (dark black, light → white)
105
- * **Handles all color formats**: named, hex, RGB, percentage RGB, short hex, mixed formats
106
- * **Case-insensitive processing**: Handles uppercase color names and hex values
80
+ ==== Features
81
+
82
+ * Smart color conversion using CssColor equivalence and threshold logic
83
+ * Handles all color formats: named, hex, RGB, percentage RGB, short hex
84
+ * Case-insensitive processing
107
85
  * Updates both attributes and style properties
108
86
 
87
+ ==== Related requirement
88
+
89
+ * link:requirements.adoc#color-restrictions-requirement[ColorRestrictionsRequirement]
90
+
91
+
109
92
  [[font-remediation]]
110
- ==== FontRemediation
93
+ === Font remediation
94
+
95
+ ==== General
111
96
 
112
97
  Maps font families to generic alternatives.
113
98
 
114
- **Configuration Options**:
99
+ Implemented as `FontRemediation`.
100
+
101
+ ==== Configuration options
115
102
 
116
103
  `font_mapping`:: Hash mapping specific font names to generic alternatives.
117
- `default_family`:: Default font family for unmapped fonts. Default: `"sans-serif"`.
118
- `preserve_fallbacks`:: Boolean flag to preserve existing font fallback lists. Default: `true`.
119
- `case_sensitive`:: Boolean flag for case-sensitive font name matching. Default: `false`.
120
104
 
121
- Configuration:
105
+ `default_family`:: Default font family for unmapped fonts. Default:
106
+ `"sans-serif"`.
107
+
108
+ `preserve_fallbacks`:: Boolean flag to preserve existing font fallback lists.
109
+ Default: `true`.
110
+
111
+ `case_sensitive`:: Boolean flag for case-sensitive font name matching.
112
+ Default: `false`.
113
+
114
+ ==== Configuration
115
+
116
+ .Example configuration of FontRemediation
117
+ [example]
118
+ ====
122
119
  [source,yaml]
123
120
  ----
124
121
  - id: "fix_fonts"
125
122
  type: "FontRemediation"
126
123
  description: "Convert to generic font families"
127
124
  targets: ["font_family"]
128
- config:
129
- default_family: "sans-serif"
130
- preserve_fallbacks: true
131
- case_sensitive: false
132
- font_mapping:
133
- "Arial": "sans-serif"
134
- "Helvetica": "sans-serif"
135
- "Times": "serif"
136
- "Times New Roman": "serif"
137
- "Courier": "monospace"
138
- "Courier New": "monospace"
139
- ----
140
-
141
- **Targets**: link:requirements.adoc#font-family-requirement[FontFamilyRequirement] violations
142
- **Remediation Type**: Convert
143
- **Confidence**: Automatic
144
-
145
- Features:
125
+ default_family: "sans-serif"
126
+ preserve_fallbacks: true
127
+ case_sensitive: false
128
+ font_mapping:
129
+ "Arial": "sans-serif"
130
+ "Helvetica": "sans-serif"
131
+ "Times": "serif"
132
+ ----
133
+ ====
134
+
135
+ ==== Example from svg_1_2_rfc profile
136
+
137
+ [example]
138
+ ====
139
+ [source,yaml]
140
+ ----
141
+ - id: "font_family_conversion"
142
+ type: "FontRemediation"
143
+ description: "Convert font families to generic families per RFC 7996"
144
+ targets: ["font_family"]
145
+ default_family: "sans-serif"
146
+ allowed_families: ["serif", "sans-serif", "monospace", "inherit"]
147
+ ----
148
+
149
+ RFC 7996 Section 17 requires generic font families. The remediation converts
150
+ specific fonts like Arial to sans-serif.
151
+ ====
152
+
153
+ ==== Features
154
+
146
155
  * Configurable font family mappings
147
156
  * Handles comma-separated font lists
148
157
  * Updates both font-family attributes and style properties
149
158
  * Preserves font fallback chains when configured
150
159
  * Case-insensitive font matching
151
160
 
152
- === Element and attribute removal remediations
161
+ ==== Related requirement
162
+
163
+ * link:requirements.adoc#font-family-requirement[FontFamilyRequirement]
164
+
165
+
166
+ [[font-embedding-remediation]]
167
+ === Font embedding remediation
168
+
169
+ ==== General
170
+
171
+ Converts external font references to embedded data URIs.
172
+
173
+ Implemented as `FontEmbeddingRemediation`.
174
+
175
+ ==== Configuration options
176
+
177
+ This remediation does not require additional configuration options. It
178
+ automatically processes external font references and embeds them as data URIs.
179
+
180
+ ==== Configuration
181
+
182
+ .Example configuration of FontEmbeddingRemediation
183
+ [example]
184
+ ====
185
+ [source,yaml]
186
+ ----
187
+ - id: "font_embedding"
188
+ type: "FontEmbeddingRemediation"
189
+ description: "Convert external font references to embedded fonts"
190
+ targets: ["no_external_fonts"]
191
+ ----
192
+ ====
193
+
194
+ ==== Example from metanorma profile
195
+
196
+ [example]
197
+ ====
198
+ [source,yaml]
199
+ ----
200
+ - id: "font_embedding"
201
+ type: "FontEmbeddingRemediation"
202
+ description: "Convert external font references to embedded fonts"
203
+ targets: ["no_external_fonts"]
204
+ ----
205
+
206
+ Fetches external font files and embeds them as data URIs for self-contained
207
+ SVG documents.
208
+ ====
209
+
210
+ ==== Font format support
211
+
212
+ Supported font formats:
213
+
214
+ * WOFF2 (`font/woff2`)
215
+ * WOFF (`font/woff`)
216
+ * TTF (`font/ttf`)
217
+ * OTF (`font/otf`)
218
+ * EOT (`application/vnd.ms-fontobject`)
219
+
220
+ ==== Features
221
+
222
+ * Fetches external font files via HTTP/HTTPS
223
+ * Encodes fonts as base64 data URIs
224
+ * Processes CSS `@font-face` rules in `<style>` elements
225
+ * Processes SVG `<font-face-uri>` elements in font definitions
226
+ * Automatic MIME type detection based on file extension
227
+ * Preserves visual appearance while making document self-contained
228
+ * Network-dependent: Requires access to external font URLs
229
+
230
+ ==== Important notes
231
+
232
+ * Requires network access to fetch external fonts
233
+ * Font embedding significantly increases SVG file size
234
+ * Failed font fetches are logged but do not halt processing
235
+ * Suitable for creating portable, self-contained documents
236
+
237
+ ==== Related requirement
238
+
239
+ * link:requirements.adoc#no-external-fonts-requirement[NoExternalFontsRequirement]
240
+
241
+
242
+ [[image-embedding-remediation]]
243
+ === Image embedding remediation
244
+
245
+ ==== General
246
+
247
+ Converts external image references to embedded data URIs.
248
+
249
+ Implemented as `ImageEmbeddingRemediation`.
250
+
251
+ ==== Configuration options
252
+
253
+ This remediation does not require additional configuration options. It
254
+ automatically processes external image references and embeds them as data URIs.
255
+
256
+ ==== Configuration
257
+
258
+ .Example configuration of ImageEmbeddingRemediation
259
+ [example]
260
+ ====
261
+ [source,yaml]
262
+ ----
263
+ - id: "image_embedding"
264
+ type: "ImageEmbeddingRemediation"
265
+ description: "Convert external image references to embedded images"
266
+ targets: ["no_external_images"]
267
+ ----
268
+ ====
269
+
270
+ ==== Example from metanorma profile
271
+
272
+ [example]
273
+ ====
274
+ [source,yaml]
275
+ ----
276
+ - id: "image_embedding"
277
+ type: "ImageEmbeddingRemediation"
278
+ description: "Convert external image references to embedded images"
279
+ targets: ["no_external_images"]
280
+ ----
281
+
282
+ Fetches external image files and embeds them as data URIs for PDF/A compliance
283
+ and offline portability.
284
+ ====
285
+
286
+ ==== Image format support
287
+
288
+ Supported image formats:
289
+
290
+ * PNG (`image/png`)
291
+ * JPEG (`image/jpeg`)
292
+ * GIF (`image/gif`)
293
+ * SVG (`image/svg+xml`)
294
+ * WebP (`image/webp`)
295
+ * BMP (`image/bmp`)
296
+ * ICO (`image/x-icon`)
297
+
298
+ ==== Features
299
+
300
+ * Fetches external image files via HTTP/HTTPS
301
+ * Encodes images as base64 data URIs
302
+ * Processes `<image>` elements with `href` and `xlink:href` attributes
303
+ * Processes style attributes with `url()` references
304
+ * Automatic MIME type detection based on file extension
305
+ * Preserves visual appearance while making document self-contained
306
+ * Network-dependent: Requires access to external image URLs
307
+
308
+ ==== Important notes
309
+
310
+ * Requires network access to fetch external images
311
+ * Image embedding significantly increases SVG file size
312
+ * Failed image fetches are logged but do not halt processing
313
+ * Suitable for PDF/A compliance and offline document portability
314
+ * Essential for creating archived documents with embedded graphics
315
+
316
+ ==== Related requirement
317
+
318
+ * link:requirements.adoc#no-external-images-requirement[NoExternalImagesRequirement]
319
+
153
320
 
154
321
  [[namespace-remediation]]
155
- ==== NamespaceRemediation
322
+ === Namespace remediation
323
+
324
+ ==== General
156
325
 
157
326
  Removes invalid namespace elements and attributes.
158
327
 
159
- **Configuration Options**:
328
+ Implemented as `NamespaceRemediation`.
329
+
330
+ ==== Configuration options
331
+
332
+ `default_namespace`:: Default namespace to apply to elements. Default:
333
+ `"http://www.w3.org/2000/svg"`.
334
+
335
+ `preserve_content`:: Boolean flag to preserve element content when removing
336
+ namespace elements. Default: `false`.
337
+
338
+ `cleanup_declarations`:: Boolean flag to remove unused namespace declarations.
339
+ Default: `true`.
160
340
 
161
- `default_namespace`:: Default namespace to apply to elements. Default: `"http://www.w3.org/2000/svg"`.
162
- `preserve_content`:: Boolean flag to preserve element content when removing namespace elements. Default: `false`.
163
- `cleanup_declarations`:: Boolean flag to remove unused namespace declarations. Default: `true`.
341
+ `allowed_namespaces`:: List of namespace URIs that are valid.
164
342
 
165
- Configuration:
343
+ `remove_elements`:: Boolean flag to remove elements with invalid namespaces.
344
+ Default: `true`.
345
+
346
+ `remove_attributes`:: Boolean flag to remove attributes with invalid
347
+ namespaces. Default: `true`.
348
+
349
+ `remove_declarations`:: Boolean flag to remove namespace declarations. Default:
350
+ `true`.
351
+
352
+ ==== Configuration
353
+
354
+ .Example configuration of NamespaceRemediation
355
+ [example]
356
+ ====
166
357
  [source,yaml]
167
358
  ----
168
359
  - id: "fix_namespaces"
169
360
  type: "NamespaceRemediation"
170
361
  description: "Remove invalid namespace content"
171
362
  targets: ["namespace_validation"]
172
- config:
173
- default_namespace: "http://www.w3.org/2000/svg"
174
- preserve_content: false
175
- cleanup_declarations: true
363
+ default_namespace: "http://www.w3.org/2000/svg"
364
+ preserve_content: false
365
+ cleanup_declarations: true
366
+ ----
367
+ ====
368
+
369
+ ==== Example from metanorma profile
370
+
371
+ [example]
372
+ ====
373
+ [source,yaml]
176
374
  ----
375
+ - id: "namespace_cleanup"
376
+ type: "NamespaceRemediation"
377
+ description: "Remove foreign namespace elements and declarations"
378
+ targets: ["namespace_validation", "namespace_attributes"]
379
+ allowed_namespaces:
380
+ - "http://www.w3.org/2000/svg"
381
+ - "http://www.w3.org/1999/xlink"
382
+ - "http://www.w3.org/XML/1998/namespace"
383
+ remove_elements: true
384
+ remove_attributes: true
385
+ remove_declarations: true
386
+ ----
387
+
388
+ Removes Inkscape, Sodipodi, and other tool-specific namespace content to
389
+ create clean, portable SVG.
390
+ ====
177
391
 
178
- **Targets**: link:requirements.adoc#namespace-requirement[NamespaceRequirement] violations
179
- **Remediation Type**: Remove
180
- **Confidence**: Safe Removal
392
+ ==== Features
181
393
 
182
- Features:
183
- * **Removes invalid namespace elements** (e.g., `<custom:element>`)
184
- * **Removes invalid namespace attributes** (e.g., `custom:attr`)
185
- * **Preserves valid namespaces** (SVG, XLink, XML)
186
- * **Cleans up namespace declarations**
394
+ * Removes invalid namespace elements (e.g., `<inkscape:layer>`)
395
+ * Removes invalid namespace attributes (e.g., `inkscape:groupmode`)
396
+ * Preserves valid namespaces (SVG, XLink, XML)
397
+ * Cleans up namespace declarations
187
398
  * Optional content preservation during element removal
188
399
 
400
+ ==== Related requirement
401
+
402
+ * link:requirements.adoc#namespace-requirement[NamespaceRequirement]
403
+
404
+
189
405
  [[namespace-attribute-remediation]]
190
- ==== NamespaceAttributeRemediation
406
+ === Namespace attribute remediation
407
+
408
+ ==== General
191
409
 
192
410
  Removes attributes from disallowed namespaces.
193
411
 
194
- **Configuration Options**:
412
+ Implemented as `NamespaceAttributeRemediation`.
413
+
414
+ ==== Configuration options
195
415
 
196
- `removal_strategy`:: Strategy for attribute removal: `"remove_all"` or `"selective"`. Default: `"selective"`.
197
- `preserve_data`:: Boolean flag to preserve data contained in removed attributes. Default: `false`.
416
+ `removal_strategy`:: Strategy for attribute removal: `"remove_all"` or
417
+ `"selective"`. Default: `"selective"`.
198
418
 
199
- Configuration:
419
+ `preserve_data`:: Boolean flag to preserve data contained in removed
420
+ attributes. Default: `false`.
421
+
422
+ `disallowed_namespaces`:: List of namespace URIs to remove attributes from.
423
+
424
+ ==== Configuration
425
+
426
+ .Example configuration of NamespaceAttributeRemediation
427
+ [example]
428
+ ====
200
429
  [source,yaml]
201
430
  ----
202
431
  - id: "fix_namespace_attrs"
203
432
  type: "NamespaceAttributeRemediation"
204
433
  description: "Remove disallowed namespace attributes"
205
434
  targets: ["namespace_attributes"]
206
- config:
207
- removal_strategy: "selective"
208
- preserve_data: false
435
+ removal_strategy: "selective"
436
+ preserve_data: false
209
437
  ----
438
+ ====
210
439
 
211
- **Targets**: link:requirements.adoc#namespace-attributes-requirement[NamespaceAttributesRequirement] violations
212
- **Remediation Type**: Remove
213
- **Confidence**: Safe Removal
440
+ ==== Example from lucid_fix profile
441
+
442
+ [example]
443
+ ====
444
+ [source,yaml]
445
+ ----
446
+ - id: "lucid_namespace_fix"
447
+ type: "NamespaceAttributeRemediation"
448
+ description: "Remove lucid namespace attributes and declarations"
449
+ targets: ["namespace_attributes_requirement"]
450
+ disallowed_namespaces:
451
+ - "lucid"
452
+ ----
453
+
454
+ Removes Lucid-specific namespace attributes (e.g., `lucid:*`) from
455
+ Lucid-generated SVG exports.
456
+ ====
457
+
458
+ ==== Features
214
459
 
215
- Features:
216
460
  * Removes attributes from disallowed namespaces
217
461
  * Selective removal based on namespace blacklist/whitelist
218
462
  * Optional data preservation for removed attributes
219
463
  * Maintains document structure integrity
220
464
 
465
+ ==== Related requirement
466
+
467
+ * link:requirements.adoc#namespace-attributes-requirement[NamespaceAttributesRequirement]
468
+
469
+
221
470
  [[no-external-css-remediation]]
222
- ==== NoExternalCssRemediation
471
+ === No external CSS remediation
472
+
473
+ ==== General
223
474
 
224
475
  Removes external CSS references.
225
476
 
226
- **Configuration Options**:
477
+ Implemented as `NoExternalCssRemediation`.
478
+
479
+ ==== Configuration options
480
+
481
+ `strategy`:: Removal strategy: `"remove_external_references"`,
482
+ `"inline_external"`, or `"convert_to_internal"`. Default:
483
+ `"remove_external_references"`.
227
484
 
228
- `strategy`:: Removal strategy: `"remove_external_references"`, `"inline_external"`, or `"convert_to_internal"`. Default: `"remove_external_references"`.
229
- `preserve_internal_styles`:: Boolean flag to preserve internal `<style>` elements. Default: `true`.
485
+ `preserve_internal_styles`:: Boolean flag to preserve internal `<style>`
486
+ elements. Default: `true`.
230
487
 
231
- Configuration:
488
+ ==== Configuration
489
+
490
+ .Example configuration of NoExternalCssRemediation
491
+ [example]
492
+ ====
232
493
  [source,yaml]
233
494
  ----
234
495
  - id: "remove_external_css"
235
496
  type: "NoExternalCssRemediation"
236
497
  description: "Remove external CSS references"
237
498
  targets: ["no_external_css"]
238
- config:
239
- strategy: "remove_external_references"
240
- preserve_internal_styles: true
499
+ strategy: "remove_external_references"
500
+ preserve_internal_styles: true
241
501
  ----
502
+ ====
503
+
504
+ ==== Example from metanorma profile
242
505
 
243
- **Targets**: link:requirements.adoc#no-external-css-requirement[NoExternalCssRequirement] violations
244
- **Remediation Type**: Remove
245
- **Confidence**: Safe Removal
506
+ Currently not used in metanorma profile (external CSS is blocked without
507
+ automatic remediation).
508
+
509
+ ==== Features
246
510
 
247
- Features:
248
511
  * Removes external `<link>` elements
249
512
  * Strips `@import` statements from `<style>` elements
250
513
  * Removes external URLs from style attributes
251
514
  * Optional preservation of internal styles
252
515
  * Configurable removal strategies
253
516
 
254
- === Addition remediations
517
+ ==== Related requirement
255
518
 
256
- [[viewbox-remediation]]
257
- ==== ViewboxRemediation
519
+ * link:requirements.adoc#no-external-css-requirement[NoExternalCssRequirement]
258
520
 
259
- Adds missing viewBox attributes to root SVG elements.
260
521
 
261
- **Configuration Options**:
522
+ [[viewbox-remediation]]
523
+ === ViewBox remediation
262
524
 
263
- `generation_strategy`:: Strategy for viewBox generation: `"from_dimensions"`, `"from_content"`, or `"default"`. Default: `"from_dimensions"`.
264
- `default_viewbox`:: Default viewBox value when automatic generation fails. Default: `"0 0 100 100"`.
265
- `preserve_existing`:: Boolean flag to preserve existing viewBox attributes. Default: `true`.
266
- `auto_calculate_bounds`:: Boolean flag to calculate bounds from SVG content. Default: `false`.
525
+ ==== General
267
526
 
268
- Configuration:
269
- [source,yaml]
270
- ----
271
- - id: "add_viewbox"
272
- type: "ViewboxRemediation"
273
- description: "Add missing viewBox attributes"
274
- targets: ["viewbox_required"]
275
- config:
276
- generation_strategy: "from_dimensions"
277
- default_viewbox: "0 0 100 100"
278
- preserve_existing: true
279
- auto_calculate_bounds: false
280
- ----
527
+ Adds missing viewBox attributes to root SVG elements.
281
528
 
282
- **Targets**: link:requirements.adoc#viewbox-required-requirement[ViewboxRequiredRequirement] violations
283
- **Remediation Type**: Add
284
- **Confidence**: Safe Structural
529
+ Implemented as `ViewboxRemediation`.
285
530
 
286
- Features:
287
- * Auto-generates viewBox from width/height attributes
288
- * Handles malformed viewBox values
289
- * Preserves existing valid viewBox attributes
290
- * Optional content-based bounds calculation
291
- * Configurable fallback values
531
+ ==== Configuration options
292
532
 
293
- === Style processing remediations
533
+ `generation_strategy`:: Strategy for viewBox generation: `"from_dimensions"`,
534
+ `"from_content"`, or `"default"`. Default: `"from_dimensions"`.
294
535
 
295
- [[style-promotion-remediation]]
296
- ==== StylePromotionRemediation
536
+ `default_viewbox`:: Default viewBox value when automatic generation fails.
537
+ Default: `"0 0 100 100"`.
297
538
 
298
- Promotes CSS style properties to SVG attributes.
539
+ `preserve_existing`:: Boolean flag to preserve existing viewBox attributes.
540
+ Default: `true`.
299
541
 
300
- **Configuration Options**:
542
+ `auto_calculate_bounds`:: Boolean flag to calculate bounds from SVG content.
543
+ Default: `false`.
301
544
 
302
- `promotable_properties`:: List of CSS properties that can be promoted to SVG attributes.
303
- `preserve_style_attribute`:: Boolean flag to preserve original style attribute after promotion. Default: `false`.
304
- `selective_promotion`:: Boolean flag to promote only when beneficial. Default: `true`.
545
+ ==== Configuration
305
546
 
306
- Configuration:
547
+ .Example configuration of ViewboxRemediation
548
+ [example]
549
+ ====
307
550
  [source,yaml]
308
551
  ----
309
- - id: "promote_styles"
310
- type: "StylePromotionRemediation"
311
- description: "Promote style properties to attributes"
312
- targets: ["style_promotion"]
313
- config:
314
- preserve_style_attribute: false
315
- selective_promotion: true
316
- promotable_properties:
317
- - "fill"
318
- - "stroke"
319
- - "font-family"
320
- - "font-size"
321
- - "opacity"
322
- ----
323
-
324
- **Targets**: link:requirements.adoc#style-promotion-requirement[StylePromotionRequirement] violations
325
- **Remediation Type**: Promote
326
- **Confidence**: Automatic
327
-
328
- Features:
329
- * Converts style properties to equivalent SVG attributes
330
- * Improves SVG compatibility and optimization
331
- * Preserves visual appearance while changing structure
332
- * Configurable property selection
333
- * Optional selective promotion based on benefit analysis
334
-
335
- === Reference fixing remediations
336
-
337
- [[invalid-id-references-remediation]]
338
- ==== InvalidIdReferencesRemediation
339
-
340
- Fixes or removes broken ID references.
341
-
342
- **Configuration Options**:
552
+ - id: "add_viewbox"
553
+ type: "ViewboxRemediation"
554
+ description: "Add missing viewBox attributes"
555
+ targets: ["viewbox_required"]
556
+ generation_strategy: "from_dimensions"
557
+ default_viewbox: "0 0 100 100"
558
+ preserve_existing: true
559
+ ----
560
+ ====
343
561
 
344
- `strategy`:: Fixing strategy: `"remove_broken_elements"`, `"remove_references"`, or `"create_placeholders"`. Default: `"remove_broken_elements"`.
345
- `preserve_structure`:: Boolean flag to maintain document structure when removing elements. Default: `true`.
346
- `placeholder_content`:: Content to use for placeholder elements when using `"create_placeholders"` strategy.
562
+ ==== Example from svg_1_2_rfc profile
347
563
 
348
- Configuration:
564
+ [example]
565
+ ====
349
566
  [source,yaml]
350
567
  ----
351
- - id: "fix_broken_refs"
352
- type: "InvalidIdReferencesRemediation"
353
- description: "Fix broken ID references"
354
- targets: ["id_references", "invalid_id_references"]
355
- config:
356
- strategy: "remove_broken_elements"
357
- preserve_structure: true
358
- placeholder_content: "<!-- Missing reference -->"
568
+ - id: "viewbox_generation"
569
+ type: "ViewboxRemediation"
570
+ description: "Auto-generate viewBox from width/height per RFC 7996"
571
+ targets: ["viewbox_required"]
359
572
  ----
360
573
 
361
- **Targets**: link:requirements.adoc#id-reference-requirement[IdReferenceRequirement], InvalidIdReferencesRequirement violations
362
- **Remediation Type**: Remove
363
- **Confidence**: Safe Removal
364
-
365
- Features:
366
- * Removes `<use>` elements with broken href references
367
- * Removes or fixes other broken ID references
368
- * Can replace with placeholder content or remove entirely
369
- * Configurable fixing strategies
370
- * Maintains document structural integrity
371
-
372
- == Structural Invalidity and Descendant Skipping
373
-
374
- SvgConform implements **structural invalidity tracking** to match svgcheck's behavior of removing invalid elements with all their children.
375
-
376
- === How It Works
377
-
378
- When an element is determined to be structurally invalid (e.g., not an allowed element, or has an invalid parent-child relationship):
379
-
380
- 1. **Element marked invalid**: The element is marked as structurally invalid in the validation context
381
- 2. **Descendants recursively marked**: All child elements are recursively marked as invalid
382
- 3. **Validation skipping**: All requirements skip validation of structurally invalid nodes
383
- 4. **Single error reported**: Only the parent element error is reported, not separate errors for each child
384
-
385
- === Benefits
386
-
387
- **Prevents Cascade Errors**:
388
- - Invalid `<font>` element → 48 `<glyph>` children automatically skipped
389
- - Invalid `<clipPath>` parent → all children skipped
390
- - Matches svgcheck: removes element WITH all children
391
-
392
- **Example**:
393
-
394
- Without structural invalidity tracking:
395
- ```
396
- ERROR: Element 'font' is not allowed as a child of 'defs'
397
- ERROR: Element 'font-face' is not allowed in this profile
398
- ERROR: Element 'missing-glyph' is not allowed in this profile
399
- ERROR: Element 'glyph' is not allowed in this profile (x48 times)
400
- Total: 51 errors
401
- ```
402
-
403
- With structural invalidity tracking:
404
- ```
405
- ERROR: Element 'font' is not allowed as a child of 'defs'
406
- Total: 1 error
407
- ```
408
-
409
- === Implementation
410
-
411
- **Marking Invalid Nodes** (in AllowedElementsRequirement):
412
- ```ruby
413
- unless allowed_elements.include?(element_name)
414
- context.add_error(...)
415
- context.mark_node_structurally_invalid(node) # Marks node and all descendants
416
- return
417
- end
418
- ```
419
-
420
- **Skipping Invalid Nodes** (in BaseRequirement):
421
- ```ruby
422
- def should_check_node?(node, context = nil)
423
- return false unless node.respond_to?(:name) && node.respond_to?(:attributes)
424
- return false if context && context.node_structurally_invalid?(node)
425
- true
426
- end
427
- ```
574
+ Automatically generates viewBox attribute from width and height attributes
575
+ when missing.
576
+ ====
428
577
 
429
- **Recursive Descendant Marking** (in ValidationContext):
430
- ```ruby
431
- def mark_node_structurally_invalid(node)
432
- @structurally_invalid_node_ids.add(generate_node_id(node))
433
- mark_descendants_invalid(node) # Recursively mark all descendants
434
- end
435
- ```
578
+ ==== Features
436
579
 
437
- === Impact on Remediations
580
+ * Auto-generates viewBox from width/height attributes
581
+ * Handles malformed viewBox values
582
+ * Preserves existing valid viewBox attributes
583
+ * Optional content-based bounds calculation
584
+ * Configurable fallback values
438
585
 
439
- Remediations automatically benefit from structural invalidity tracking:
586
+ ==== Related requirement
440
587
 
441
- * **Fewer errors to process**: Only parent errors, not descendant errors
442
- * **Cleaner error reports**: More focused, actionable error messages
443
- * **Better performance**: Less validation work on invalid subtrees
444
- * **Matches svgcheck**: 100% compatibility with svgcheck behavior
588
+ * link:requirements.adoc#viewbox-required-requirement[ViewboxRequiredRequirement]
445
589
 
446
- == Violation Types and Remediability
447
590
 
448
- SvgConform categorizes violations into two main types:
591
+ [[style-promotion-remediation]]
592
+ === Style promotion remediation
449
593
 
450
- === Remediable Violations
594
+ ==== General
451
595
 
452
- These can be automatically fixed through remediation processing:
596
+ Promotes CSS style properties to SVG attributes.
453
597
 
454
- **ColorViolation** (`color_restrictions`):
455
- * **Remediation**: Convert using CssColor equivalence system
456
- * **Examples**: `red` → `black`, `#f00` → `#000000`
457
- * **Confidence**: Automatic
598
+ Implemented as `StylePromotionRemediation`.
458
599
 
459
- **FontViolation** (`font_family`):
460
- * **Remediation**: Map to generic font families
461
- * **Examples**: `Arial` → `sans-serif`, `Times New Roman` → `serif`
462
- * **Confidence**: Automatic
600
+ ==== Configuration options
463
601
 
464
- **ContentViolation** (`forbidden_content`):
465
- * **Remediation**: Remove forbidden elements/attributes
466
- * **Examples**: Remove `<script>`, `onclick` attributes
467
- * **Confidence**: Safe removal
602
+ `promotable_properties`:: List of CSS properties that can be promoted to SVG
603
+ attributes.
468
604
 
469
- **ReferenceViolation** (`id_reference`, `link_validation`):
470
- * **Remediation**: Remove broken references or elements
471
- * **Examples**: Remove `<use>` with invalid href, broken links
472
- * **Confidence**: Safe removal
605
+ `preserve_style_attribute`:: Boolean flag to preserve original style attribute
606
+ after promotion. Default: `false`.
473
607
 
474
- **NamespaceViolation** (`namespace`, `namespace_attributes`):
475
- * **Remediation**: Remove invalid namespace elements/attributes
476
- * **Examples**: Remove `<inkscape:layer>`, `custom:attr`
477
- * **Confidence**: Safe removal
478
-
479
- **ViewboxViolation** (`viewbox_required`):
480
- * **Remediation**: Add missing viewBox attributes
481
- * **Examples**: Generate from width/height dimensions
482
- * **Confidence**: Safe structural
483
-
484
- **StyleViolation** (`style`, `style_promotion`):
485
- * **Remediation**: Promote or convert style properties
486
- * **Examples**: Move `style="fill:black"` to `fill="black"`
487
- * **Confidence**: Automatic
488
-
489
- === Non-Remediable Violations
490
-
491
- These require manual intervention:
492
-
493
- **StructuralViolation**:
494
- * **Examples**: Malformed XML, root element not `<svg>`, invalid document hierarchy
495
- * **Reason**: Automatic fixing could break document integrity or change meaning
496
- * **Solution**: Manual document restructuring required
497
-
498
- == Configuration Best Practices
499
-
500
- === Remediation Configuration
608
+ `selective_promotion`:: Boolean flag to promote only when beneficial. Default:
609
+ `true`.
501
610
 
502
- **Target Mapping**:
503
- [source,yaml]
504
- ----
505
- remediations:
506
- - id: "comprehensive_color_fix"
507
- type: "ColorRemediation"
508
- description: "Handle all color violations"
509
- targets: ["color_restrictions", "style_colors"] # Multiple targets
510
- ----
611
+ ==== Configuration
511
612
 
512
- **Strategy Selection**:
613
+ .Example configuration of StylePromotionRemediation
614
+ [example]
615
+ ====
513
616
  [source,yaml]
514
617
  ----
515
- - id: "safe_id_fix"
516
- type: "InvalidIdReferencesRemediation"
517
- targets: ["id_references"]
518
- config:
519
- strategy: "remove_references" # Conservative approach
520
- preserve_structure: true
521
-
522
- - id: "aggressive_id_fix"
523
- type: "InvalidIdReferencesRemediation"
524
- targets: ["id_references"]
525
- config:
526
- strategy: "remove_broken_elements" # More thorough cleanup
527
- preserve_structure: false
618
+ - id: "promote_styles"
619
+ type: "StylePromotionRemediation"
620
+ description: "Promote style properties to attributes"
621
+ targets: ["style_promotion"]
622
+ preserve_style_attribute: false
623
+ selective_promotion: true
624
+ promotable_properties: ["fill", "stroke", "font-family", "font-size"]
528
625
  ----
626
+ ====
529
627
 
530
- === Performance Optimization
531
-
532
- **Efficient Remediation Order**:
533
- 1. **Namespace cleanups** (removes invalid content early)
534
- 2. **Content removal** (reduces document size for subsequent processing)
535
- 3. **Content conversion** (processes remaining valid content)
536
- 4. **Structure additions** (adds missing required elements)
537
- 5. **Style promotion** (final optimization step)
628
+ ==== Example from svg_1_2_rfc profile
538
629
 
539
- **Remediation Grouping**:
630
+ [example]
631
+ ====
540
632
  [source,yaml]
541
633
  ----
542
- # Group related remediations for efficiency
543
- remediations:
544
- - id: "namespace_cleanup"
545
- type: "NamespaceRemediation"
546
- targets: ["namespace_validation"]
547
- - id: "namespace_attrs_cleanup"
548
- type: "NamespaceAttributeRemediation"
549
- targets: ["namespace_attributes"]
550
- - id: "color_conversion"
551
- type: "ColorRemediation"
552
- targets: ["color_restrictions"]
634
+ - id: "style_promotion"
635
+ type: "StylePromotionRemediation"
636
+ description: "Promote valid style properties to attributes per RFC 7996"
637
+ targets: ["style_promotion"]
553
638
  ----
554
639
 
555
- === Safety Configuration
640
+ Converts style properties to equivalent SVG attributes for better
641
+ compatibility.
642
+ ====
556
643
 
557
- **Conservative Settings**:
558
- [source,yaml]
559
- ----
560
- - id: "safe_remediation"
561
- type: "NamespaceRemediation"
562
- config:
563
- preserve_content: true # Don't lose content
564
- cleanup_declarations: false # Minimal cleanup
565
- ----
644
+ ==== Features
566
645
 
567
- **Aggressive Settings**:
568
- [source,yaml]
569
- ----
570
- - id: "thorough_cleanup"
571
- type: "NamespaceRemediation"
572
- config:
573
- preserve_content: false # Remove invalid content
574
- cleanup_declarations: true # Full cleanup
575
- ----
646
+ * Converts style properties to equivalent SVG attributes
647
+ * Improves SVG compatibility and optimization
648
+ * Preserves visual appearance while changing structure
649
+ * Configurable property selection
650
+ * Optional selective promotion based on benefit analysis
576
651
 
577
- == Advanced Configuration
652
+ ==== Related requirement
578
653
 
579
- === Conditional Remediations
654
+ * link:requirements.adoc#style-promotion-requirement[StylePromotionRequirement]
580
655
 
581
- Remediations can be configured to apply conditionally based on document characteristics:
582
656
 
583
- [source,yaml]
584
- ----
585
- - id: "conditional_color_fix"
586
- type: "ColorRemediation"
587
- description: "Apply color conversion only to specific elements"
588
- targets: ["color_restrictions"]
589
- config:
590
- apply_to_elements: ["rect", "circle"] # Only fix colors on these elements
591
- conversion_strategy: "threshold"
592
- ----
593
-
594
- === Custom Remediation Strategies
657
+ [[invalid-id-references-remediation]]
658
+ === Invalid ID references remediation
595
659
 
596
- Define custom strategies for complex remediation scenarios:
660
+ ==== General
597
661
 
598
- [source,yaml]
599
- ----
600
- - id: "smart_font_mapping"
601
- type: "FontRemediation"
602
- targets: ["font_family"]
603
- config:
604
- font_mapping:
605
- # Map common fonts to generic equivalents
606
- "Arial": "sans-serif"
607
- "Helvetica": "sans-serif"
608
- "Georgia": "serif"
609
- "Verdana": "sans-serif"
610
- fallback_strategy: "closest_generic" # Find closest generic match
611
- preserve_fallbacks: true
612
- ----
662
+ Fixes or removes broken ID references.
613
663
 
614
- === Remediation Chaining
664
+ Implemented as `InvalidIdReferencesRemediation`.
615
665
 
616
- Configure remediations to work together in sequence:
666
+ ==== Configuration options
617
667
 
618
- [source,yaml]
619
- ----
620
- remediations:
621
- # Step 1: Clean up namespaces
622
- - id: "namespace_cleanup"
623
- type: "NamespaceRemediation"
624
- targets: ["namespace_validation"]
668
+ `strategy`:: Fixing strategy: `"remove_broken_elements"`,
669
+ `"remove_references"`, or `"create_placeholders"`. Default:
670
+ `"remove_broken_elements"`.
625
671
 
626
- # Step 2: Remove invalid attributes (depends on step 1)
627
- - id: "attribute_cleanup"
628
- type: "NamespaceAttributeRemediation"
629
- targets: ["namespace_attributes"]
630
- depends_on: ["namespace_cleanup"]
672
+ `preserve_structure`:: Boolean flag to maintain document structure when
673
+ removing elements. Default: `true`.
631
674
 
632
- # Step 3: Fix remaining content (depends on steps 1-2)
633
- - id: "content_fixes"
634
- type: "ColorRemediation"
635
- targets: ["color_restrictions"]
636
- depends_on: ["namespace_cleanup", "attribute_cleanup"]
637
- ----
675
+ `placeholder_content`:: Content to use for placeholder elements when using
676
+ `"create_placeholders"` strategy.
638
677
 
639
- == Enhanced Color System
678
+ `log_removed_elements`:: Boolean flag to log removed elements. Default:
679
+ `false`.
640
680
 
641
- SvgConform uses the `CssColor` class for advanced color equivalence recognition:
681
+ `create_placeholder_comment`:: Boolean flag to create placeholder comments.
682
+ Default: `false`.
642
683
 
643
- === Color Equivalence Examples
684
+ ==== Configuration
644
685
 
645
- [source]
686
+ .Example configuration of InvalidIdReferencesRemediation
687
+ [example]
688
+ ====
689
+ [source,yaml]
646
690
  ----
647
- # These are all equivalent and recognized as "white":
648
- white
649
- #ffffff
650
- #FFFFFF
651
- #fff
652
- #FFF
653
- rgb(255,255,255)
654
- rgba(255,255,255,1.0)
655
-
656
- # These are all equivalent and recognized as "black":
657
- black
658
- #000000
659
- #000
660
- rgb(0,0,0)
691
+ - id: "fix_broken_refs"
692
+ type: "InvalidIdReferencesRemediation"
693
+ description: "Fix broken ID references"
694
+ targets: ["id_references"]
695
+ strategy: "remove_broken_elements"
696
+ preserve_structure: true
697
+ placeholder_content: "<!-- Missing reference -->"
661
698
  ----
699
+ ====
662
700
 
663
- === Color Conversion Features
664
-
665
- * **Normalization**: All color formats converted to canonical hex
666
- * **Named Color Support**: Full CSS named color palette
667
- * **Case Insensitive**: Hex colors match regardless of case
668
- * **Short Hex Expansion**: `#fff` automatically expands to `#ffffff`
669
- * **RGB Function Parsing**: `rgb(255,0,0)` converts to `#ff0000`
670
- * **Equivalence Checking**: Smart matching across all formats
701
+ ==== Example from lucid_fix profile
671
702
 
672
- Usage in color remediation:
673
- [source,ruby]
703
+ [example]
704
+ ====
705
+ [source,yaml]
674
706
  ----
675
- # These will all be recognized as equivalent to "white":
676
- CssColor.equivalent?("#fff", "white") # => true
677
- CssColor.equivalent?("#FFFFFF", "#fff") # => true
678
- CssColor.normalize("rgb(255,255,255)") # => "#ffffff"
679
- CssColor.to_canonical("#fff") # => "white"
707
+ - id: "remove_invalid_use_elements"
708
+ type: "InvalidIdReferencesRemediation"
709
+ description: "Remove use elements with invalid ID references (Lucid fix)"
710
+ targets: ["invalid_id_references"]
711
+ strategy: "remove_invalid_use"
712
+ log_removed_elements: true
713
+ create_placeholder_comment: false
680
714
  ----
681
715
 
682
- == Troubleshooting
683
-
684
- === Common Remediation Issues
685
-
686
- **Target Mismatch**:
687
- - Ensure remediation `targets` match requirement IDs exactly
688
- - Check that target requirements are included in the same profile
689
- - Verify requirement IDs are spelled correctly
716
+ Removes broken `<use>` elements from Lucid-generated SVGs without creating
717
+ placeholder comments.
718
+ ====
690
719
 
691
- **Configuration Errors**:
692
- - Validate YAML syntax for remediation configuration
693
- - Ensure all referenced configuration parameters exist
694
- - Check parameter types match expected values
720
+ ==== Features
695
721
 
696
- **Remediation Conflicts**:
697
- - Avoid multiple remediations targeting the same content
698
- - Order remediations to prevent conflicts
699
- - Use conditional application when needed
722
+ * Removes `<use>` elements with broken href references
723
+ * Removes or fixes other broken ID references
724
+ * Can replace with placeholder content or remove entirely
725
+ * Configurable fixing strategies
726
+ * Maintains document structural integrity
700
727
 
701
- === Debugging Remediations
728
+ ==== Related requirement
702
729
 
703
- **Enable detailed logging**:
704
- [source,yaml]
705
- ----
706
- - id: "debug_remediation"
707
- type: "ColorRemediation"
708
- targets: ["color_restrictions"]
709
- config:
710
- debug_logging: true # Enable detailed remediation logs
711
- trace_changes: true # Track all changes made
712
- ----
713
-
714
- **Test remediation results**:
715
- - Always validate remediated documents
716
- - Check that visual appearance is preserved
717
- - Verify no new validation errors are introduced
718
- - Test with representative SVG files
719
-
720
- === Performance Troubleshooting
721
-
722
- **Slow remediations**:
723
- - Profile remediation performance with timing
724
- - Check for expensive operations in configuration
725
- - Consider breaking complex remediations into simpler ones
726
- - Optimize target requirement selection
727
-
728
- **Memory usage**:
729
- - Monitor memory consumption during large document processing
730
- - Use streaming processing for very large SVG files
731
- - Consider processing documents in batches
732
- - Optimize configuration data structures
730
+ * link:requirements.adoc#id-reference-requirement[IdReferenceRequirement]
731
+ * link:requirements.adoc#invalid-id-references-requirement[InvalidIdReferencesRequirement]