plurimath 0.11.4 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1bd22352f6fdea1f20d57cc552cb7c192f487de748ce69389ddd85c38bcaa2e
4
- data.tar.gz: fc2c2959d8cf67c04566de3296b9002e4ef691f6786b540aac9a2ce243018230
3
+ metadata.gz: 3ef91bdeedde9e1522b4cf104b9af6cd7f3f3be3a6407061ca3cca8f02ab5cf4
4
+ data.tar.gz: de35902ff11a81acdf1fe559d60a2f5e1a9ab88315ff276e3348e8040d8af71a
5
5
  SHA512:
6
- metadata.gz: 60ade76c92676e02145a0db94913b1cbb07e7d14f03b11b53c6438bdc65c83fe661d037613b69d9dd2cd6fcc5c7d2de39e80275b8143eb8b5ae0506e28796815
7
- data.tar.gz: ec5dc417656ad00f5b9cb96dcb95df5a4436fa793976f2f0bc13680d7be613787315992f20f81c349e628ef19c33f314f39ee0dec13d90dd597d6d6490164aec
6
+ metadata.gz: 95d7081c0d4666935b3d99c39add5dda1f4350d30d04ce41b7e302fe24c212164e2b9b55302f7493ffdb07b0f8203872a04bb6b9a43b3bbe8bd9536b04747fb4
7
+ data.tar.gz: 876992263c2ffdcb3a72dc9a37f411f894d7f3c1841d5156aad8f21e554871f331f8e8704d4e9f8b5c57b91187d0f5516bfeb59bbb9a05add81729758fd99791
@@ -0,0 +1,106 @@
1
+ # TODO — PR #448 audit (lasem image rendering)
2
+
3
+ Source: audit performed 2026-06-29 against `feat/lasem-image-rendering` (HEAD `c0a7729c`).
4
+ Author: suleman-uzair. +792/−57. DRAFT. CI green.
5
+
6
+ Scope: `Plurimath::Math.render`, `Formula#render`, `plurimath render` CLI,
7
+ `Plurimath::RenderingError`, `Plurimath::Math::Renderer` (lasem bridge).
8
+
9
+ ---
10
+
11
+ ## Blockers (must fix before merge)
12
+
13
+ ### H1. Rename `Plurimath::RenderingError` → `Plurimath::Errors::RenderingError`
14
+ - File: `lib/plurimath/errors/rendering_error.rb:4` declares `class RenderingError < Error` under `Plurimath`, not `Plurimath::Errors`.
15
+ - Move autoload from `lib/plurimath.rb:16` into `lib/plurimath/errors.rb`.
16
+ - Update references: README.adoc (2 callouts), `spec/plurimath/math/renderer_spec.rb`, `spec/plurimath/math/formula/render_spec.rb`, `spec/plurimath/math_spec.rb`.
17
+ - Precedent: `Plurimath::Errors::UnsupportedBase`, `Errors::InvalidNumber`, `Errors::UnsupportedLocale`. See memory `feedback-errors-namespace`.
18
+
19
+ ### H2. Replace `require_relative` with `autoload`
20
+ - `lib/plurimath/cli.rb:5-7` — `require_relative "cli/helpers"`, `"cli/convert"`, `"cli/render"`.
21
+ - `lib/plurimath/cli/helpers.rb:26,29` — `require_relative "../setup/ox_engine"`, `"../setup/oga"`.
22
+ - Add `autoload :Convert, "plurimath/cli/convert"` etc. on `class Cli < Thor`.
23
+
24
+ ### H3. Rebase on `main`; re-apply #452's boolean coercion
25
+ - `lib/plurimath/cli/convert.rb:17` still has `YAML.safe_load(options[:math_rendering])`.
26
+ - Replace with `options[:math_rendering].to_s == "true"` (matches `Formula#boolean_display_style`).
27
+ - Without this, the Opal path #452 fixed is broken again.
28
+
29
+ ### M1. Memoize `Renderer.available?`
30
+ - `lib/plurimath/math/renderer.rb:48-58` clears `@load_error` and re-runs `load_lasem` (which `require "lasem"`'s) on every call.
31
+ - `Math.render_available?` may be polled by callers — each call re-requires.
32
+ - Refactor: resolve load state once, return a result struct; make `available?` a pure query.
33
+
34
+ ### M5. CLI rescue parity between `convert` and `render`
35
+ - `lib/plurimath/cli/render.rb:14-16` rescues `Plurimath::Error`; `Cli::Convert#call` has no rescue.
36
+ - `plurimath convert -i '{\sin{d}' -f latex` → uncaught backtrace.
37
+ - `plurimath render -i '{\sin{d}' -f latex -o x.png` → clean message + `exit 1`.
38
+ - Decide: both rescue via a shared helper (preferred), or neither. Consider distinct exit codes (parse: 65 `EX_DATAERR`; render: 70 `EX_SOFTWARE`).
39
+
40
+ ---
41
+
42
+ ## Strongly request changes
43
+
44
+ ### M2. Unify option routing
45
+ - Three option lists across three files: `Math.SUPPORTED_PARSE_OPTIONS`, `Renderer::MATHML_OPTIONS`, `Renderer::LASEM_OPTIONS`.
46
+ - `Cli::Render#render_options` reads `Renderer::LASEM_OPTIONS` even though `Renderer` is documented NOT public API (`renderer.rb:8`).
47
+ - Decide: either `LASEM_OPTIONS` is public (say so), or move the canonical option registry onto `Math`.
48
+ - Inconsistency: `Math.parse` raises `ParseOptionError` on unknown opts; `Formula#render` silently drops unknown opts (spec `"ignores unrecognized keyword options"` codifies this). Pick one — raising is more useful for a public API.
49
+
50
+ ### L3. Spec gaps to close
51
+ - `Formula#render` with `split_on_linebreak: true` — the docstring warns it breaks lasem; no spec covers it. Either add one or stop forwarding the option to `to_mathml` in the render path.
52
+ - `Math.render` with `locale:` AND lasem geometry together — only routing is tested, not the combined path.
53
+ - `Cli::Render` with `-p`/`--file-input` — only `-i` is tested.
54
+ - `Cli::Render` writing real bytes to `--output` — every test stubs `Math.render`.
55
+ - `Cli::Convert` as standalone command object (`Cli::Convert.new(options).call`) — the new architecture's selling point, not directly tested.
56
+ - `Renderer.available?` memoization behavior (becomes relevant after M1).
57
+
58
+ ---
59
+
60
+ ## Follow-ups (can be separate PRs)
61
+
62
+ ### M3. `Cli::Convert#convert_formula` case statement (OCP)
63
+ - `lib/plurimath/cli/convert.rb:25-32` relocated pre-existing case dispatch.
64
+ - Adding a format requires touching this case AND `Formula` AND `Math::VALID_TYPES`.
65
+ - Consider `formula.public_send(:"to_#{output_format}")` with whitelist from `Math::VALID_TYPES`.
66
+
67
+ ### M4. CLI option declaration duplication
68
+ - `convert` and `render` both declare `:input`, `:input_format`, `:file_path`, `:xml_engine`, `:display_style`, `:split_on_linebreak` (~25 lines duplicated).
69
+ - Use Thor `class_option`, or a shared module.
70
+
71
+ ### M6. `Cli::Render#render_format` defers invalid-extension errors
72
+ - `lib/plurimath/cli/render.rb:38-46` returns `:gif` verbatim for unknown extensions and relies on `Renderer.normalize_format` to raise.
73
+ - Two error paths for the same kind of mistake. Validate at the CLI boundary; source supported set from `Renderer::OUTPUT_FORMATS`.
74
+
75
+ ### L1. Drop pointless `super()` in `Helpers#initialize`
76
+ - `lib/plurimath/cli/helpers.rb:13-16`. `Convert`/`Render` are plain `Object` subclasses; `super()` calls `Object#initialize` (no-op).
77
+
78
+ ### L2. Remove `send` calls to private methods in specs
79
+ - `spec/plurimath/cli_spec.rb:142,154` — `cmd.send(:render_options)`, `... .send(:render_format, ...)`.
80
+ - Either test through the public path (`Cli.start([...])`) or promote `render_format` to a tiny standalone module/class so it can be tested directly.
81
+
82
+ ### L4. Fix parallel-unsafe tmp paths in specs
83
+ - `spec/plurimath/cli_spec.rb:8` uses `Process.pid`. Use `Tempfile` or `SecureRandom.hex(4)` suffix.
84
+
85
+ ### L6. Note Opal autoload assumption
86
+ - `lib/plurimath/math/renderer.rb:11-13` claims autoload guarantees Opal won't bundle the file. This depends on Opal's compiler behavior. Add a comment noting it's empirical, not structural.
87
+
88
+ ---
89
+
90
+ ## Open architectural question
91
+
92
+ `Math` → `Formula#render` → `Renderer` → `Lasem` is three layers for "serialize to MathML, then rasterize." `Formula#render` is mostly option-slicing; `Math.render` is mostly option-routing; only `Renderer` does work.
93
+
94
+ Should rendering live on `Formula` at all? A service shape — `Plurimath::Render.call(formula, format: :png, ppi: 144)` — would keep the pure-math domain model free of native-extension / image-byte concerns. Decide before this becomes 1.x public API.
95
+
96
+ ---
97
+
98
+ ## Done well (no changes needed)
99
+
100
+ - Soft-dep gating: `lasem` is not in the gemspec, only required inside `Renderer.load_lasem`.
101
+ - Opal excluded via `RUBY_ENGINE` short-circuit at `available?` and `render_available?`.
102
+ - Single bridge point — library depends on `Plurimath::Math::Renderer` constant, never on `Lasem` directly.
103
+ - Actionable error messages (`gem \"lasem\"`, `lasem-doctor`).
104
+ - Error factory methods (`unsupported_format`, `unavailable`, `render_failed`) match `ParseOptionError.unknown_options` pattern.
105
+ - `Cli::Convert` / `Cli::Render` as standalone command objects — testable without Thor.
106
+ - Stubbed-backend specs use real `Class.new`, not doubles.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.11.4"
4
+ VERSION = "0.11.5"
5
5
  end
data/plurimath.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "bigdecimal"
31
31
  spec.add_dependency "htmlentities"
32
32
  spec.add_dependency "lutaml-model", "~> 0.8.0"
33
- spec.add_dependency "mml", "~> 2.3.6"
33
+ spec.add_dependency "mml", ">= 2.3"
34
34
  spec.add_dependency "omml", "~> 0.2.5"
35
35
  spec.add_dependency "ostruct"
36
36
  spec.add_dependency "ox"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: mml
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.3.6
61
+ version: '2.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 2.3.6
68
+ version: '2.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: omml
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +180,7 @@ files:
180
180
  - MathML-Supported-Data.adoc
181
181
  - README.adoc
182
182
  - Rakefile
183
+ - TODO.lasem-448-report.md
183
184
  - UnicodeMath-Supported-Data.adoc
184
185
  - UnitsML-Supported-Data.adoc
185
186
  - bin/console