postsvg 0.2.2 → 0.2.5
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/CLAUDE.md +3 -3
- data/Gemfile +1 -1
- data/lib/postsvg/svg/element.rb +1 -1
- data/lib/postsvg/svg/parser.rb +3 -3
- data/lib/postsvg/svg.rb +1 -1
- data/lib/postsvg/translation/record_emitter.rb +11 -0
- data/lib/postsvg/version.rb +1 -1
- data/lib/postsvg.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e16167ba04bd75b82581d7d2b134ab27e86dbfb8d6995b1cf2c90dbd066f8c77
|
|
4
|
+
data.tar.gz: 6037cc81949b6081d656e255cb69df316bdbe281693c63a557fb7594e28bd087
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a877fb8b10d634fd4099bf48722e4f22bc06fd3666d8e4a0fa94e4f47a1c6ba9ab94d4194363e8ed2a2dc4d5b1b90df4f01698f6b6da45f39bdf07ba9806c7a2
|
|
7
|
+
data.tar.gz: 387841a18917ae89771060686407b391c4ad6ad39c028411171a130c46c308f132089b7b3a258508cc4ca4ff66a534c244873d79b70d5608d10604a49b880eae
|
data/CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
`postsvg` is a pure-Ruby bidirectional converter between PostScript/EPS and SVG. Both directions are implemented in the 0.2.x line; the SVg→PS direction is newer. The PS side uses a hand-written lexer + stack-machine interpreter; the SVG side uses
|
|
7
|
+
`postsvg` is a pure-Ruby bidirectional converter between PostScript/EPS and SVG. Both directions are implemented in the 0.2.x line; the SVg→PS direction is newer. The PS side uses a hand-written lexer + stack-machine interpreter; the SVG side uses leptris. There is no Ghostscript, Inkscape, or other external renderer.
|
|
8
8
|
|
|
9
9
|
Code architecture mirrors `emfsvg`: a typed `Model::Program` value object is the single source of truth, with a Renderer / Visitor visiting it to emit SVG, and a Serializer walking it to emit PS.
|
|
10
10
|
|
|
@@ -54,7 +54,7 @@ PS/EPS bytes ──▶│ Postsvg::Lexer │
|
|
|
54
54
|
│ │
|
|
55
55
|
▼ │
|
|
56
56
|
SVG string │
|
|
57
|
-
│
|
|
57
|
+
│ leptris │
|
|
58
58
|
▼ │
|
|
59
59
|
┌─────────────────┐ │
|
|
60
60
|
│ Postsvg:: │ │
|
|
@@ -163,7 +163,7 @@ Errors: `Postsvg::ParseError`, `LexError`, `SyntaxError`, `RenderError`, `StackU
|
|
|
163
163
|
|
|
164
164
|
## Dependencies
|
|
165
165
|
|
|
166
|
-
- `parslet`, `thor`, `
|
|
166
|
+
- `parslet`, `thor`, `leptris`, `lutaml/canon` (dev only, for XML matcher in integration specs) — see `Gemfile`.
|
|
167
167
|
|
|
168
168
|
## Limitations
|
|
169
169
|
|
data/Gemfile
CHANGED
data/lib/postsvg/svg/element.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Postsvg
|
|
|
6
6
|
# carry typed semantic fields; the base provides a uniform interface
|
|
7
7
|
# for the translation layer's dispatch.
|
|
8
8
|
#
|
|
9
|
-
# Element instances are immutable: built once from a
|
|
9
|
+
# Element instances are immutable: built once from a leptris node
|
|
10
10
|
# via the .from_node factory. The node is not retained.
|
|
11
11
|
#
|
|
12
12
|
# Every element exposes `children`, `transform`, `clip_path_id`,
|
data/lib/postsvg/svg/parser.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "leptris"
|
|
4
4
|
|
|
5
5
|
module Postsvg
|
|
6
6
|
module Svg
|
|
7
|
-
# Parses an SVG document via
|
|
7
|
+
# Parses an SVG document via leptris and produces an Svg::Document.
|
|
8
8
|
# Pure: no I/O, no global state.
|
|
9
9
|
class Parser
|
|
10
10
|
def self.call(svg_string)
|
|
11
|
-
doc =
|
|
11
|
+
doc = Leptris::XML.parse(svg_string, options: Leptris::XML::ParseOptions.noblanks)
|
|
12
12
|
root = doc.root
|
|
13
13
|
raise TranslationError, "no root element in SVG" unless root
|
|
14
14
|
|
data/lib/postsvg/svg.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Postsvg
|
|
4
|
-
# SVG domain model. Built once from a
|
|
4
|
+
# SVG domain model. Built once from a leptris-parsed document;
|
|
5
5
|
# consumed by the Translation layer (SVG -> PS).
|
|
6
6
|
#
|
|
7
7
|
# Svg::* value objects know nothing about PostScript. Their job is
|
|
@@ -14,6 +14,17 @@ module Postsvg
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def emit(record)
|
|
17
|
+
# Operators built by the svg -> ps handlers carry their
|
|
18
|
+
# operands as attributes; the serializer writes keywords only
|
|
19
|
+
# and expects the operands as separate literal statements
|
|
20
|
+
# ahead of the keyword (the shape the PS parse path produces).
|
|
21
|
+
# Splice them in so the record stream round-trips.
|
|
22
|
+
if record.is_a?(Model::Operator) &&
|
|
23
|
+
record.class.public_method_defined?(:operand_values)
|
|
24
|
+
record.operand_values.each do |v|
|
|
25
|
+
@records << Model::Literals::Number.new(v)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
17
28
|
@records << record
|
|
18
29
|
self
|
|
19
30
|
end
|
data/lib/postsvg/version.rb
CHANGED
data/lib/postsvg.rb
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: postsvg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: leptris
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.9.362
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 1.9.362
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: parslet
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|