plurimath 0.11.15 → 0.11.17

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: 4b65c30f11725ec42f14fe121fda3a4d3398baedf7b5442a3f87bd9cffe95573
4
- data.tar.gz: 60908df104d07d036963dc5c105e0f02fb4b65a0f0336f4e21941ff5f080cef5
3
+ metadata.gz: 97890a7dadd0792e3a8a38fc4e559602b1b9fe7e08a66d9ede44dc9303cee721
4
+ data.tar.gz: a46581dd8505a2913928b7af5bddb2ab0404e0ac37b056b4eb3a77fdd797fc7d
5
5
  SHA512:
6
- metadata.gz: 9c4e43105945034eb0079c6d72ef9cd8593c318b12544781328547647445589808c6faef7a3e813f3c532a59d54d59a13827fa034e1496932b67c4dd95508b6f
7
- data.tar.gz: 58ee38130ab763b8733f9602b07d07648605918ae1c7e7a4bb49f9d7e0fb867f45f3e062cb6837b385331e95e782ab272cfd6804b19900d4205f8f4ef4827b58
6
+ metadata.gz: cc998579be0c5864a3c7a8f47c4943c52c9fee3b2b12042fe372ac3691bfb4925b871300fab921018efcd3d21b741c0e03bdd58b8fe954dcfe0a5e2fb6c0c387
7
+ data.tar.gz: c7bf9fc1b3d8f6455425e08add1830557f230b83309ae45a6d6038cbafd8feb62b52a27fceb43f85ab4225f9581795b356ce317219692505c3fca7bade5b0ecb
@@ -8,8 +8,9 @@ module Plurimath
8
8
  # returns the Parslet-shaped tree Asciimath::Transform expects, and
9
9
  # raises Parslet::ParseFailed with a cause at amath's rejection position.
10
10
  class Parse
11
- # amath is not released yet, so the Gemfile line points at GitHub.
12
- AMATH_GEMFILE_LINE = 'gem "amath", github: "plurimath/amath"'
11
+ # amath is a runtime dependency (published on RubyGems); this line is
12
+ # only guidance for installs where the gem is unexpectedly missing.
13
+ AMATH_GEMFILE_LINE = 'gem "amath"'
13
14
 
14
15
  def parse(text)
15
16
  load_amath
@@ -23,16 +23,30 @@ module Plurimath
23
23
  private
24
24
 
25
25
  def convert_formula(formula, output_format)
26
+ format = output_format.to_sym
27
+ unless Plurimath::Math::VALID_TYPES.key?(format)
28
+ supported = Plurimath::Math::VALID_TYPES.keys.sort.join(", ")
29
+ warn_and_exit("Invalid output format: #{output_format} (supported: #{supported})")
30
+ end
31
+
32
+ write_output(formula, format)
33
+ end
34
+
35
+ # Output formats are enumerated from Plurimath::Math::VALID_TYPES (the
36
+ # single source of truth); most formats dispatch to their `to_<type>`
37
+ # writer, with the formats needing dedicated arguments listed explicitly.
38
+ def write_output(formula, format)
26
39
  display_style = options[:display_style]
27
40
  split = options[:split_on_linebreak]
28
41
  style = display_style.to_s.empty? ? "true" : display_style
29
- case output_format
30
- when "unicodemath" then formula.to_unicodemath
31
- when "asciimath" then formula.to_asciimath
32
- when "mathml" then formula.to_mathml(display_style: style, split_on_linebreak: split)
33
- when "latex" then formula.to_latex
34
- when "omml" then formula.to_omml(display_style: style, split_on_linebreak: split)
35
- else warn_and_exit("Invalid output format: #{output_format}")
42
+ case format
43
+ when :unicode then formula.to_unicodemath
44
+ when :mathml then formula.to_mathml(display_style: style, split_on_linebreak: split)
45
+ when :omml then formula.to_omml(display_style: style, split_on_linebreak: split)
46
+ # MathML with UnitsML markup embedded (the retired asciimath2unitsml
47
+ # output shape), via Function::Unitsml's wrapped_unitsml_xml.
48
+ when :unitsml then formula.to_mathml(unitsml: { xml: true })
49
+ else formula.public_send("to_#{format}")
36
50
  end
37
51
  end
38
52
  end
data/lib/plurimath/cli.rb CHANGED
@@ -20,7 +20,7 @@ module Plurimath
20
20
  option :input_format,
21
21
  aliases: "-f",
22
22
  default: "asciimath",
23
- desc: "Input format should be in quoted string => \"asciimath\""
23
+ desc: "Input format: #{Plurimath::Math::VALID_TYPES.keys.sort.join(', ')} (default: asciimath)"
24
24
 
25
25
  option :file_path,
26
26
  aliases: "-p",
@@ -30,7 +30,7 @@ module Plurimath
30
30
  option :output_format,
31
31
  aliases: "-t",
32
32
  default: "mathml",
33
- desc: "Convert to language type, Output format should be in quoted string"
33
+ desc: "Output format: #{Plurimath::Math::VALID_TYPES.keys.sort.join(', ')} (default: mathml)"
34
34
 
35
35
  option :math_rendering,
36
36
  aliases: "-m",
@@ -66,7 +66,7 @@ module Plurimath
66
66
  option :input_format,
67
67
  aliases: "-f",
68
68
  default: "asciimath",
69
- desc: "Input format should be in quoted string => \"asciimath\""
69
+ desc: "Input format: #{Plurimath::Math::VALID_TYPES.keys.sort.join(', ')} (default: asciimath)"
70
70
 
71
71
  option :file_path,
72
72
  aliases: "-p",
@@ -499,7 +499,7 @@ options:)
499
499
  def all_unitsml_nodes?(style)
500
500
  return false unless style.nodes.one?
501
501
 
502
- style.nodes.first.attributes["unitsml"] == "true"
502
+ style.nodes.first["unitsml"] == "true"
503
503
  end
504
504
 
505
505
  def unitsml_processing(nodes, prev_node)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.11.15"
4
+ VERSION = "0.11.17"
5
5
  end
@@ -63,6 +63,10 @@ module Plurimath
63
63
  end
64
64
 
65
65
  def remove_attr(attribute)
66
+ # leptris keeps attributes in two stores: the construction-time hash
67
+ # view ([] and []= read/write it) and the attached attribute list the
68
+ # serializer renders from. Both must be cleared.
69
+ @node.attributes.delete(attribute.to_s)
66
70
  @node.remove_attribute(attribute.to_s)
67
71
  end
68
72
 
@@ -116,7 +116,11 @@ module Plurimath
116
116
  end
117
117
 
118
118
  def remove_attr(attr_key)
119
- @wrapped.unset(attr_key)
119
+ # Oga keeps attributes in an array and its `unset` does not remove
120
+ # them reliably; reject directly, matching the reader's name logic.
121
+ @wrapped.attributes.reject! do |attribute|
122
+ [attribute.name, attribute.name.split(":").last].include?(attr_key.to_s)
123
+ end
120
124
  end
121
125
 
122
126
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.15
4
+ version: 0.11.17
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-02 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amath