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 +4 -4
- data/lib/plurimath/asciimath/parse.rb +3 -2
- data/lib/plurimath/cli/convert.rb +21 -7
- data/lib/plurimath/cli.rb +3 -3
- data/lib/plurimath/math/formula.rb +1 -1
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/leptris_engine/element.rb +4 -0
- data/lib/plurimath/xml_engine/oga/node.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97890a7dadd0792e3a8a38fc4e559602b1b9fe7e08a66d9ede44dc9303cee721
|
|
4
|
+
data.tar.gz: a46581dd8505a2913928b7af5bddb2ab0404e0ac37b056b4eb3a77fdd797fc7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
12
|
-
|
|
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
|
|
30
|
-
when
|
|
31
|
-
when
|
|
32
|
-
when
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
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: "
|
|
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
|
|
69
|
+
desc: "Input format: #{Plurimath::Math::VALID_TYPES.keys.sort.join(', ')} (default: asciimath)"
|
|
70
70
|
|
|
71
71
|
option :file_path,
|
|
72
72
|
aliases: "-p",
|
data/lib/plurimath/version.rb
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2026-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: amath
|