svg_conform 0.2.7 → 0.2.9

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.
data/docs/cli_guide.adoc CHANGED
@@ -60,7 +60,7 @@ The `check` command validates SVG files against a profile and optionally applies
60
60
 
61
61
  [source,bash]
62
62
  ----
63
- $ svg_conform check file.svg --profile=metanorma
63
+ $ svg_conform check file.svg --profile=metanorma-sample
64
64
  ----
65
65
 
66
66
  Output example:
@@ -70,7 +70,7 @@ Output example:
70
70
  SVG Validation Report
71
71
  ==================================================
72
72
  File: file.svg
73
- Profile: metanorma
73
+ Profile: metanorma-sample
74
74
  Valid: ✗
75
75
  Total Errors: 2
76
76
 
@@ -88,7 +88,7 @@ Validation Errors:
88
88
 
89
89
  [source,bash]
90
90
  ----
91
- $ svg_conform check file1.svg file2.svg file3.svg -p metanorma
91
+ $ svg_conform check file1.svg file2.svg file3.svg -p metanorma-sample
92
92
  ----
93
93
 
94
94
  ==== Directory validation
@@ -97,7 +97,7 @@ Recursively validate all SVG files in a directory:
97
97
 
98
98
  [source,bash]
99
99
  ----
100
- $ svg_conform check --directory=images/ --profile=metanorma
100
+ $ svg_conform check --directory=images/ --profile=metanorma-sample
101
101
  ----
102
102
 
103
103
  Output shows a summary table and statistics.
@@ -157,13 +157,13 @@ Examples:
157
157
  [source,bash]
158
158
  ----
159
159
  # JSON output to stdout
160
- $ svg_conform check file.svg -p metanorma --format=json
160
+ $ svg_conform check file.svg -p metanorma-sample --format=json
161
161
 
162
162
  # JSON output to file
163
- $ svg_conform check file.svg -p metanorma --format=json -o report.json
163
+ $ svg_conform check file.svg -p metanorma-sample --format=json -o report.json
164
164
 
165
165
  # YAML output to file
166
- $ svg_conform check file.svg -p metanorma --format=yaml -o report.yaml
166
+ $ svg_conform check file.svg -p metanorma-sample --format=yaml -o report.yaml
167
167
  ----
168
168
 
169
169
  ==== Remediation options
@@ -194,13 +194,13 @@ Examples:
194
194
  [source,bash]
195
195
  ----
196
196
  # Single file with custom output
197
- $ svg_conform check file.svg -p metanorma --fix --fix-output=cleaned.svg
197
+ $ svg_conform check file.svg -p metanorma-sample --fix --fix-output=cleaned.svg
198
198
 
199
199
  # Multiple files to output directory
200
- $ svg_conform check *.svg -p metanorma --fix --output-dir=fixed/
200
+ $ svg_conform check *.svg -p metanorma-sample --fix --output-dir=fixed/
201
201
 
202
202
  # Directory with in-place replacement (destructive!)
203
- $ svg_conform check -d images/ -p metanorma --fix --in-place --force
203
+ $ svg_conform check -d images/ -p metanorma-sample --fix --in-place --force
204
204
  ----
205
205
 
206
206
  ==== Batch processing options
@@ -229,14 +229,14 @@ Examples:
229
229
  [source,bash]
230
230
  ----
231
231
  # Quiet mode - summary only
232
- $ svg_conform check -d images/ -p metanorma -q
232
+ $ svg_conform check -d images/ -p metanorma-sample -q
233
233
 
234
234
  # Generate detailed JSON report
235
- $ svg_conform check -d images/ -p metanorma \
235
+ $ svg_conform check -d images/ -p metanorma-sample \
236
236
  --report-format=json --report-output=full-report.json
237
237
 
238
238
  # Full workflow with manifest
239
- $ svg_conform check -d images/ -p metanorma --fix --output-dir=fixed/ \
239
+ $ svg_conform check -d images/ -p metanorma-sample --fix --output-dir=fixed/ \
240
240
  --manifest=file-mapping.json --report-format=json --report-output=report.json
241
241
  ----
242
242
 
@@ -248,7 +248,7 @@ Process one SVG file:
248
248
 
249
249
  [source,bash]
250
250
  ----
251
- $ svg_conform check file.svg -p metanorma
251
+ $ svg_conform check file.svg -p metanorma-sample
252
252
  ----
253
253
 
254
254
  Features:
@@ -264,7 +264,7 @@ Process multiple specified files:
264
264
 
265
265
  [source,bash]
266
266
  ----
267
- $ svg_conform check file1.svg file2.svg file3.svg -p metanorma
267
+ $ svg_conform check file1.svg file2.svg file3.svg -p metanorma-sample
268
268
  ----
269
269
 
270
270
  Features:
@@ -279,7 +279,7 @@ Recursively process all SVG files in a directory:
279
279
 
280
280
  [source,bash]
281
281
  ----
282
- $ svg_conform check --directory=images/ -p metanorma
282
+ $ svg_conform check --directory=images/ -p metanorma-sample
283
283
  ----
284
284
 
285
285
  Features:
@@ -297,7 +297,7 @@ Validate all SVGs before deployment:
297
297
 
298
298
  [source,bash]
299
299
  ----
300
- $ svg_conform check -d assets/images/ -p metanorma --quiet
300
+ $ svg_conform check -d assets/images/ -p metanorma-sample --quiet
301
301
 
302
302
  # Exit code 0 = all valid
303
303
  # Exit code 1 = validation failures
@@ -308,7 +308,7 @@ Use in CI/CD:
308
308
  [source,bash]
309
309
  ----
310
310
  #!/bin/bash
311
- if svg_conform check -d docs/images/ -p metanorma -q; then
311
+ if svg_conform check -d docs/images/ -p metanorma-sample -q; then
312
312
  echo "All SVGs valid"
313
313
  else
314
314
  echo "SVG validation failed"
@@ -323,10 +323,10 @@ Fix issues with review:
323
323
  [source,bash]
324
324
  ----
325
325
  # 1. Validate and see issues
326
- $ svg_conform check file.svg -p metanorma
326
+ $ svg_conform check file.svg -p metanorma-sample
327
327
 
328
328
  # 2. Apply fixes to new file
329
- $ svg_conform check file.svg -p metanorma --fix --fix-output=file-fixed.svg
329
+ $ svg_conform check file.svg -p metanorma-sample --fix --fix-output=file-fixed.svg
330
330
 
331
331
  # 3. Review the fixed file
332
332
  $ diff file.svg file-fixed.svg
@@ -345,15 +345,15 @@ Fix all non-conforming files in a directory:
345
345
  $ cp -r images/ images-backup/
346
346
 
347
347
  # 2. Generate pre-fix report
348
- $ svg_conform check -d images/ -p metanorma \
348
+ $ svg_conform check -d images/ -p metanorma-sample \
349
349
  --report-format=json --report-output=before.json
350
350
 
351
351
  # 3. Apply fixes to new directory
352
- $ svg_conform check -d images/ -p metanorma \
352
+ $ svg_conform check -d images/ -p metanorma-sample \
353
353
  --fix --output-dir=images-fixed/ --manifest=manifest.json
354
354
 
355
355
  # 4. Verify fixes
356
- $ svg_conform check -d images-fixed/ -p metanorma -q
356
+ $ svg_conform check -d images-fixed/ -p metanorma-sample -q
357
357
 
358
358
  # 5. If satisfied, replace originals
359
359
  $ rm -rf images/
@@ -370,10 +370,10 @@ Fix files in place (destructive):
370
370
  $ cp -r images/ images-backup/
371
371
 
372
372
  # Fix all files in place
373
- $ svg_conform check -d images/ -p metanorma --fix --in-place --force
373
+ $ svg_conform check -d images/ -p metanorma-sample --fix --in-place --force
374
374
 
375
375
  # Verify
376
- $ svg_conform check -d images/ -p metanorma -q
376
+ $ svg_conform check -d images/ -p metanorma-sample -q
377
377
  ----
378
378
 
379
379
  ==== Workflow 5: Selective remediation
@@ -383,12 +383,12 @@ Fix only specific files:
383
383
  [source,bash]
384
384
  ----
385
385
  # Find invalid files
386
- $ svg_conform check -d images/ -p metanorma -q > results.txt
386
+ $ svg_conform check -d images/ -p metanorma-sample -q > results.txt
387
387
 
388
388
  # Manually identify problematic files
389
389
  # Then fix them individually
390
- $ svg_conform check images/problematic1.svg -p metanorma -f
391
- $ svg_conform check images/problematic2.svg -p metanorma -f
390
+ $ svg_conform check images/problematic1.svg -p metanorma-sample -f
391
+ $ svg_conform check images/problematic2.svg -p metanorma-sample -f
392
392
  ----
393
393
 
394
394
  === Exit codes
@@ -403,7 +403,7 @@ Use exit codes in scripts:
403
403
 
404
404
  [source,bash]
405
405
  ----
406
- if svg_conform check file.svg -p metanorma; then
406
+ if svg_conform check file.svg -p metanorma-sample; then
407
407
  echo "Valid!"
408
408
  else
409
409
  echo "Invalid - see errors above"
@@ -443,7 +443,7 @@ xref:diagnostics.adoc[Diagnostics]). No timestamp is emitted by the CLI.
443
443
  {
444
444
  "schema_version": 1,
445
445
  "producer": { "name": "svg_conform", "version": "0.2.4" },
446
- "profile": { "id": "metanorma", "citations": [] },
446
+ "profile": { "id": "metanorma-sample", "citations": [] },
447
447
  "valid": false,
448
448
  "summary": { "errors": 1, "warnings": 0, "infos": 1 },
449
449
  "diagnostics": [ ... ],
@@ -465,7 +465,7 @@ For multiple files or directories:
465
465
  BATCH VALIDATION SUMMARY
466
466
  ================================================================================
467
467
  Directory: images/
468
- Profile: metanorma
468
+ Profile: metanorma-sample
469
469
  Files processed: 15
470
470
  Valid before: 8
471
471
  Remediated: 5
@@ -527,7 +527,7 @@ Example output:
527
527
  Detailed SVG Validation Profiles
528
528
  ==================================================
529
529
 
530
- Profile: metanorma
530
+ Profile: metanorma-sample
531
531
  ------------------------------
532
532
  Description: Metanorma document requirements
533
533
  Requirements: 12
@@ -587,7 +587,7 @@ $ svg_conform check --directory=/absolute/path/to/images/
587
587
  [source,bash]
588
588
  ----
589
589
  # Specify output directory
590
- $ svg_conform check *.svg -p metanorma --fix --output-dir=fixed/
590
+ $ svg_conform check *.svg -p metanorma-sample --fix --output-dir=fixed/
591
591
  ----
592
592
 
593
593
  ==== "--in-place requires --force"
@@ -599,7 +599,7 @@ $ svg_conform check *.svg -p metanorma --fix --output-dir=fixed/
599
599
  [source,bash]
600
600
  ----
601
601
  # Add --force flag
602
- $ svg_conform check -d images/ -p metanorma --fix --in-place --force
602
+ $ svg_conform check -d images/ -p metanorma-sample --fix --in-place --force
603
603
  ----
604
604
 
605
605
  ==== "Profile not found"
@@ -614,7 +614,7 @@ $ svg_conform check -d images/ -p metanorma --fix --in-place --force
614
614
  $ svg_conform profiles
615
615
 
616
616
  # Use correct profile name
617
- $ svg_conform check file.svg -p metanorma
617
+ $ svg_conform check file.svg -p metanorma-sample
618
618
  ----
619
619
 
620
620
  ==== Exit code 1 with valid files
@@ -636,11 +636,11 @@ For directories with many files:
636
636
  [source,bash]
637
637
  ----
638
638
  # Use quiet mode
639
- $ svg_conform check -d large-dir/ -p metanorma -q
639
+ $ svg_conform check -d large-dir/ -p metanorma-sample -q
640
640
 
641
641
  # Process in batches
642
642
  $ find images/ -name "*.svg" -print0 | \
643
- xargs -0 -n 50 svg_conform check -p metanorma
643
+ xargs -0 -n 50 svg_conform check -p metanorma-sample
644
644
  ----
645
645
 
646
646
  ==== Large SVG files
@@ -718,7 +718,7 @@ changed_svgs=$(git diff --cached --name-only --diff-filter=ACM | grep '\.svg$')
718
718
 
719
719
  if [ -n "$changed_svgs" ]; then
720
720
  echo "Validating SVG files..."
721
- echo "$changed_svgs" | xargs svg_conform check -p metanorma -q
721
+ echo "$changed_svgs" | xargs svg_conform check -p metanorma-sample -q
722
722
  if [ $? -ne 0 ]; then
723
723
  echo "SVG validation failed. Commit aborted."
724
724
  exit 1
@@ -744,7 +744,7 @@ jobs:
744
744
  with:
745
745
  ruby-version: 3.0
746
746
  - run: gem install svg_conform
747
- - run: svg_conform check -d docs/images/ -p metanorma --quiet
747
+ - run: svg_conform check -d docs/images/ -p metanorma-sample --quiet
748
748
  ----
749
749
 
750
750
  ==== Makefile integration
@@ -756,10 +756,10 @@ jobs:
756
756
  .PHONY: validate-svg fix-svg
757
757
 
758
758
  validate-svg:
759
- svg_conform check -d images/ -p metanorma --quiet
759
+ svg_conform check -d images/ -p metanorma-sample --quiet
760
760
 
761
761
  fix-svg:
762
- svg_conform check -d images/ -p metanorma \
762
+ svg_conform check -d images/ -p metanorma-sample \
763
763
  --fix --output-dir=images-fixed/ \
764
764
  --manifest=manifest.json
765
765
  @echo "Review images-fixed/ before replacing images/"
data/docs/profiles.adoc CHANGED
@@ -342,18 +342,24 @@ See link:remediation.adoc#namespace-attribute-remediation[NamespaceAttributeReme
342
342
  * Maintains valid SVG markup
343
343
 
344
344
  [[metanorma-profile]]
345
- === Metanorma profile (`:metanorma`)
345
+ === Metanorma sample profile (`:"metanorma-sample"`)
346
346
 
347
347
  **Purpose**: Ensures SVG documents comply with Metanorma requirements for technical documents with embedded resources.
348
348
 
349
349
  **Target use case**: Technical diagrams, flowcharts, and illustrations for Metanorma-generated standards documents (ISO, IEC, IETF, etc.).
350
350
 
351
+ This bundled profile is a sample and testing reference. Profiles are consumer
352
+ policy: the operative Metanorma profile ships and loads by path from
353
+ metanorma-standoc (`lib/metanorma/standoc/svg_conform_profile/metanorma.yml`),
354
+ so the `metanorma` name is not registered here and resolving it fails loudly
355
+ with `ProfileError: Profile not found`.
356
+
351
357
  **Key Characteristics**:
352
358
  * **Flexible colors**: Any colors allowed (unlike RFC 7996 black/white restriction)
353
359
  * **Flexible fonts**: Any font families allowed (unlike RFC 7996 generic-only restriction)
354
360
  * **Flexible styles**: Any CSS styles allowed
355
361
  * **Event handlers allowed**: Supports event attributes (`on*`) for interactivity
356
- * **Clipping and masking**: `clip-path` and `mask` presentation attributes allowed
362
+ * **Clipping and masking**: `clip-path` and `mask` presentation attributes allowed, and `clip-path`, `clip-rule`, and `opacity` allowed on container elements (`g`, `a`, `defs`)
357
363
  * **Self-contained resources**: All CSS and fonts must be embedded
358
364
  * **Structural compliance**: Proper namespaces and viewBox required
359
365
  * **No external dependencies**: External CSS and fonts strictly prohibited
@@ -42,7 +42,7 @@ The manifest provides complete context:
42
42
  ----
43
43
  require 'svg_conform'
44
44
 
45
- validator = SvgConform::Validator.new(profile: 'metanorma')
45
+ validator = SvgConform::Validator.new(profile: 'metanorma-sample')
46
46
  result = validator.validate(svg_content)
47
47
 
48
48
  # Access the reference manifest
@@ -296,7 +296,7 @@ puts result_hash[:reference_manifest]
296
296
  [source,ruby]
297
297
  ----
298
298
  # Validate SVG document
299
- result = validator.validate(svg_content, profile: 'metanorma')
299
+ result = validator.validate(svg_content, profile: 'metanorma-sample')
300
300
 
301
301
  # Get external references for consumer validation
302
302
  external_refs = result.external_references
@@ -368,4 +368,4 @@ Easy to add new reference types without modifying existing code.
368
368
  * link:requirements.adoc[Requirements Documentation]
369
369
  * link:api_reference.adoc[API Reference]
370
370
  * link:../README.adoc[Main README]
371
- * link:../config/profiles/metanorma.yml[Metanorma Profile Configuration]
371
+ * link:../config/profiles/metanorma-sample.yml[Metanorma Profile Configuration]
@@ -49,10 +49,10 @@ module SvgConform
49
49
  - yaml: LensCore diagnostics YAML (schema version 1)
50
50
 
51
51
  EXAMPLES:
52
- svg_conform check file.svg -p metanorma
53
- svg_conform check *.svg -p metanorma -f --output-dir fixed/
54
- svg_conform check -d images/ -p metanorma --report-format json --report-output report.json
55
- svg_conform check -d images/ -p metanorma -f --in-place --force
52
+ svg_conform check file.svg -p metanorma-sample
53
+ svg_conform check *.svg -p metanorma-sample -f --output-dir fixed/
54
+ svg_conform check -d images/ -p metanorma-sample --report-format json --report-output report.json
55
+ svg_conform check -d images/ -p metanorma-sample -f --in-place --force
56
56
  DESC
57
57
  option :directory, aliases: "-d", type: :string,
58
58
  desc: "Directory to scan recursively for SVG files"
@@ -205,7 +205,12 @@ requirement_id: nil, severity: nil, violation_type: nil)
205
205
  :font_violation
206
206
  when /forbidden|content/
207
207
  :content_violation
208
- when /reference|id/
208
+ # The bare substring /id/ misclassified any requirement whose id
209
+ # merely contains it ("namespace_val[id]ation", "link_val[id]ation")
210
+ # as :reference_violation — the type consumers drop for the separate
211
+ # reference pass, so their verdicts vanished from downstream logs
212
+ # (#133). Match the id token only as a whole word segment.
213
+ when /reference/, /(^|_)id($|_)/
209
214
  :reference_violation
210
215
  when /namespace/
211
216
  :namespace_violation
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SvgConform
4
- VERSION = "0.2.7"
4
+ VERSION = "0.2.9"
5
5
  end
@@ -0,0 +1,53 @@
1
+ require "spec_helper"
2
+
3
+ require "svg_conform/errors/validation_issue"
4
+
5
+ RSpec.describe SvgConform::Errors::ValidationIssue do
6
+ let(:node) { Struct.new(:name, :line, :column).new("g", 1, 1) }
7
+
8
+ def issue_for(requirement_id, message)
9
+ described_class.new(
10
+ type: :error,
11
+ rule: Struct.new(:id).new(requirement_id),
12
+ node: node,
13
+ message: message,
14
+ )
15
+ end
16
+
17
+ # metanorma's svg_error drops :reference_violation entries (the separate
18
+ # reference pass covers them); a misclassification here silently deletes
19
+ # profile verdicts from downstream logs (#133).
20
+ it "classifies reference requirements by the whole id token" do
21
+ expect(issue_for("id_references", "broken id reference").violation_type)
22
+ .to eq(:reference_violation)
23
+ expect(issue_for("id_collection", "collected").violation_type)
24
+ .to eq(:reference_violation)
25
+ expect(issue_for("external_references", "external reference").violation_type)
26
+ .to eq(:reference_violation)
27
+ end
28
+
29
+ it "does not misclassify ids that merely contain the substring id" do
30
+ expect(issue_for("namespace_validation", "namespace issue").violation_type)
31
+ .to eq(:namespace_violation)
32
+ expect(issue_for("link_validation", "bad link").violation_type)
33
+ .to eq(:unknown_violation)
34
+ expect(issue_for("allowed_elements", "Attribute 'opacity' is not allowed").violation_type)
35
+ .to eq(:unknown_violation)
36
+ end
37
+
38
+ it "keeps the message-based classification anchored on reference wording" do
39
+ expect(issue_for("unknown_rule", "broken reference to #missing").violation_type)
40
+ .to eq(:reference_violation)
41
+ expect(issue_for("unknown_rule", "broken href target").violation_type)
42
+ .to eq(:reference_violation)
43
+ end
44
+
45
+ it "classifies the other requirement families as before" do
46
+ expect(issue_for("forbidden_content", "Attribute 'fill' is not allowed").violation_type)
47
+ .to eq(:content_violation)
48
+ expect(issue_for("font_embedding", "font not embedded").violation_type)
49
+ .to eq(:font_violation)
50
+ expect(issue_for("viewbox_required", "missing viewBox").violation_type)
51
+ .to eq(:viewbox_violation)
52
+ end
53
+ end
@@ -5,13 +5,16 @@ require "spec_helper"
5
5
  RSpec.describe "svg_conform.gemspec" do # rubocop:disable RSpec/DescribeClass
6
6
  let(:specification) { Gem::Specification.load("svg_conform.gemspec") }
7
7
 
8
- it "does not gate installation on the unpublished lens_core gem" do
9
- # lens_core is optional: the canonical diagnostics renderer rides it
10
- # when installed, and the plain structural serializers answer when
11
- # not. A runtime dependency on the unpublished gem made 0.2.5
12
- # uninstallable for every consumer.
13
- expect(specification.runtime_dependencies.map(&:name)).not_to include("lens_core")
14
- expect(File.read("lib/svg_conform.rb")).to include("rescue LoadError")
8
+ it "declares the published lens_core gem as a runtime dependency" do
9
+ # lens_core 0.1.0 is on rubygems, so the 0.2.5-era optionality is
10
+ # obsolete: leaving it undeclared crashed the CLI on strict bundler
11
+ # deployments (rescue LoadError misses Bundler::GemNotFound,
12
+ # claricle/svg_conform#130). The guard in svg_conform.rb stays as a
13
+ # version-compatibility courtesy, not as the dependency mechanism.
14
+ dependency = specification.runtime_dependencies.find { |d| d.name == "lens_core" }
15
+
16
+ expect(dependency).not_to be_nil
17
+ expect(dependency.requirement).to eq(Gem::Requirement.new("~> 0.1"))
15
18
  end
16
19
 
17
20
  it "declares yeptris as a runtime dependency" do
@@ -31,4 +34,15 @@ RSpec.describe "svg_conform.gemspec" do # rubocop:disable RSpec/DescribeClass
31
34
  expect(SvgConform).to respond_to(:lens_core_available?)
32
35
  expect(SvgConform.lens_core_available?).to be_truthy.or be_falsey
33
36
  end
37
+
38
+ it "keeps the committed lockfile in sync with the gem version" do
39
+ # The release flow (metanorma/ci rubygems-release) deletes the lock and
40
+ # bumps version.rb without restoring it: staleness is this repo's own
41
+ # guard (ci's words). Without this check, every post-release PR fails
42
+ # bundler 4's frozen install ("gemspecs for path gems changed") before
43
+ # anyone sees why.
44
+ lock = File.read("Gemfile.lock")
45
+ path_version = lock[/\APATH\n remote: \.\n specs:\n svg_conform \(([^)]+)\)/, 1]
46
+ expect(path_version).to eq(SvgConform::VERSION)
47
+ end
34
48
  end
@@ -8,17 +8,22 @@ METANORMA_PROFILE_CONTAINER_TAGS = %w[g a defs].freeze
8
8
  METANORMA_PROFILE_CLIP_ATTRIBUTES = %w[clip-path mask].freeze
9
9
 
10
10
  RSpec.describe "Metanorma Profile" do
11
- let(:metanorma_profile_path) { "config/profiles/metanorma.yml" }
11
+ let(:metanorma_sample_profile_path) { "config/profiles/metanorma-sample.yml" }
12
+
13
+ let(:validator) { SvgConform::Validator.new(mode: :sax, profile: profile) }
14
+ let(:profile) do
15
+ SvgConform::Profile.load_from_file("config/profiles/metanorma-sample.yml")
16
+ end
12
17
 
13
18
  describe "profile loading" do
14
19
  it "loads the Metanorma profile successfully" do
15
- profile = SvgConform::Profile.load_from_file(metanorma_profile_path)
20
+ profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
16
21
  expect(profile).not_to be_nil
17
- expect(profile.name).to eq("metanorma")
22
+ expect(profile.name).to eq("metanorma-sample")
18
23
  end
19
24
 
20
25
  it "includes external resource requirements" do
21
- profile = SvgConform::Profile.load_from_file(metanorma_profile_path)
26
+ profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
22
27
  requirement_ids = profile.requirements.map(&:id)
23
28
  expect(requirement_ids).to include("no_external_css")
24
29
  expect(requirement_ids).to include("no_external_fonts")
@@ -26,7 +31,7 @@ RSpec.describe "Metanorma Profile" do
26
31
  end
27
32
 
28
33
  it "includes comprehensive element support" do
29
- profile = SvgConform::Profile.load_from_file(metanorma_profile_path)
34
+ profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
30
35
  requirement_ids = profile.requirements.map(&:id)
31
36
  expect(requirement_ids).to include("allowed_elements")
32
37
  end
@@ -41,7 +46,7 @@ RSpec.describe "Metanorma Profile" do
41
46
  SVG
42
47
 
43
48
  document = SvgConform::Document.from_content(svg_with_colors)
44
- profile = SvgConform::Profile.load_from_file(metanorma_profile_path)
49
+ profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
45
50
 
46
51
  result = profile.validate(document)
47
52
  color_errors = result.errors.select do |e|
@@ -58,7 +63,7 @@ RSpec.describe "Metanorma Profile" do
58
63
  SVG
59
64
 
60
65
  document = SvgConform::Document.from_content(svg_with_image)
61
- profile = SvgConform::Profile.load_from_file(metanorma_profile_path)
66
+ profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
62
67
 
63
68
  result = profile.validate(document)
64
69
  expect(result).to respond_to(:valid?)
@@ -69,7 +74,7 @@ RSpec.describe "Metanorma Profile" do
69
74
  # SVG applies the clip-path and mask properties to container elements and
70
75
  # graphics elements alike; rejecting them on containers rejects
71
76
  # schema-valid documents (metanorma-pdfa#106).
72
- let(:profile) { SvgConform::Profile.load_from_file(metanorma_profile_path) }
77
+ let(:profile) { SvgConform::Profile.load_from_file(metanorma_sample_profile_path) }
73
78
  let(:validator) { SvgConform::Validator.new(mode: :sax) }
74
79
 
75
80
  def svg_with_clip_assets(inner)
@@ -107,4 +112,55 @@ RSpec.describe "Metanorma Profile" do
107
112
  end
108
113
  end
109
114
  end
115
+
116
+ def shape_geometry(tag)
117
+ case tag
118
+ when "path" then 'd="M2,6 H38"'
119
+ when "line" then 'x1="2" y1="6" x2="38" y2="6"'
120
+ else 'points="2,6 20,6 38,6"'
121
+ end
122
+ end
123
+
124
+ def marker_svg(shape_attrs)
125
+ <<~SVG
126
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="40" height="12" viewBox="0 0 40 12">
127
+ <defs>
128
+ <marker id="a" markerWidth="4" markerHeight="4" refX="2" refY="2" orient="auto">
129
+ <path d="M0,0 L4,2 L0,4"/>
130
+ </marker>
131
+ </defs>
132
+ <g>#{shape_attrs}</g>
133
+ </svg>
134
+ SVG
135
+ end
136
+
137
+ # claricle/svg_conform#128: the profile listed the marker element but
138
+ # none of the marker presentation attributes on the shapes, so
139
+ # marker-end="url(...)" failed while the same marker in a style
140
+ # attribute passed.
141
+ %w[path line polyline polygon].each do |tag|
142
+ it "allows marker-end on #{tag}" do
143
+ svg = marker_svg(
144
+ %(<#{tag} #{shape_geometry(tag)} marker-end="url(#a)"/>),
145
+ )
146
+ result = validator.validate(svg, profile: profile)
147
+ attribute_errors = result.errors.select { |e| e.message.include?("marker-end") }
148
+ expect(attribute_errors).to be_empty
149
+ end
150
+
151
+ it "allows marker-start and marker-mid on #{tag}" do
152
+ svg = marker_svg(
153
+ %(<#{tag} #{shape_geometry(tag)} marker-start="url(#a)" marker-mid="url(#a)" marker-end="url(#a)"/>),
154
+ )
155
+ result = validator.validate(svg, profile: profile)
156
+ attribute_errors = result.errors.select { |e| e.message.include?("marker") }
157
+ expect(attribute_errors).to be_empty
158
+ end
159
+ end
160
+
161
+ it "still rejects marker attributes on rect, where SVG does not define them" do
162
+ svg = marker_svg(%(<rect x="2" y="2" width="36" height="8" marker-end="url(#a)"/>))
163
+ result = validator.validate(svg, profile: profile)
164
+ expect(result.errors.map(&:message).join).to include("marker-end")
165
+ end
110
166
  end
@@ -5,7 +5,7 @@ require "nokogiri"
5
5
 
6
6
  RSpec.describe SvgConform::Profiles do
7
7
  let(:validator) { SvgConform::Validator.new(mode: :sax) }
8
- let(:profile) { described_class.get(:metanorma) }
8
+ let(:profile) { described_class.get(:"metanorma-sample") }
9
9
  let(:plantuml_attributes) { %w[contentstyletype zoomandpan title textlength lengthadjust] }
10
10
  let(:svg) do
11
11
  <<~SVG
@@ -3,7 +3,7 @@
3
3
  require "spec_helper"
4
4
 
5
5
  RSpec.describe "Reference Manifest Integration" do
6
- let(:validator) { SvgConform::Validator.new(profile: "metanorma") }
6
+ let(:validator) { SvgConform::Validator.new(profile: "metanorma-sample") }
7
7
 
8
8
  describe "complete reference manifest generation" do
9
9
  let(:svg_content) do
@@ -30,7 +30,7 @@ RSpec.describe "IdReferenceRequirement" do
30
30
 
31
31
  it "does not leak state from first validation to second validation" do
32
32
  # First validation: SVG with reference error
33
- result1 = validator.validate(svg_with_error, profile: :metanorma)
33
+ result1 = validator.validate(svg_with_error, profile: :"metanorma-sample")
34
34
 
35
35
  # Verify first validation caught the error
36
36
  expect(result1.errors.map(&:message)).to include(
@@ -38,7 +38,7 @@ RSpec.describe "IdReferenceRequirement" do
38
38
  )
39
39
 
40
40
  # Second validation: SVG without reference errors
41
- result2 = validator.validate(svg_without_error, profile: :metanorma)
41
+ result2 = validator.validate(svg_without_error, profile: :"metanorma-sample")
42
42
 
43
43
  # Verify second validation does NOT report errors from first validation
44
44
  error_messages = result2.errors.map(&:message).join("\n")
@@ -59,8 +59,8 @@ RSpec.describe "IdReferenceRequirement" do
59
59
 
60
60
  # Alternate between error and no-error SVGs
61
61
  3.times do
62
- results << validator.validate(svg_with_error, profile: :metanorma)
63
- results << validator.validate(svg_without_error, profile: :metanorma)
62
+ results << validator.validate(svg_with_error, profile: :"metanorma-sample")
63
+ results << validator.validate(svg_without_error, profile: :"metanorma-sample")
64
64
  end
65
65
 
66
66
  # Check that error pattern is consistent
@@ -80,7 +80,7 @@ RSpec.describe "IdReferenceRequirement" do
80
80
 
81
81
  it "resets state when using the same profile instance" do
82
82
  # Get profile instance
83
- profile = SvgConform::Profiles.get(:metanorma)
83
+ profile = SvgConform::Profiles.get(:"metanorma-sample")
84
84
 
85
85
  # Run two validations using the same profile
86
86
  validator.validate(svg_with_error, profile: profile)