mml 2.0.3 → 2.2.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/.github/workflows/release.yml +10 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +20 -91
- data/Gemfile +2 -1
- data/README.adoc +365 -4
- data/lib/mml/v3/common_attributes.rb +22 -0
- data/lib/mml/v3/configuration.rb +105 -0
- data/lib/mml/v3/maction.rb +22 -0
- data/lib/mml/v3/maligngroup.rb +20 -0
- data/lib/mml/v3/malignmark.rb +20 -0
- data/lib/mml/v3/math.rb +20 -0
- data/lib/mml/v3/menclose.rb +21 -0
- data/lib/mml/v3/merror.rb +19 -0
- data/lib/mml/v3/mfenced.rb +28 -0
- data/lib/mml/v3/mfrac.rb +27 -0
- data/lib/mml/v3/mfraction.rb +27 -0
- data/lib/mml/v3/mglyph.rb +46 -0
- data/lib/mml/v3/mi.rb +38 -0
- data/lib/mml/v3/mlabeledtr.rb +31 -0
- data/lib/mml/v3/mlongdiv.rb +25 -0
- data/lib/mml/v3/mmultiscripts.rb +27 -0
- data/lib/mml/v3/mn.rb +38 -0
- data/lib/mml/v3/mo.rb +86 -0
- data/lib/mml/v3/mover.rb +23 -0
- data/lib/mml/v3/mpadded.rb +29 -0
- data/lib/mml/v3/mphantom.rb +19 -0
- data/lib/mml/v3/mprescripts.rb +18 -0
- data/lib/mml/v3/mroot.rb +19 -0
- data/lib/mml/v3/mrow.rb +25 -0
- data/lib/mml/v3/ms.rb +43 -0
- data/lib/mml/v3/mscarries.rb +27 -0
- data/lib/mml/v3/mscarry.rb +23 -0
- data/lib/mml/v3/msgroup.rb +25 -0
- data/lib/mml/v3/msline.rb +28 -0
- data/lib/mml/v3/mspace.rb +58 -0
- data/lib/mml/v3/msqrt.rb +19 -0
- data/lib/mml/v3/msrow.rb +21 -0
- data/lib/mml/v3/mstack.rb +27 -0
- data/lib/mml/v3/mstyle.rb +211 -0
- data/lib/mml/v3/msub.rb +21 -0
- data/lib/mml/v3/msubsup.rb +23 -0
- data/lib/mml/v3/msup.rb +21 -0
- data/lib/mml/v3/mtable.rb +61 -0
- data/lib/mml/v3/mtd.rb +23 -0
- data/lib/mml/v3/mtext.rb +38 -0
- data/lib/mml/v3/mtr.rb +29 -0
- data/lib/mml/v3/munder.rb +25 -0
- data/lib/mml/v3/munderover.rb +25 -0
- data/lib/mml/v3/namespace.rb +10 -0
- data/lib/mml/v3/none.rb +18 -0
- data/lib/mml/v3/semantics.rb +19 -0
- data/lib/mml/v3/version.rb +7 -0
- data/lib/mml/v3.rb +85 -0
- data/lib/mml/v4/a.rb +31 -0
- data/lib/mml/v4/common_attributes.rb +26 -0
- data/lib/mml/v4/configuration.rb +106 -0
- data/lib/mml/v4/maction.rb +30 -0
- data/lib/mml/v4/maligngroup.rb +28 -0
- data/lib/mml/v4/malignmark.rb +28 -0
- data/lib/mml/v4/math.rb +27 -0
- data/lib/mml/v4/menclose.rb +29 -0
- data/lib/mml/v4/merror.rb +27 -0
- data/lib/mml/v4/mfenced.rb +36 -0
- data/lib/mml/v4/mfrac.rb +35 -0
- data/lib/mml/v4/mfraction.rb +31 -0
- data/lib/mml/v4/mglyph.rb +46 -0
- data/lib/mml/v4/mi.rb +41 -0
- data/lib/mml/v4/mlabeledtr.rb +34 -0
- data/lib/mml/v4/mlongdiv.rb +29 -0
- data/lib/mml/v4/mmultiscripts.rb +35 -0
- data/lib/mml/v4/mn.rb +40 -0
- data/lib/mml/v4/mo.rb +86 -0
- data/lib/mml/v4/mover.rb +31 -0
- data/lib/mml/v4/mpadded.rb +37 -0
- data/lib/mml/v4/mphantom.rb +27 -0
- data/lib/mml/v4/mprescripts.rb +22 -0
- data/lib/mml/v4/mroot.rb +27 -0
- data/lib/mml/v4/mrow.rb +31 -0
- data/lib/mml/v4/ms.rb +45 -0
- data/lib/mml/v4/mscarries.rb +31 -0
- data/lib/mml/v4/mscarry.rb +27 -0
- data/lib/mml/v4/msgroup.rb +29 -0
- data/lib/mml/v4/msline.rb +32 -0
- data/lib/mml/v4/mspace.rb +60 -0
- data/lib/mml/v4/msqrt.rb +27 -0
- data/lib/mml/v4/msrow.rb +29 -0
- data/lib/mml/v4/mstack.rb +35 -0
- data/lib/mml/v4/mstyle.rb +197 -0
- data/lib/mml/v4/msub.rb +29 -0
- data/lib/mml/v4/msubsup.rb +31 -0
- data/lib/mml/v4/msup.rb +29 -0
- data/lib/mml/v4/mtable.rb +66 -0
- data/lib/mml/v4/mtd.rb +31 -0
- data/lib/mml/v4/mtext.rb +40 -0
- data/lib/mml/v4/mtr.rb +36 -0
- data/lib/mml/v4/munder.rb +33 -0
- data/lib/mml/v4/munderover.rb +33 -0
- data/lib/mml/v4/namespace.rb +10 -0
- data/lib/mml/v4/none.rb +22 -0
- data/lib/mml/v4/opal_setup.rb.erb +6 -0
- data/lib/mml/v4/semantics.rb +23 -0
- data/lib/mml/v4/version.rb +7 -0
- data/lib/mml/v4.rb +81 -0
- data/lib/mml/version.rb +1 -1
- data/lib/mml.rb +25 -43
- data/mml.gemspec +1 -1
- metadata +105 -53
- data/lib/mml/common_attributes.rb +0 -23
- data/lib/mml/configuration.rb +0 -104
- data/lib/mml/maction.rb +0 -19
- data/lib/mml/maligngroup.rb +0 -17
- data/lib/mml/malignmark.rb +0 -17
- data/lib/mml/math_with_namespace.rb +0 -14
- data/lib/mml/math_with_nil_namespace.rb +0 -13
- data/lib/mml/menclose.rb +0 -17
- data/lib/mml/merror.rb +0 -15
- data/lib/mml/mfenced.rb +0 -24
- data/lib/mml/mfrac.rb +0 -23
- data/lib/mml/mfraction.rb +0 -23
- data/lib/mml/mglyph.rb +0 -43
- data/lib/mml/mi.rb +0 -35
- data/lib/mml/mlabeledtr.rb +0 -27
- data/lib/mml/mlongdiv.rb +0 -21
- data/lib/mml/mmultiscripts.rb +0 -23
- data/lib/mml/mn.rb +0 -35
- data/lib/mml/mo.rb +0 -83
- data/lib/mml/mover.rb +0 -19
- data/lib/mml/mpadded.rb +0 -25
- data/lib/mml/mphantom.rb +0 -15
- data/lib/mml/mprescripts.rb +0 -15
- data/lib/mml/mroot.rb +0 -15
- data/lib/mml/mrow.rb +0 -21
- data/lib/mml/ms.rb +0 -39
- data/lib/mml/mscarries.rb +0 -24
- data/lib/mml/mscarry.rb +0 -19
- data/lib/mml/msgroup.rb +0 -21
- data/lib/mml/msline.rb +0 -25
- data/lib/mml/mspace.rb +0 -55
- data/lib/mml/msqrt.rb +0 -15
- data/lib/mml/msrow.rb +0 -17
- data/lib/mml/mstack.rb +0 -23
- data/lib/mml/mstyle.rb +0 -212
- data/lib/mml/msub.rb +0 -17
- data/lib/mml/msubsup.rb +0 -19
- data/lib/mml/msup.rb +0 -17
- data/lib/mml/mtable.rb +0 -57
- data/lib/mml/mtd.rb +0 -19
- data/lib/mml/mtext.rb +0 -35
- data/lib/mml/mtr.rb +0 -25
- data/lib/mml/munder.rb +0 -21
- data/lib/mml/munderover.rb +0 -21
- data/lib/mml/none.rb +0 -15
- data/lib/mml/semantics.rb +0 -15
- /data/lib/mml/{opal_setup.rb.erb → v3/opal_setup.rb.erb} +0 -0
data/lib/mml/v4/mtext.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
class Mtext < Mml::V3::Mtext
|
|
6
|
+
attribute :value, :string
|
|
7
|
+
attribute :mathcolor, :string
|
|
8
|
+
attribute :mathbackground, :string
|
|
9
|
+
attribute :mathvariant, :string
|
|
10
|
+
attribute :mathsize, :string
|
|
11
|
+
attribute :dir, :string
|
|
12
|
+
attribute :fontfamily, :string
|
|
13
|
+
attribute :fontweight, :string
|
|
14
|
+
attribute :fontstyle, :string
|
|
15
|
+
attribute :fontsize, :string
|
|
16
|
+
attribute :color, :string
|
|
17
|
+
attribute :background, :string
|
|
18
|
+
attribute :intent, :string
|
|
19
|
+
attribute :arg, :string
|
|
20
|
+
attribute :displaystyle, :string
|
|
21
|
+
attribute :scriptlevel, :integer
|
|
22
|
+
|
|
23
|
+
xml do
|
|
24
|
+
namespace Namespace
|
|
25
|
+
element "mtext"
|
|
26
|
+
|
|
27
|
+
map_content to: :value
|
|
28
|
+
map_attribute "mathcolor", to: :mathcolor
|
|
29
|
+
map_attribute "mathbackground", to: :mathbackground
|
|
30
|
+
map_attribute "mathvariant", to: :mathvariant
|
|
31
|
+
map_attribute "mathsize", to: :mathsize
|
|
32
|
+
map_attribute "dir", to: :dir
|
|
33
|
+
map_attribute "intent", to: :intent
|
|
34
|
+
map_attribute "arg", to: :arg
|
|
35
|
+
map_attribute "displaystyle", to: :displaystyle
|
|
36
|
+
map_attribute "scriptlevel", to: :scriptlevel
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/mml/v4/mtr.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
autoload(:Mtd, "mml/v4/mtd")
|
|
6
|
+
|
|
7
|
+
class Mtr < Mml::V3::Mtr
|
|
8
|
+
attribute :mathcolor, :string
|
|
9
|
+
attribute :mathbackground, :string
|
|
10
|
+
attribute :rowalign, :string
|
|
11
|
+
attribute :columnalign, :string
|
|
12
|
+
attribute :groupalign, :string
|
|
13
|
+
attribute :intent, :string
|
|
14
|
+
attribute :arg, :string
|
|
15
|
+
attribute :displaystyle, :string
|
|
16
|
+
attribute :scriptlevel, :integer
|
|
17
|
+
attribute :mtd_value, Mtd, collection: true
|
|
18
|
+
|
|
19
|
+
xml do
|
|
20
|
+
namespace Namespace
|
|
21
|
+
element "mtr"
|
|
22
|
+
mixed_content
|
|
23
|
+
|
|
24
|
+
map_attribute "mathcolor", to: :mathcolor
|
|
25
|
+
map_attribute "mathbackground", to: :mathbackground
|
|
26
|
+
map_attribute "rowalign", to: :rowalign
|
|
27
|
+
map_attribute "columnalign", to: :columnalign
|
|
28
|
+
map_attribute "intent", to: :intent
|
|
29
|
+
map_attribute "arg", to: :arg
|
|
30
|
+
map_attribute "displaystyle", to: :displaystyle
|
|
31
|
+
map_attribute "scriptlevel", to: :scriptlevel
|
|
32
|
+
map_element "mtd", to: :mtd_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
class Munder < Mml::V3::Munder
|
|
6
|
+
attribute :mathbackground, :string
|
|
7
|
+
attribute :accentunder, :string
|
|
8
|
+
attribute :mathcolor, :string
|
|
9
|
+
attribute :content, :string
|
|
10
|
+
attribute :align, :string
|
|
11
|
+
attribute :intent, :string
|
|
12
|
+
attribute :arg, :string
|
|
13
|
+
attribute :displaystyle, :string
|
|
14
|
+
attribute :scriptlevel, :integer
|
|
15
|
+
|
|
16
|
+
xml do
|
|
17
|
+
namespace Namespace
|
|
18
|
+
element "munder"
|
|
19
|
+
mixed_content
|
|
20
|
+
|
|
21
|
+
map_attribute "mathbackground", to: :mathbackground
|
|
22
|
+
map_attribute "accentunder", to: :accentunder
|
|
23
|
+
map_attribute "mathcolor", to: :mathcolor
|
|
24
|
+
map_attribute "align", to: :align
|
|
25
|
+
map_attribute "intent", to: :intent
|
|
26
|
+
map_attribute "arg", to: :arg
|
|
27
|
+
map_attribute "displaystyle", to: :displaystyle
|
|
28
|
+
map_attribute "scriptlevel", to: :scriptlevel
|
|
29
|
+
map_content to: :content
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
class Munderover < Mml::V3::Munderover
|
|
6
|
+
attribute :mathcolor, :string
|
|
7
|
+
attribute :mathbackground, :string
|
|
8
|
+
attribute :accent, :string
|
|
9
|
+
attribute :accentunder, :string
|
|
10
|
+
attribute :align, :string
|
|
11
|
+
attribute :intent, :string
|
|
12
|
+
attribute :arg, :string
|
|
13
|
+
attribute :displaystyle, :string
|
|
14
|
+
attribute :scriptlevel, :integer
|
|
15
|
+
|
|
16
|
+
xml do
|
|
17
|
+
namespace Namespace
|
|
18
|
+
element "munderover"
|
|
19
|
+
mixed_content
|
|
20
|
+
|
|
21
|
+
map_attribute "mathcolor", to: :mathcolor
|
|
22
|
+
map_attribute "mathbackground", to: :mathbackground
|
|
23
|
+
map_attribute "accent", to: :accent
|
|
24
|
+
map_attribute "accentunder", to: :accentunder
|
|
25
|
+
map_attribute "align", to: :align
|
|
26
|
+
map_attribute "intent", to: :intent
|
|
27
|
+
map_attribute "arg", to: :arg
|
|
28
|
+
map_attribute "displaystyle", to: :displaystyle
|
|
29
|
+
map_attribute "scriptlevel", to: :scriptlevel
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/mml/v4/none.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
class None < Mml::V3::None
|
|
6
|
+
attribute :mathcolor, :string
|
|
7
|
+
attribute :mathbackground, :string
|
|
8
|
+
attribute :intent, :string
|
|
9
|
+
attribute :arg, :string
|
|
10
|
+
|
|
11
|
+
xml do
|
|
12
|
+
namespace Namespace
|
|
13
|
+
element "none"
|
|
14
|
+
|
|
15
|
+
map_attribute "mathcolor", to: :mathcolor
|
|
16
|
+
map_attribute "mathbackground", to: :mathbackground
|
|
17
|
+
map_attribute "intent", to: :intent
|
|
18
|
+
map_attribute "arg", to: :arg
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mml
|
|
4
|
+
module V4
|
|
5
|
+
autoload(:Mi, "mml/v4/mi")
|
|
6
|
+
|
|
7
|
+
class Semantics < Mml::V3::Semantics
|
|
8
|
+
attribute :annotation, Mi, collection: true
|
|
9
|
+
attribute :displaystyle, :string
|
|
10
|
+
attribute :scriptlevel, :integer
|
|
11
|
+
|
|
12
|
+
xml do
|
|
13
|
+
namespace Namespace
|
|
14
|
+
element "semantics"
|
|
15
|
+
mixed_content
|
|
16
|
+
|
|
17
|
+
map_element :annotation, to: :annotation
|
|
18
|
+
map_attribute "displaystyle", to: :displaystyle
|
|
19
|
+
map_attribute "scriptlevel", to: :scriptlevel
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/mml/v4.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mml/v4/configuration"
|
|
4
|
+
|
|
5
|
+
module Mml
|
|
6
|
+
module V4
|
|
7
|
+
autoload :Namespace, "mml/v4/namespace"
|
|
8
|
+
autoload :A, "mml/v4/a"
|
|
9
|
+
autoload :Maction, "mml/v4/maction"
|
|
10
|
+
autoload :Maligngroup, "mml/v4/maligngroup"
|
|
11
|
+
autoload :Malignmark, "mml/v4/malignmark"
|
|
12
|
+
autoload :Math, "mml/v4/math"
|
|
13
|
+
autoload :Menclose, "mml/v4/menclose"
|
|
14
|
+
autoload :Merror, "mml/v4/merror"
|
|
15
|
+
autoload :Mfenced, "mml/v4/mfenced"
|
|
16
|
+
autoload :Mfrac, "mml/v4/mfrac"
|
|
17
|
+
autoload :Mfraction, "mml/v4/mfraction"
|
|
18
|
+
autoload :Mglyph, "mml/v4/mglyph"
|
|
19
|
+
autoload :Mi, "mml/v4/mi"
|
|
20
|
+
autoload :Mlabeledtr, "mml/v4/mlabeledtr"
|
|
21
|
+
autoload :Mlongdiv, "mml/v4/mlongdiv"
|
|
22
|
+
autoload :Mmultiscripts, "mml/v4/mmultiscripts"
|
|
23
|
+
autoload :Mn, "mml/v4/mn"
|
|
24
|
+
autoload :Mo, "mml/v4/mo"
|
|
25
|
+
autoload :Mover, "mml/v4/mover"
|
|
26
|
+
autoload :Mpadded, "mml/v4/mpadded"
|
|
27
|
+
autoload :Mphantom, "mml/v4/mphantom"
|
|
28
|
+
autoload :Mprescripts, "mml/v4/mprescripts"
|
|
29
|
+
autoload :Mroot, "mml/v4/mroot"
|
|
30
|
+
autoload :Mrow, "mml/v4/mrow"
|
|
31
|
+
autoload :Ms, "mml/v4/ms"
|
|
32
|
+
autoload :Mscarries, "mml/v4/mscarries"
|
|
33
|
+
autoload :Mscarry, "mml/v4/mscarry"
|
|
34
|
+
autoload :Msgroup, "mml/v4/msgroup"
|
|
35
|
+
autoload :Msline, "mml/v4/msline"
|
|
36
|
+
autoload :Mspace, "mml/v4/mspace"
|
|
37
|
+
autoload :Msqrt, "mml/v4/msqrt"
|
|
38
|
+
autoload :Msrow, "mml/v4/msrow"
|
|
39
|
+
autoload :Mstack, "mml/v4/mstack"
|
|
40
|
+
autoload :Mstyle, "mml/v4/mstyle"
|
|
41
|
+
autoload :Msub, "mml/v4/msub"
|
|
42
|
+
autoload :Msubsup, "mml/v4/msubsup"
|
|
43
|
+
autoload :Msup, "mml/v4/msup"
|
|
44
|
+
autoload :Mtable, "mml/v4/mtable"
|
|
45
|
+
autoload :Mtd, "mml/v4/mtd"
|
|
46
|
+
autoload :Mtext, "mml/v4/mtext"
|
|
47
|
+
autoload :Mtr, "mml/v4/mtr"
|
|
48
|
+
autoload :Munder, "mml/v4/munder"
|
|
49
|
+
autoload :Munderover, "mml/v4/munderover"
|
|
50
|
+
autoload :None, "mml/v4/none"
|
|
51
|
+
autoload :Semantics, "mml/v4/semantics"
|
|
52
|
+
|
|
53
|
+
# Ensure that the CommonAttributes class is loaded after all
|
|
54
|
+
# other classes
|
|
55
|
+
require "mml/v4/common_attributes"
|
|
56
|
+
|
|
57
|
+
def self.update_attributes
|
|
58
|
+
Configuration::COMMON_ATTRIBUTES_CLASSES.each do |klass|
|
|
59
|
+
const_get(klass).import_model(CommonAttributes)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.parse(input, namespace_exist: true)
|
|
64
|
+
Configuration.adapter ||= DEFAULT_ADAPTER
|
|
65
|
+
|
|
66
|
+
return parse_with_no_namespace(input) unless namespace_exist
|
|
67
|
+
|
|
68
|
+
Mml::V4::Math.from_xml(input)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.parse_with_no_namespace(input)
|
|
72
|
+
with_ns = Nokogiri::XML.parse(input).tap do |doc|
|
|
73
|
+
doc.root["xmlns"] = Namespace.uri
|
|
74
|
+
end.to_xml
|
|
75
|
+
|
|
76
|
+
Mml::V4::Math.from_xml(with_ns)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
Mml::V4.update_attributes
|
data/lib/mml/version.rb
CHANGED
data/lib/mml.rb
CHANGED
|
@@ -1,56 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "mml/configuration"
|
|
5
|
-
if RUBY_ENGINE == "opal"
|
|
6
|
-
require_relative "mml/opal_setup"
|
|
7
|
-
else
|
|
8
|
-
lib_path = File.join(__dir__, "mml", "*.rb")
|
|
9
|
-
Dir[lib_path].each do |file|
|
|
10
|
-
basename = File.basename(file, ".rb")
|
|
11
|
-
next if basename == "common_attributes"
|
|
12
|
-
|
|
13
|
-
require_relative "mml/#{basename}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
# Ensure that the CommonAttributes class is loaded after all
|
|
17
|
-
# other classes
|
|
18
|
-
require "mml/common_attributes"
|
|
19
|
-
|
|
20
|
-
DEFAULT_ADAPTER = if RUBY_ENGINE == "opal"
|
|
21
|
-
require "lutaml/model/xml_adapter/oga_adapter"
|
|
22
|
-
:oga
|
|
23
|
-
else
|
|
24
|
-
require "lutaml/model/xml_adapter/ox_adapter"
|
|
25
|
-
:ox
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Moxml::Config.default_adapter = DEFAULT_ADAPTER
|
|
3
|
+
require "mml/v3"
|
|
29
4
|
|
|
30
5
|
module Mml
|
|
31
6
|
class Error < StandardError; end
|
|
32
7
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
8
|
+
# Delegate undefined constants to Mml::V3 for backward compatibility.
|
|
9
|
+
# Lazily loads Mml::V4 when referenced.
|
|
10
|
+
def self.const_missing(name)
|
|
11
|
+
if name == :V4
|
|
12
|
+
require "mml/v4"
|
|
13
|
+
Mml::V4
|
|
14
|
+
elsif Mml::V3.const_defined?(name)
|
|
15
|
+
Mml::V3.const_get(name)
|
|
16
|
+
else
|
|
17
|
+
raise NameError, "uninitialized constant Mml::#{name}"
|
|
42
18
|
end
|
|
43
19
|
end
|
|
44
20
|
|
|
45
|
-
|
|
46
|
-
Configuration.adapter = DEFAULT_ADAPTER unless Configuration.adapter
|
|
21
|
+
module_function
|
|
47
22
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
def parse(input, namespace_exist: true, version: 3)
|
|
24
|
+
case version
|
|
25
|
+
when 3 then Mml::V3.parse(input, namespace_exist: namespace_exist)
|
|
26
|
+
when 4
|
|
27
|
+
require "mml/v4"
|
|
28
|
+
Mml::V4.parse(input, namespace_exist: namespace_exist)
|
|
29
|
+
else raise Error, "Unsupported MathML version: #{version}"
|
|
52
30
|
end
|
|
53
31
|
end
|
|
54
|
-
end
|
|
55
32
|
|
|
56
|
-
Mml
|
|
33
|
+
# Backward compatibility: Mml aliases Mml::V3
|
|
34
|
+
Configuration = Mml::V3::Configuration
|
|
35
|
+
|
|
36
|
+
# Explicitly define Math to avoid collision with Ruby built-in Math module
|
|
37
|
+
Math = Mml::V3::Math
|
|
38
|
+
end
|
data/mml.gemspec
CHANGED
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
30
|
spec.require_paths = ["lib"]
|
|
31
31
|
|
|
32
|
-
spec.add_dependency "lutaml-model"
|
|
32
|
+
spec.add_dependency "lutaml-model", "~> 0.8.0"
|
|
33
33
|
spec.add_dependency "moxml"
|
|
34
34
|
spec.metadata["rubygems_mfa_required"] = "true"
|
|
35
35
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.8.0
|
|
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: 0.8.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: moxml
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -60,53 +60,105 @@ files:
|
|
|
60
60
|
- bin/console
|
|
61
61
|
- bin/setup
|
|
62
62
|
- lib/mml.rb
|
|
63
|
-
- lib/mml/
|
|
64
|
-
- lib/mml/
|
|
65
|
-
- lib/mml/
|
|
66
|
-
- lib/mml/
|
|
67
|
-
- lib/mml/
|
|
68
|
-
- lib/mml/
|
|
69
|
-
- lib/mml/
|
|
70
|
-
- lib/mml/menclose.rb
|
|
71
|
-
- lib/mml/merror.rb
|
|
72
|
-
- lib/mml/mfenced.rb
|
|
73
|
-
- lib/mml/mfrac.rb
|
|
74
|
-
- lib/mml/mfraction.rb
|
|
75
|
-
- lib/mml/mglyph.rb
|
|
76
|
-
- lib/mml/mi.rb
|
|
77
|
-
- lib/mml/mlabeledtr.rb
|
|
78
|
-
- lib/mml/mlongdiv.rb
|
|
79
|
-
- lib/mml/mmultiscripts.rb
|
|
80
|
-
- lib/mml/mn.rb
|
|
81
|
-
- lib/mml/mo.rb
|
|
82
|
-
- lib/mml/mover.rb
|
|
83
|
-
- lib/mml/mpadded.rb
|
|
84
|
-
- lib/mml/mphantom.rb
|
|
85
|
-
- lib/mml/mprescripts.rb
|
|
86
|
-
- lib/mml/mroot.rb
|
|
87
|
-
- lib/mml/mrow.rb
|
|
88
|
-
- lib/mml/ms.rb
|
|
89
|
-
- lib/mml/mscarries.rb
|
|
90
|
-
- lib/mml/mscarry.rb
|
|
91
|
-
- lib/mml/msgroup.rb
|
|
92
|
-
- lib/mml/msline.rb
|
|
93
|
-
- lib/mml/mspace.rb
|
|
94
|
-
- lib/mml/msqrt.rb
|
|
95
|
-
- lib/mml/msrow.rb
|
|
96
|
-
- lib/mml/mstack.rb
|
|
97
|
-
- lib/mml/mstyle.rb
|
|
98
|
-
- lib/mml/msub.rb
|
|
99
|
-
- lib/mml/msubsup.rb
|
|
100
|
-
- lib/mml/msup.rb
|
|
101
|
-
- lib/mml/mtable.rb
|
|
102
|
-
- lib/mml/mtd.rb
|
|
103
|
-
- lib/mml/mtext.rb
|
|
104
|
-
- lib/mml/mtr.rb
|
|
105
|
-
- lib/mml/munder.rb
|
|
106
|
-
- lib/mml/munderover.rb
|
|
107
|
-
- lib/mml/
|
|
108
|
-
- lib/mml/
|
|
109
|
-
- lib/mml/
|
|
63
|
+
- lib/mml/v3.rb
|
|
64
|
+
- lib/mml/v3/common_attributes.rb
|
|
65
|
+
- lib/mml/v3/configuration.rb
|
|
66
|
+
- lib/mml/v3/maction.rb
|
|
67
|
+
- lib/mml/v3/maligngroup.rb
|
|
68
|
+
- lib/mml/v3/malignmark.rb
|
|
69
|
+
- lib/mml/v3/math.rb
|
|
70
|
+
- lib/mml/v3/menclose.rb
|
|
71
|
+
- lib/mml/v3/merror.rb
|
|
72
|
+
- lib/mml/v3/mfenced.rb
|
|
73
|
+
- lib/mml/v3/mfrac.rb
|
|
74
|
+
- lib/mml/v3/mfraction.rb
|
|
75
|
+
- lib/mml/v3/mglyph.rb
|
|
76
|
+
- lib/mml/v3/mi.rb
|
|
77
|
+
- lib/mml/v3/mlabeledtr.rb
|
|
78
|
+
- lib/mml/v3/mlongdiv.rb
|
|
79
|
+
- lib/mml/v3/mmultiscripts.rb
|
|
80
|
+
- lib/mml/v3/mn.rb
|
|
81
|
+
- lib/mml/v3/mo.rb
|
|
82
|
+
- lib/mml/v3/mover.rb
|
|
83
|
+
- lib/mml/v3/mpadded.rb
|
|
84
|
+
- lib/mml/v3/mphantom.rb
|
|
85
|
+
- lib/mml/v3/mprescripts.rb
|
|
86
|
+
- lib/mml/v3/mroot.rb
|
|
87
|
+
- lib/mml/v3/mrow.rb
|
|
88
|
+
- lib/mml/v3/ms.rb
|
|
89
|
+
- lib/mml/v3/mscarries.rb
|
|
90
|
+
- lib/mml/v3/mscarry.rb
|
|
91
|
+
- lib/mml/v3/msgroup.rb
|
|
92
|
+
- lib/mml/v3/msline.rb
|
|
93
|
+
- lib/mml/v3/mspace.rb
|
|
94
|
+
- lib/mml/v3/msqrt.rb
|
|
95
|
+
- lib/mml/v3/msrow.rb
|
|
96
|
+
- lib/mml/v3/mstack.rb
|
|
97
|
+
- lib/mml/v3/mstyle.rb
|
|
98
|
+
- lib/mml/v3/msub.rb
|
|
99
|
+
- lib/mml/v3/msubsup.rb
|
|
100
|
+
- lib/mml/v3/msup.rb
|
|
101
|
+
- lib/mml/v3/mtable.rb
|
|
102
|
+
- lib/mml/v3/mtd.rb
|
|
103
|
+
- lib/mml/v3/mtext.rb
|
|
104
|
+
- lib/mml/v3/mtr.rb
|
|
105
|
+
- lib/mml/v3/munder.rb
|
|
106
|
+
- lib/mml/v3/munderover.rb
|
|
107
|
+
- lib/mml/v3/namespace.rb
|
|
108
|
+
- lib/mml/v3/none.rb
|
|
109
|
+
- lib/mml/v3/opal_setup.rb.erb
|
|
110
|
+
- lib/mml/v3/semantics.rb
|
|
111
|
+
- lib/mml/v3/version.rb
|
|
112
|
+
- lib/mml/v4.rb
|
|
113
|
+
- lib/mml/v4/a.rb
|
|
114
|
+
- lib/mml/v4/common_attributes.rb
|
|
115
|
+
- lib/mml/v4/configuration.rb
|
|
116
|
+
- lib/mml/v4/maction.rb
|
|
117
|
+
- lib/mml/v4/maligngroup.rb
|
|
118
|
+
- lib/mml/v4/malignmark.rb
|
|
119
|
+
- lib/mml/v4/math.rb
|
|
120
|
+
- lib/mml/v4/menclose.rb
|
|
121
|
+
- lib/mml/v4/merror.rb
|
|
122
|
+
- lib/mml/v4/mfenced.rb
|
|
123
|
+
- lib/mml/v4/mfrac.rb
|
|
124
|
+
- lib/mml/v4/mfraction.rb
|
|
125
|
+
- lib/mml/v4/mglyph.rb
|
|
126
|
+
- lib/mml/v4/mi.rb
|
|
127
|
+
- lib/mml/v4/mlabeledtr.rb
|
|
128
|
+
- lib/mml/v4/mlongdiv.rb
|
|
129
|
+
- lib/mml/v4/mmultiscripts.rb
|
|
130
|
+
- lib/mml/v4/mn.rb
|
|
131
|
+
- lib/mml/v4/mo.rb
|
|
132
|
+
- lib/mml/v4/mover.rb
|
|
133
|
+
- lib/mml/v4/mpadded.rb
|
|
134
|
+
- lib/mml/v4/mphantom.rb
|
|
135
|
+
- lib/mml/v4/mprescripts.rb
|
|
136
|
+
- lib/mml/v4/mroot.rb
|
|
137
|
+
- lib/mml/v4/mrow.rb
|
|
138
|
+
- lib/mml/v4/ms.rb
|
|
139
|
+
- lib/mml/v4/mscarries.rb
|
|
140
|
+
- lib/mml/v4/mscarry.rb
|
|
141
|
+
- lib/mml/v4/msgroup.rb
|
|
142
|
+
- lib/mml/v4/msline.rb
|
|
143
|
+
- lib/mml/v4/mspace.rb
|
|
144
|
+
- lib/mml/v4/msqrt.rb
|
|
145
|
+
- lib/mml/v4/msrow.rb
|
|
146
|
+
- lib/mml/v4/mstack.rb
|
|
147
|
+
- lib/mml/v4/mstyle.rb
|
|
148
|
+
- lib/mml/v4/msub.rb
|
|
149
|
+
- lib/mml/v4/msubsup.rb
|
|
150
|
+
- lib/mml/v4/msup.rb
|
|
151
|
+
- lib/mml/v4/mtable.rb
|
|
152
|
+
- lib/mml/v4/mtd.rb
|
|
153
|
+
- lib/mml/v4/mtext.rb
|
|
154
|
+
- lib/mml/v4/mtr.rb
|
|
155
|
+
- lib/mml/v4/munder.rb
|
|
156
|
+
- lib/mml/v4/munderover.rb
|
|
157
|
+
- lib/mml/v4/namespace.rb
|
|
158
|
+
- lib/mml/v4/none.rb
|
|
159
|
+
- lib/mml/v4/opal_setup.rb.erb
|
|
160
|
+
- lib/mml/v4/semantics.rb
|
|
161
|
+
- lib/mml/v4/version.rb
|
|
110
162
|
- lib/mml/version.rb
|
|
111
163
|
- mml.gemspec
|
|
112
164
|
- sig/mml.rbs
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Mml
|
|
4
|
-
Mml::Configuration::SUPPORTED_TAGS.each do |tag|
|
|
5
|
-
# `autoload` is `require`, not `require_relative`
|
|
6
|
-
autoload(tag.to_s.capitalize.to_sym, "mml/#{tag}.rb")
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class CommonAttributes < Lutaml::Model::Serializable
|
|
10
|
-
Mml::Configuration::SUPPORTED_TAGS.each do |tag|
|
|
11
|
-
attribute :"#{tag}_value", Mml.const_get(tag.to_s.capitalize),
|
|
12
|
-
collection: true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
xml do
|
|
16
|
-
no_root
|
|
17
|
-
|
|
18
|
-
Mml::Configuration::SUPPORTED_TAGS.each do |tag|
|
|
19
|
-
map_element tag, to: :"#{tag}_value"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|