postsvg 0.1.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +105 -0
- data/CLAUDE.md +173 -0
- data/Gemfile +2 -3
- data/README.adoc +456 -179
- data/Rakefile +100 -0
- data/TODO.roadmap/00-architecture.md +139 -0
- data/TODO.roadmap/01-autoload-migration.md +39 -0
- data/TODO.roadmap/02-isolate-dormant-code.md +51 -0
- data/TODO.roadmap/03-domain-model.md +66 -0
- data/TODO.roadmap/04-lexer.md +40 -0
- data/TODO.roadmap/05-parser.md +43 -0
- data/TODO.roadmap/06-graphics-state.md +45 -0
- data/TODO.roadmap/07-matrix-and-color.md +37 -0
- data/TODO.roadmap/08-svg-builder.md +51 -0
- data/TODO.roadmap/09-renderer.md +52 -0
- data/TODO.roadmap/10-visitor.md +58 -0
- data/TODO.roadmap/11-operator-coverage.md +103 -0
- data/TODO.roadmap/12-svg-domain.md +62 -0
- data/TODO.roadmap/13-translation-handlers.md +69 -0
- data/TODO.roadmap/14-ps-serializer.md +49 -0
- data/TODO.roadmap/15-cli-and-public-api.md +47 -0
- data/TODO.roadmap/16-specs.md +84 -0
- data/TODO.roadmap/17-docs-sync.md +47 -0
- data/TODO.roadmap/18-performance-and-determinism.md +47 -0
- data/TODO.roadmap/19-error-model.md +45 -0
- data/TODO.roadmap/20-font-and-text.md +46 -0
- data/TODO.roadmap/21-images.md +45 -0
- data/TODO.roadmap/22-forms-and-resources.md +25 -0
- data/TODO.roadmap/23-level2-level3.md +52 -0
- data/TODO.roadmap/24-ci-and-release.md +42 -0
- data/TODO.roadmap/README.md +77 -0
- data/docs/.gitignore +29 -0
- data/docs/CHANGELOG.md +114 -0
- data/docs/COMPLETE_DOCUMENTATION_STATUS.md +376 -0
- data/docs/DEPLOYMENT.md +456 -0
- data/docs/DEPLOYMENT_INSTRUCTIONS.md +229 -0
- data/docs/DOCUMENTATION_PLAN.md +425 -0
- data/docs/FINAL_SUMMARY.md +657 -0
- data/docs/Gemfile +15 -0
- data/docs/README.md +327 -0
- data/docs/_config.yml +99 -0
- data/docs/advanced-topics.adoc +370 -0
- data/docs/api-reference/colors.adoc +705 -0
- data/docs/api-reference/converter.adoc +699 -0
- data/docs/api-reference/execution-context.adoc +1210 -0
- data/docs/api-reference/graphics-state.adoc +1070 -0
- data/docs/api-reference/interpreter.adoc +810 -0
- data/docs/api-reference/matrix.adoc +1179 -0
- data/docs/api-reference/path-builder.adoc +1284 -0
- data/docs/api-reference/postsvg-module.adoc +388 -0
- data/docs/api-reference/svg-generator.adoc +891 -0
- data/docs/api-reference/tokenizer.adoc +925 -0
- data/docs/api-reference.adoc +221 -0
- data/docs/architecture/command-registry.adoc +1191 -0
- data/docs/architecture/conversion-pipeline.adoc +746 -0
- data/docs/architecture/design-decisions.adoc +999 -0
- data/docs/architecture/generator-stage.adoc +1115 -0
- data/docs/architecture/graphics-state-model.adoc +1089 -0
- data/docs/architecture/interpreter-stage.adoc +1125 -0
- data/docs/architecture/parser-stage.adoc +1051 -0
- data/docs/architecture.adoc +354 -0
- data/docs/cli-reference/batch-command.adoc +616 -0
- data/docs/cli-reference/check-command.adoc +677 -0
- data/docs/cli-reference/cli-options.adoc +802 -0
- data/docs/cli-reference/convert-command.adoc +462 -0
- data/docs/cli-reference/version-command.adoc +296 -0
- data/docs/cli-reference.adoc +317 -0
- data/docs/concepts/conversion-pipeline.adoc +903 -0
- data/docs/concepts/coordinate-systems.adoc +836 -0
- data/docs/concepts/graphics-state.adoc +861 -0
- data/docs/concepts/path-operations.adoc +1076 -0
- data/docs/concepts/postscript-language.adoc +859 -0
- data/docs/concepts/svg-generation.adoc +937 -0
- data/docs/concepts.adoc +198 -0
- data/docs/contributing.adoc +443 -0
- data/docs/development.adoc +420 -0
- data/docs/faq.adoc +493 -0
- data/docs/getting-started/basic-usage.adoc +538 -0
- data/docs/getting-started/common-workflows.adoc +577 -0
- data/docs/getting-started/first-conversion.adoc +492 -0
- data/docs/getting-started/installation.adoc +534 -0
- data/docs/getting-started.adoc +94 -0
- data/docs/index.adoc +248 -0
- data/docs/optimization.adoc +196 -0
- data/docs/ps2svg_compatibility.adoc +149 -0
- data/docs/quick-reference.adoc +453 -0
- data/docs/sitemap.adoc +337 -0
- data/docs/troubleshooting.adoc +486 -0
- data/docs/validation.adoc +772 -0
- data/exe/postsvg +1 -0
- data/lib/postsvg/cli.rb +104 -57
- data/lib/postsvg/color.rb +132 -0
- data/lib/postsvg/errors.rb +68 -3
- data/lib/postsvg/format_number.rb +22 -0
- data/lib/postsvg/graphics_context.rb +80 -0
- data/lib/postsvg/graphics_stack.rb +43 -0
- data/lib/postsvg/model/literals/array.rb +41 -0
- data/lib/postsvg/model/literals/dictionary.rb +34 -0
- data/lib/postsvg/model/literals/hex.rb +37 -0
- data/lib/postsvg/model/literals/name.rb +40 -0
- data/lib/postsvg/model/literals/number.rb +36 -0
- data/lib/postsvg/model/literals/procedure.rb +41 -0
- data/lib/postsvg/model/literals/string.rb +30 -0
- data/lib/postsvg/model/literals.rb +19 -0
- data/lib/postsvg/model/operator.rb +58 -0
- data/lib/postsvg/model/operators/arithmetic.rb +264 -0
- data/lib/postsvg/model/operators/boolean.rb +182 -0
- data/lib/postsvg/model/operators/color.rb +74 -0
- data/lib/postsvg/model/operators/container.rb +186 -0
- data/lib/postsvg/model/operators/control_flow.rb +119 -0
- data/lib/postsvg/model/operators/device.rb +21 -0
- data/lib/postsvg/model/operators/dictionary.rb +118 -0
- data/lib/postsvg/model/operators/font.rb +121 -0
- data/lib/postsvg/model/operators/graphics_state.rb +84 -0
- data/lib/postsvg/model/operators/painting.rb +29 -0
- data/lib/postsvg/model/operators/path.rb +169 -0
- data/lib/postsvg/model/operators/stack.rb +72 -0
- data/lib/postsvg/model/operators/transformations.rb +103 -0
- data/lib/postsvg/model/operators.rb +89 -0
- data/lib/postsvg/model/program.rb +68 -0
- data/lib/postsvg/model/token.rb +43 -0
- data/lib/postsvg/model.rb +17 -0
- data/lib/postsvg/options.rb +29 -0
- data/lib/postsvg/renderer.rb +85 -0
- data/lib/postsvg/serializer.rb +325 -0
- data/lib/postsvg/source/ast_builder.rb +308 -0
- data/lib/postsvg/source/lexer.rb +322 -0
- data/lib/postsvg/source/operand_stack.rb +55 -0
- data/lib/postsvg/source.rb +21 -0
- data/lib/postsvg/svg/attribute_parser.rb +45 -0
- data/lib/postsvg/svg/clip_path_registry.rb +44 -0
- data/lib/postsvg/svg/document.rb +22 -0
- data/lib/postsvg/svg/element.rb +84 -0
- data/lib/postsvg/svg/elements/circle.rb +36 -0
- data/lib/postsvg/svg/elements/clip_path.rb +26 -0
- data/lib/postsvg/svg/elements/defs.rb +24 -0
- data/lib/postsvg/svg/elements/ellipse.rb +38 -0
- data/lib/postsvg/svg/elements/group.rb +37 -0
- data/lib/postsvg/svg/elements/image.rb +35 -0
- data/lib/postsvg/svg/elements/line.rb +36 -0
- data/lib/postsvg/svg/elements/path.rb +32 -0
- data/lib/postsvg/svg/elements/polygon.rb +12 -0
- data/lib/postsvg/svg/elements/polyline.rb +32 -0
- data/lib/postsvg/svg/elements/rect.rb +44 -0
- data/lib/postsvg/svg/elements/svg.rb +39 -0
- data/lib/postsvg/svg/elements/text.rb +42 -0
- data/lib/postsvg/svg/elements.rb +31 -0
- data/lib/postsvg/svg/paint.rb +34 -0
- data/lib/postsvg/svg/parser.rb +39 -0
- data/lib/postsvg/svg/path_data/command.rb +27 -0
- data/lib/postsvg/svg/path_data/parser.rb +82 -0
- data/lib/postsvg/svg/path_data.rb +17 -0
- data/lib/postsvg/svg/stroke.rb +31 -0
- data/lib/postsvg/svg/transform_list.rb +59 -0
- data/lib/postsvg/svg.rb +22 -0
- data/lib/postsvg/svg_builder.rb +249 -0
- data/lib/postsvg/translation/arc_converter.rb +86 -0
- data/lib/postsvg/translation/bounding_box.rb +59 -0
- data/lib/postsvg/translation/context.rb +34 -0
- data/lib/postsvg/translation/handler_registry.rb +38 -0
- data/lib/postsvg/translation/handlers/circle_handler.rb +28 -0
- data/lib/postsvg/translation/handlers/clip_path_handler.rb +13 -0
- data/lib/postsvg/translation/handlers/defs_handler.rb +15 -0
- data/lib/postsvg/translation/handlers/ellipse_handler.rb +31 -0
- data/lib/postsvg/translation/handlers/group_handler.rb +21 -0
- data/lib/postsvg/translation/handlers/image_handler.rb +20 -0
- data/lib/postsvg/translation/handlers/line_handler.rb +23 -0
- data/lib/postsvg/translation/handlers/open_handler.rb +18 -0
- data/lib/postsvg/translation/handlers/path_handler.rb +356 -0
- data/lib/postsvg/translation/handlers/polygon_handler.rb +33 -0
- data/lib/postsvg/translation/handlers/polyline_handler.rb +31 -0
- data/lib/postsvg/translation/handlers/rect_handler.rb +27 -0
- data/lib/postsvg/translation/handlers/shared.rb +110 -0
- data/lib/postsvg/translation/handlers/svg_handler.rb +25 -0
- data/lib/postsvg/translation/handlers/text_handler.rb +56 -0
- data/lib/postsvg/translation/handlers.rb +25 -0
- data/lib/postsvg/translation/ps_renderer.rb +105 -0
- data/lib/postsvg/translation/record_emitter.rb +35 -0
- data/lib/postsvg/translation.rb +17 -0
- data/lib/postsvg/version.rb +1 -1
- data/lib/postsvg/visitors/ps_visitor/arithmetic.rb +125 -0
- data/lib/postsvg/visitors/ps_visitor/boolean.rb +105 -0
- data/lib/postsvg/visitors/ps_visitor/color.rb +53 -0
- data/lib/postsvg/visitors/ps_visitor/common.rb +66 -0
- data/lib/postsvg/visitors/ps_visitor/container.rb +164 -0
- data/lib/postsvg/visitors/ps_visitor/control_flow.rb +110 -0
- data/lib/postsvg/visitors/ps_visitor/device.rb +20 -0
- data/lib/postsvg/visitors/ps_visitor/dictionary.rb +89 -0
- data/lib/postsvg/visitors/ps_visitor/font.rb +93 -0
- data/lib/postsvg/visitors/ps_visitor/graphics_state.rb +55 -0
- data/lib/postsvg/visitors/ps_visitor/painting.rb +90 -0
- data/lib/postsvg/visitors/ps_visitor/path.rb +112 -0
- data/lib/postsvg/visitors/ps_visitor/stack.rb +47 -0
- data/lib/postsvg/visitors/ps_visitor/transformations.rb +101 -0
- data/lib/postsvg/visitors/ps_visitor.rb +208 -0
- data/lib/postsvg/visitors.rb +9 -0
- data/lib/postsvg.rb +93 -59
- data/lychee.toml +86 -0
- metadata +216 -11
- data/postsvg.gemspec +0 -38
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
= check Command
|
|
2
|
+
:page-nav_order: 3
|
|
3
|
+
:page-parent: CLI Reference
|
|
4
|
+
|
|
5
|
+
== Purpose
|
|
6
|
+
|
|
7
|
+
The `check` command validates PostScript and EPS files for syntax errors, semantic issues, and conversion compatibility. It's essential for quality assurance and CI/CD pipelines.
|
|
8
|
+
|
|
9
|
+
== References
|
|
10
|
+
|
|
11
|
+
* link:../index.adoc[Documentation Home]
|
|
12
|
+
* link:../cli-reference.adoc[CLI Reference Overview]
|
|
13
|
+
* link:convert-command.adoc[convert Command]
|
|
14
|
+
* link:batch-command.adoc[batch Command]
|
|
15
|
+
* link:../validation.adoc[Validation System]
|
|
16
|
+
|
|
17
|
+
== Concepts
|
|
18
|
+
|
|
19
|
+
**Validation**:: The process of checking PostScript files for errors without performing actual conversion.
|
|
20
|
+
|
|
21
|
+
**Validation Levels**:: Different degrees of checking: syntax (fast), semantic (thorough), full (complete).
|
|
22
|
+
|
|
23
|
+
**Output Formats**:: Different report formats: text (human), yaml (structured), json (programmatic).
|
|
24
|
+
|
|
25
|
+
**Fail-Fast**:: Stopping validation at the first error instead of checking all files.
|
|
26
|
+
|
|
27
|
+
== Command Syntax
|
|
28
|
+
|
|
29
|
+
[source,sh]
|
|
30
|
+
----
|
|
31
|
+
postsvg check [OPTIONS] FILE... <1>
|
|
32
|
+
----
|
|
33
|
+
<1> Validate one or more PostScript or EPS files
|
|
34
|
+
|
|
35
|
+
**Where:**
|
|
36
|
+
|
|
37
|
+
`FILE...`:: One or more PostScript (`.ps`) or EPS (`.eps`) files to validate
|
|
38
|
+
|
|
39
|
+
**Options:**
|
|
40
|
+
|
|
41
|
+
`-l, --level LEVEL`:: Validation level: `syntax`, `semantic`, `full` (default: `semantic`)
|
|
42
|
+
|
|
43
|
+
`-f, --format FORMAT`:: Output format: `text`, `yaml`, `json` (default: `text`)
|
|
44
|
+
|
|
45
|
+
`-v, --verbose`:: Print detailed information including warnings
|
|
46
|
+
|
|
47
|
+
`-q, --quiet`:: Only output errors (suppress success messages)
|
|
48
|
+
|
|
49
|
+
`--no-color`:: Disable colored output
|
|
50
|
+
|
|
51
|
+
`--fail-fast`:: Stop at first error instead of checking all files
|
|
52
|
+
|
|
53
|
+
`--eps-version VERSION`:: Validate against specific EPS version (`1.0`, `2.0`, `3.0`)
|
|
54
|
+
|
|
55
|
+
**Exit Codes:**
|
|
56
|
+
* `0` - All files valid
|
|
57
|
+
* `1` - One or more files have errors
|
|
58
|
+
|
|
59
|
+
**Source:**
|
|
60
|
+
[`lib/postsvg/cli.rb:109-143`](../../lib/postsvg/cli.rb:109)
|
|
61
|
+
|
|
62
|
+
== Validation Levels
|
|
63
|
+
|
|
64
|
+
=== syntax
|
|
65
|
+
|
|
66
|
+
Fast structural validation checking only basic file structure.
|
|
67
|
+
|
|
68
|
+
[source,sh]
|
|
69
|
+
----
|
|
70
|
+
postsvg check --level=syntax FILE <1>
|
|
71
|
+
----
|
|
72
|
+
<1> Syntax-only validation (fastest)
|
|
73
|
+
|
|
74
|
+
**Checks:**
|
|
75
|
+
* PostScript header present (`%!PS` or `%!<`)
|
|
76
|
+
* Delimiter matching (brackets, braces, parentheses)
|
|
77
|
+
* Basic tokenization validity
|
|
78
|
+
* Comment syntax
|
|
79
|
+
|
|
80
|
+
**Skips:**
|
|
81
|
+
* Stack simulation
|
|
82
|
+
* Graphics state tracking
|
|
83
|
+
* Full conversion attempt
|
|
84
|
+
|
|
85
|
+
**Speed:** ~10-50ms per file
|
|
86
|
+
|
|
87
|
+
.Syntax validation example
|
|
88
|
+
[example]
|
|
89
|
+
====
|
|
90
|
+
[source,sh]
|
|
91
|
+
----
|
|
92
|
+
$ postsvg check --level=syntax document.ps
|
|
93
|
+
✓ document.ps - Valid PostScript file
|
|
94
|
+
File type: PostScript
|
|
95
|
+
Validation level: syntax
|
|
96
|
+
No errors found
|
|
97
|
+
----
|
|
98
|
+
|
|
99
|
+
Use for quick structural checks in development.
|
|
100
|
+
====
|
|
101
|
+
|
|
102
|
+
=== semantic (default)
|
|
103
|
+
|
|
104
|
+
Thorough validation including stack and state checking.
|
|
105
|
+
|
|
106
|
+
[source,sh]
|
|
107
|
+
----
|
|
108
|
+
postsvg check --level=semantic FILE <1>
|
|
109
|
+
postsvg check FILE <2>
|
|
110
|
+
----
|
|
111
|
+
<1> Explicit semantic validation
|
|
112
|
+
<2> Default validation level
|
|
113
|
+
|
|
114
|
+
**Checks:**
|
|
115
|
+
* All syntax checks
|
|
116
|
+
* Stack balance verification
|
|
117
|
+
* Graphics state tracking
|
|
118
|
+
* Dictionary operations
|
|
119
|
+
* Operator argument validation
|
|
120
|
+
|
|
121
|
+
**Skips:**
|
|
122
|
+
* Full SVG generation
|
|
123
|
+
|
|
124
|
+
**Speed:** ~50-200ms per file
|
|
125
|
+
|
|
126
|
+
.Semantic validation example
|
|
127
|
+
[example]
|
|
128
|
+
====
|
|
129
|
+
[source,sh]
|
|
130
|
+
----
|
|
131
|
+
$ postsvg check document.ps
|
|
132
|
+
✓ document.ps - Valid PostScript file
|
|
133
|
+
File type: EPS
|
|
134
|
+
Validation level: semantic
|
|
135
|
+
BoundingBox: 0 0 612 792
|
|
136
|
+
No errors found
|
|
137
|
+
----
|
|
138
|
+
|
|
139
|
+
This is the recommended level for regular validation.
|
|
140
|
+
====
|
|
141
|
+
|
|
142
|
+
=== full
|
|
143
|
+
|
|
144
|
+
Complete validation with full conversion attempt.
|
|
145
|
+
|
|
146
|
+
[source,sh]
|
|
147
|
+
----
|
|
148
|
+
postsvg check --level=full FILE <1>
|
|
149
|
+
----
|
|
150
|
+
<1> Full validation (strictest, slowest)
|
|
151
|
+
|
|
152
|
+
**Checks:**
|
|
153
|
+
* All syntax checks
|
|
154
|
+
* All semantic checks
|
|
155
|
+
* Complete conversion to SVG
|
|
156
|
+
* SVG generation validity
|
|
157
|
+
* Output verification
|
|
158
|
+
|
|
159
|
+
**Speed:** ~100-500ms per file (depends on complexity)
|
|
160
|
+
|
|
161
|
+
.Full validation example
|
|
162
|
+
[example]
|
|
163
|
+
====
|
|
164
|
+
[source,sh]
|
|
165
|
+
----
|
|
166
|
+
$ postsvg check --level=full complex.ps
|
|
167
|
+
✓ complex.ps - Valid PostScript file
|
|
168
|
+
File type: PostScript
|
|
169
|
+
Validation level: full
|
|
170
|
+
BoundingBox: 0 0 800 600
|
|
171
|
+
Paths generated: 15
|
|
172
|
+
No errors found
|
|
173
|
+
----
|
|
174
|
+
|
|
175
|
+
Use for production readiness checks and thorough quality assurance.
|
|
176
|
+
====
|
|
177
|
+
|
|
178
|
+
== Output Formats
|
|
179
|
+
|
|
180
|
+
=== text (default)
|
|
181
|
+
|
|
182
|
+
Human-readable colored console output.
|
|
183
|
+
|
|
184
|
+
[source,sh]
|
|
185
|
+
----
|
|
186
|
+
postsvg check --format=text FILE <1>
|
|
187
|
+
postsvg check FILE <2>
|
|
188
|
+
----
|
|
189
|
+
<1> Explicit text format
|
|
190
|
+
<2> Default output format
|
|
191
|
+
|
|
192
|
+
**Features:**
|
|
193
|
+
* ✓/✗ symbols for status
|
|
194
|
+
* Color-coded messages (green=success, red=error, yellow=warning)
|
|
195
|
+
* Human-readable formatting
|
|
196
|
+
* Detailed error descriptions
|
|
197
|
+
|
|
198
|
+
.Text output example
|
|
199
|
+
[example]
|
|
200
|
+
====
|
|
201
|
+
[source,sh]
|
|
202
|
+
----
|
|
203
|
+
$ postsvg check file1.ps file2.ps broken.ps
|
|
204
|
+
✓ file1.ps - Valid PostScript file
|
|
205
|
+
File type: EPS
|
|
206
|
+
No errors found
|
|
207
|
+
|
|
208
|
+
✓ file2.ps - Valid PostScript file
|
|
209
|
+
File type: PostScript
|
|
210
|
+
No errors found
|
|
211
|
+
|
|
212
|
+
✗ broken.ps - Semantic error
|
|
213
|
+
File type: PostScript
|
|
214
|
+
Errors:
|
|
215
|
+
- Stack underflow at operator 'moveto' (line ~15)
|
|
216
|
+
- Unmatched delimiter '}' (line ~23)
|
|
217
|
+
----
|
|
218
|
+
====
|
|
219
|
+
|
|
220
|
+
=== yaml
|
|
221
|
+
|
|
222
|
+
Structured YAML output for programmatic processing.
|
|
223
|
+
|
|
224
|
+
[source,sh]
|
|
225
|
+
----
|
|
226
|
+
postsvg check --format=yaml FILE <1>
|
|
227
|
+
----
|
|
228
|
+
<1> YAML structured output
|
|
229
|
+
|
|
230
|
+
.YAML output example
|
|
231
|
+
[example]
|
|
232
|
+
====
|
|
233
|
+
[source,sh]
|
|
234
|
+
----
|
|
235
|
+
$ postsvg check --format=yaml document.ps
|
|
236
|
+
---
|
|
237
|
+
filename: document.ps
|
|
238
|
+
valid: true
|
|
239
|
+
file_type: EPS
|
|
240
|
+
validation_level: semantic
|
|
241
|
+
bounding_box:
|
|
242
|
+
llx: 0
|
|
243
|
+
lly: 0
|
|
244
|
+
urx: 612
|
|
245
|
+
ury: 792
|
|
246
|
+
errors: []
|
|
247
|
+
warnings: []
|
|
248
|
+
info:
|
|
249
|
+
- BoundingBox present
|
|
250
|
+
- 5 paths found
|
|
251
|
+
----
|
|
252
|
+
====
|
|
253
|
+
|
|
254
|
+
=== json
|
|
255
|
+
|
|
256
|
+
JSON output ideal for CI/CD integration.
|
|
257
|
+
|
|
258
|
+
[source,sh]
|
|
259
|
+
----
|
|
260
|
+
postsvg check --format=json FILE <1>
|
|
261
|
+
----
|
|
262
|
+
<1> JSON structured output
|
|
263
|
+
|
|
264
|
+
.JSON output example
|
|
265
|
+
[example]
|
|
266
|
+
====
|
|
267
|
+
[source,sh]
|
|
268
|
+
----
|
|
269
|
+
$ postsvg check --format=json --no-color document.ps
|
|
270
|
+
{
|
|
271
|
+
"filename": "document.ps",
|
|
272
|
+
"valid": true,
|
|
273
|
+
"file_type": "EPS",
|
|
274
|
+
"validation_level": "semantic",
|
|
275
|
+
"bounding_box": {
|
|
276
|
+
"llx": 0,
|
|
277
|
+
"lly": 0,
|
|
278
|
+
"urx": 612,
|
|
279
|
+
"ury": 792
|
|
280
|
+
},
|
|
281
|
+
"errors": [],
|
|
282
|
+
"warnings": [],
|
|
283
|
+
"info": ["BoundingBox present", "5 paths found"]
|
|
284
|
+
}
|
|
285
|
+
----
|
|
286
|
+
|
|
287
|
+
Perfect for parsing in scripts or CI/CD pipelines.
|
|
288
|
+
====
|
|
289
|
+
|
|
290
|
+
## Validation Options
|
|
291
|
+
|
|
292
|
+
=== --verbose
|
|
293
|
+
|
|
294
|
+
Show warnings and info messages in addition to errors.
|
|
295
|
+
|
|
296
|
+
[source,sh]
|
|
297
|
+
----
|
|
298
|
+
postsvg check --verbose FILE <1>
|
|
299
|
+
----
|
|
300
|
+
<1> Include warnings and informational messages
|
|
301
|
+
|
|
302
|
+
.Verbose output
|
|
303
|
+
[example]
|
|
304
|
+
====
|
|
305
|
+
[source,sh]
|
|
306
|
+
----
|
|
307
|
+
$ postsvg check --verbose document.ps
|
|
308
|
+
✓ document.ps - Valid PostScript file
|
|
309
|
+
File type: EPS
|
|
310
|
+
BoundingBox: 0 0 612 792
|
|
311
|
+
Info:
|
|
312
|
+
- PostScript version: 3.0
|
|
313
|
+
- Total operators: 127
|
|
314
|
+
- Path commands: 45
|
|
315
|
+
- Graphics state operations: 12
|
|
316
|
+
Warnings:
|
|
317
|
+
- Consider using explicit line cap settings
|
|
318
|
+
No errors found
|
|
319
|
+
----
|
|
320
|
+
====
|
|
321
|
+
|
|
322
|
+
=== --quiet
|
|
323
|
+
|
|
324
|
+
Suppress output for valid files, only show errors.
|
|
325
|
+
|
|
326
|
+
[source,sh]
|
|
327
|
+
----
|
|
328
|
+
postsvg check --quiet FILES... <1>
|
|
329
|
+
----
|
|
330
|
+
<1> Silent mode - only errors displayed
|
|
331
|
+
|
|
332
|
+
.Quiet mode example
|
|
333
|
+
[example]
|
|
334
|
+
====
|
|
335
|
+
[source,sh]
|
|
336
|
+
----
|
|
337
|
+
$ postsvg check --quiet good1.ps good2.ps broken.ps
|
|
338
|
+
✗ broken.ps - Syntax error: Unmatched delimiter
|
|
339
|
+
----
|
|
340
|
+
|
|
341
|
+
Good files produce no output. Only errors are shown.
|
|
342
|
+
====
|
|
343
|
+
|
|
344
|
+
=== --no-color
|
|
345
|
+
|
|
346
|
+
Disable colored output (useful for CI/CD logs).
|
|
347
|
+
|
|
348
|
+
[source,sh]
|
|
349
|
+
----
|
|
350
|
+
postsvg check --no-color FILE <1>
|
|
351
|
+
----
|
|
352
|
+
<1> Plain text without ANSI color codes
|
|
353
|
+
|
|
354
|
+
.No-color output
|
|
355
|
+
[example]
|
|
356
|
+
====
|
|
357
|
+
[source,sh]
|
|
358
|
+
----
|
|
359
|
+
$ postsvg check --no-color document.ps
|
|
360
|
+
✓ document.ps - Valid PostScript file
|
|
361
|
+
File type: PostScript
|
|
362
|
+
No errors found
|
|
363
|
+
----
|
|
364
|
+
|
|
365
|
+
Same content as colored output, but without color codes. Essential for log files and CI/CD systems.
|
|
366
|
+
====
|
|
367
|
+
|
|
368
|
+
=== --fail-fast
|
|
369
|
+
|
|
370
|
+
Stop validation at the first error encountered.
|
|
371
|
+
|
|
372
|
+
[source,sh]
|
|
373
|
+
----
|
|
374
|
+
postsvg check --fail-fast FILES... <1>
|
|
375
|
+
----
|
|
376
|
+
<1> Exit immediately on first error
|
|
377
|
+
|
|
378
|
+
.Fail-fast example
|
|
379
|
+
[example]
|
|
380
|
+
====
|
|
381
|
+
[source,sh]
|
|
382
|
+
----
|
|
383
|
+
# Without fail-fast (checks all files)
|
|
384
|
+
$ postsvg check file1.ps file2.ps file3.ps
|
|
385
|
+
✓ file1.ps - Valid
|
|
386
|
+
✗ file2.ps - Error
|
|
387
|
+
✓ file3.ps - Valid
|
|
388
|
+
|
|
389
|
+
# With fail-fast (stops at first error)
|
|
390
|
+
$ postsvg check --fail-fast file1.ps file2.ps file3.ps
|
|
391
|
+
✓ file1.ps - Valid
|
|
392
|
+
✗ file2.ps - Error
|
|
393
|
+
# file3.ps not checked
|
|
394
|
+
----
|
|
395
|
+
|
|
396
|
+
Useful for rapid feedback in development.
|
|
397
|
+
====
|
|
398
|
+
|
|
399
|
+
=== --eps-version
|
|
400
|
+
|
|
401
|
+
Validate EPS version compliance.
|
|
402
|
+
|
|
403
|
+
[source,sh]
|
|
404
|
+
----
|
|
405
|
+
postsvg check --eps-version=VERSION FILE <1>
|
|
406
|
+
----
|
|
407
|
+
<1> Validate against specific EPS version
|
|
408
|
+
|
|
409
|
+
**Supported Versions:**
|
|
410
|
+
* `1.0` - EPS version 1.0
|
|
411
|
+
* `2.0` - EPS version 2.0
|
|
412
|
+
* `3.0` - EPS version 3.0
|
|
413
|
+
|
|
414
|
+
.EPS version validation
|
|
415
|
+
[example]
|
|
416
|
+
====
|
|
417
|
+
[source,sh]
|
|
418
|
+
----
|
|
419
|
+
$ postsvg check --eps-version=3.0 diagram.eps
|
|
420
|
+
✓ diagram.eps - Valid EPS 3.0 file
|
|
421
|
+
EPS version: 3.0
|
|
422
|
+
Compliant with specification
|
|
423
|
+
No errors found
|
|
424
|
+
|
|
425
|
+
$ postsvg check --eps-version=3.0 old.eps
|
|
426
|
+
✗ old.eps - EPS version mismatch
|
|
427
|
+
Expected: 3.0
|
|
428
|
+
Found: 1.0
|
|
429
|
+
Consider upgrading or use correct version flag
|
|
430
|
+
----
|
|
431
|
+
====
|
|
432
|
+
|
|
433
|
+
## Multiple File Validation
|
|
434
|
+
|
|
435
|
+
=== Validate All Files in Directory
|
|
436
|
+
|
|
437
|
+
[source,sh]
|
|
438
|
+
----
|
|
439
|
+
postsvg check *.ps *.eps <1>
|
|
440
|
+
postsvg check documents/*.ps <2>
|
|
441
|
+
----
|
|
442
|
+
<1> Check all PS and EPS files in current directory
|
|
443
|
+
<2> Check all PS files in documents subdirectory
|
|
444
|
+
|
|
445
|
+
.Multiple file validation
|
|
446
|
+
[example]
|
|
447
|
+
====
|
|
448
|
+
[source,sh]
|
|
449
|
+
----
|
|
450
|
+
$ postsvg check *.ps
|
|
451
|
+
✓ diagram1.ps - Valid PostScript file
|
|
452
|
+
✓ diagram2.ps - Valid PostScript file
|
|
453
|
+
✗ broken.ps - Syntax error: Unmatched delimiter
|
|
454
|
+
✓ figure.ps - Valid PostScript file
|
|
455
|
+
|
|
456
|
+
# Exit code: 1 (because one file failed)
|
|
457
|
+
----
|
|
458
|
+
====
|
|
459
|
+
|
|
460
|
+
### Check with Different Levels
|
|
461
|
+
|
|
462
|
+
[source,sh]
|
|
463
|
+
----
|
|
464
|
+
# Quick syntax check on all files
|
|
465
|
+
postsvg check --level=syntax *.ps
|
|
466
|
+
|
|
467
|
+
# Thorough check before deployment
|
|
468
|
+
postsvg check --level=full --verbose production/*.ps
|
|
469
|
+
----
|
|
470
|
+
|
|
471
|
+
## CI/CD Integration
|
|
472
|
+
|
|
473
|
+
=== GitHub Actions
|
|
474
|
+
|
|
475
|
+
[source,yaml]
|
|
476
|
+
----
|
|
477
|
+
name: Validate PostScript
|
|
478
|
+
|
|
479
|
+
on: [push, pull_request]
|
|
480
|
+
|
|
481
|
+
jobs:
|
|
482
|
+
validate:
|
|
483
|
+
runs-on: ubuntu-latest
|
|
484
|
+
steps:
|
|
485
|
+
- uses: actions/checkout@v3
|
|
486
|
+
|
|
487
|
+
- name: Setup Ruby
|
|
488
|
+
uses: ruby/setup-ruby@v1
|
|
489
|
+
with:
|
|
490
|
+
ruby-version: '3.2'
|
|
491
|
+
|
|
492
|
+
- name: Install Postsvg
|
|
493
|
+
run: gem install postsvg
|
|
494
|
+
|
|
495
|
+
- name: Validate PS files
|
|
496
|
+
run: |
|
|
497
|
+
postsvg check --format=json --no-color \
|
|
498
|
+
--level=full --fail-fast \
|
|
499
|
+
$(find . -name "*.ps" -o -name "*.eps")
|
|
500
|
+
----
|
|
501
|
+
|
|
502
|
+
=== GitLab CI
|
|
503
|
+
|
|
504
|
+
[source,yaml]
|
|
505
|
+
----
|
|
506
|
+
validate-postscript:
|
|
507
|
+
image: ruby:3.2
|
|
508
|
+
stage: test
|
|
509
|
+
script:
|
|
510
|
+
- gem install postsvg
|
|
511
|
+
- |
|
|
512
|
+
find . -name "*.ps" -o -name "*.eps" | \
|
|
513
|
+
xargs postsvg check --format=json --level=semantic
|
|
514
|
+
artifacts:
|
|
515
|
+
when: on_failure
|
|
516
|
+
reports:
|
|
517
|
+
junit: validation-report.json
|
|
518
|
+
----
|
|
519
|
+
|
|
520
|
+
=== Pre-commit Hook
|
|
521
|
+
|
|
522
|
+
[source,sh]
|
|
523
|
+
----
|
|
524
|
+
#!/bin/bash
|
|
525
|
+
# .git/hooks/pre-commit
|
|
526
|
+
|
|
527
|
+
# Find staged PS/EPS files
|
|
528
|
+
FILES=$(git diff --cached --name-only --diff-filter=ACM | \
|
|
529
|
+
grep -E '\.(ps|eps)$')
|
|
530
|
+
|
|
531
|
+
if [ -n "$FILES" ]; then
|
|
532
|
+
echo "Validating PostScript files..."
|
|
533
|
+
|
|
534
|
+
for file in $FILES; do
|
|
535
|
+
if ! postsvg check --quiet "$file"; then
|
|
536
|
+
echo "Validation failed for $file"
|
|
537
|
+
echo "Run: postsvg check $file"
|
|
538
|
+
exit 1
|
|
539
|
+
fi
|
|
540
|
+
done
|
|
541
|
+
|
|
542
|
+
echo "✓ All PostScript files valid"
|
|
543
|
+
fi
|
|
544
|
+
----
|
|
545
|
+
|
|
546
|
+
## Usage Patterns
|
|
547
|
+
|
|
548
|
+
=== Pattern 1: Pre-Conversion Validation
|
|
549
|
+
|
|
550
|
+
[source,sh]
|
|
551
|
+
----
|
|
552
|
+
#!/bin/bash
|
|
553
|
+
# validate-before-convert.sh
|
|
554
|
+
|
|
555
|
+
for file in *.ps; do
|
|
556
|
+
if postsvg check --level=full --quiet "$file"; then
|
|
557
|
+
postsvg convert "$file" "${file%.ps}.svg"
|
|
558
|
+
echo "✓ Converted: $file"
|
|
559
|
+
else
|
|
560
|
+
echo "✗ Skipped (invalid): $file"
|
|
561
|
+
fi
|
|
562
|
+
done
|
|
563
|
+
----
|
|
564
|
+
|
|
565
|
+
=== Pattern 2: Quality Gate
|
|
566
|
+
|
|
567
|
+
[source,sh]
|
|
568
|
+
----
|
|
569
|
+
#!/bin/bash
|
|
570
|
+
# quality-gate.sh
|
|
571
|
+
|
|
572
|
+
ERRORS=0
|
|
573
|
+
|
|
574
|
+
for file in production/*.ps; do
|
|
575
|
+
if ! postsvg check --level=full "$file"; then
|
|
576
|
+
ERRORS=$((ERRORS + 1))
|
|
577
|
+
fi
|
|
578
|
+
done
|
|
579
|
+
|
|
580
|
+
if [ $ERRORS -gt 0 ]; then
|
|
581
|
+
echo "Quality gate failed: $ERRORS file(s) with errors"
|
|
582
|
+
exit 1
|
|
583
|
+
else
|
|
584
|
+
echo "Quality gate passed: All files valid"
|
|
585
|
+
exit 0
|
|
586
|
+
fi
|
|
587
|
+
----
|
|
588
|
+
|
|
589
|
+
=== Pattern 3: Detailed Reporting
|
|
590
|
+
|
|
591
|
+
[source,sh]
|
|
592
|
+
----
|
|
593
|
+
#!/bin/bash
|
|
594
|
+
# detailed-validation.sh
|
|
595
|
+
|
|
596
|
+
REPORT="validation_report_$(date +%Y%m%d).json"
|
|
597
|
+
|
|
598
|
+
postsvg check --format=json --verbose \
|
|
599
|
+
--level=full \
|
|
600
|
+
*.ps *.eps > "$REPORT"
|
|
601
|
+
|
|
602
|
+
echo "Validation report saved to: $REPORT"
|
|
603
|
+
|
|
604
|
+
# Parse results
|
|
605
|
+
if command -v jq &> /dev/null; then
|
|
606
|
+
VALID=$(jq '[.[] | select(.valid == true)] | length' "$REPORT")
|
|
607
|
+
INVALID=$(jq '[.[] | select(.valid == false)] | length' "$REPORT")
|
|
608
|
+
|
|
609
|
+
echo "Valid files: $VALID"
|
|
610
|
+
echo "Invalid files: $INVALID"
|
|
611
|
+
fi
|
|
612
|
+
----
|
|
613
|
+
|
|
614
|
+
== Error Messages
|
|
615
|
+
|
|
616
|
+
=== Syntax Errors
|
|
617
|
+
|
|
618
|
+
[source]
|
|
619
|
+
----
|
|
620
|
+
✗ document.ps - Syntax error
|
|
621
|
+
File type: PostScript
|
|
622
|
+
Errors:
|
|
623
|
+
- Unmatched delimiter '}' (line ~45)
|
|
624
|
+
- Invalid token near line 67
|
|
625
|
+
----
|
|
626
|
+
|
|
627
|
+
**Common causes:**
|
|
628
|
+
* Missing closing delimiter
|
|
629
|
+
* Malformed strings
|
|
630
|
+
* Invalid number format
|
|
631
|
+
|
|
632
|
+
=== Semantic Errors
|
|
633
|
+
|
|
634
|
+
[source]
|
|
635
|
+
----
|
|
636
|
+
✗ document.ps - Semantic error
|
|
637
|
+
File type: PostScript
|
|
638
|
+
Errors:
|
|
639
|
+
- Stack underflow at operator 'moveto'
|
|
640
|
+
- Dictionary not found: 'customfont'
|
|
641
|
+
----
|
|
642
|
+
|
|
643
|
+
**Common causes:**
|
|
644
|
+
* Insufficient operands
|
|
645
|
+
* Undefined variables
|
|
646
|
+
* Invalid operator sequences
|
|
647
|
+
|
|
648
|
+
=== Conversion Errors
|
|
649
|
+
|
|
650
|
+
[source]
|
|
651
|
+
----
|
|
652
|
+
✗ document.ps - Conversion error
|
|
653
|
+
File type: PostScript
|
|
654
|
+
Validation level: full
|
|
655
|
+
Errors:
|
|
656
|
+
- Unknown operator: 'unsupportedop'
|
|
657
|
+
- BoundingBox missing
|
|
658
|
+
----
|
|
659
|
+
|
|
660
|
+
**Common causes:**
|
|
661
|
+
* Unsupported operators
|
|
662
|
+
* Missing required metadata
|
|
663
|
+
* Invalid PostScript constructs
|
|
664
|
+
|
|
665
|
+
## Next Steps
|
|
666
|
+
|
|
667
|
+
* Learn link:convert-command.adoc[convert command] for file conversion
|
|
668
|
+
* Review link:batch-command.adoc[batch command] for bulk processing
|
|
669
|
+
* See link:../validation.adoc[Validation System] for architecture details
|
|
670
|
+
* Check link:../getting-started/common-workflows.adoc[Common Workflows] for integration examples
|
|
671
|
+
|
|
672
|
+
== Bibliography
|
|
673
|
+
|
|
674
|
+
* link:convert-command.adoc[convert Command Documentation]
|
|
675
|
+
* link:batch-command.adoc[batch Command Documentation]
|
|
676
|
+
* link:../validation.adoc[Validation System Overview]
|
|
677
|
+
* link:../getting-started/common-workflows.adoc[Common Workflows]
|