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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +10 -4
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +1 -1
  5. data/.rubocop_todo.yml +20 -91
  6. data/Gemfile +2 -1
  7. data/README.adoc +365 -4
  8. data/lib/mml/v3/common_attributes.rb +22 -0
  9. data/lib/mml/v3/configuration.rb +105 -0
  10. data/lib/mml/v3/maction.rb +22 -0
  11. data/lib/mml/v3/maligngroup.rb +20 -0
  12. data/lib/mml/v3/malignmark.rb +20 -0
  13. data/lib/mml/v3/math.rb +20 -0
  14. data/lib/mml/v3/menclose.rb +21 -0
  15. data/lib/mml/v3/merror.rb +19 -0
  16. data/lib/mml/v3/mfenced.rb +28 -0
  17. data/lib/mml/v3/mfrac.rb +27 -0
  18. data/lib/mml/v3/mfraction.rb +27 -0
  19. data/lib/mml/v3/mglyph.rb +46 -0
  20. data/lib/mml/v3/mi.rb +38 -0
  21. data/lib/mml/v3/mlabeledtr.rb +31 -0
  22. data/lib/mml/v3/mlongdiv.rb +25 -0
  23. data/lib/mml/v3/mmultiscripts.rb +27 -0
  24. data/lib/mml/v3/mn.rb +38 -0
  25. data/lib/mml/v3/mo.rb +86 -0
  26. data/lib/mml/v3/mover.rb +23 -0
  27. data/lib/mml/v3/mpadded.rb +29 -0
  28. data/lib/mml/v3/mphantom.rb +19 -0
  29. data/lib/mml/v3/mprescripts.rb +18 -0
  30. data/lib/mml/v3/mroot.rb +19 -0
  31. data/lib/mml/v3/mrow.rb +25 -0
  32. data/lib/mml/v3/ms.rb +43 -0
  33. data/lib/mml/v3/mscarries.rb +27 -0
  34. data/lib/mml/v3/mscarry.rb +23 -0
  35. data/lib/mml/v3/msgroup.rb +25 -0
  36. data/lib/mml/v3/msline.rb +28 -0
  37. data/lib/mml/v3/mspace.rb +58 -0
  38. data/lib/mml/v3/msqrt.rb +19 -0
  39. data/lib/mml/v3/msrow.rb +21 -0
  40. data/lib/mml/v3/mstack.rb +27 -0
  41. data/lib/mml/v3/mstyle.rb +211 -0
  42. data/lib/mml/v3/msub.rb +21 -0
  43. data/lib/mml/v3/msubsup.rb +23 -0
  44. data/lib/mml/v3/msup.rb +21 -0
  45. data/lib/mml/v3/mtable.rb +61 -0
  46. data/lib/mml/v3/mtd.rb +23 -0
  47. data/lib/mml/v3/mtext.rb +38 -0
  48. data/lib/mml/v3/mtr.rb +29 -0
  49. data/lib/mml/v3/munder.rb +25 -0
  50. data/lib/mml/v3/munderover.rb +25 -0
  51. data/lib/mml/v3/namespace.rb +10 -0
  52. data/lib/mml/v3/none.rb +18 -0
  53. data/lib/mml/v3/semantics.rb +19 -0
  54. data/lib/mml/v3/version.rb +7 -0
  55. data/lib/mml/v3.rb +85 -0
  56. data/lib/mml/v4/a.rb +31 -0
  57. data/lib/mml/v4/common_attributes.rb +26 -0
  58. data/lib/mml/v4/configuration.rb +106 -0
  59. data/lib/mml/v4/maction.rb +30 -0
  60. data/lib/mml/v4/maligngroup.rb +28 -0
  61. data/lib/mml/v4/malignmark.rb +28 -0
  62. data/lib/mml/v4/math.rb +27 -0
  63. data/lib/mml/v4/menclose.rb +29 -0
  64. data/lib/mml/v4/merror.rb +27 -0
  65. data/lib/mml/v4/mfenced.rb +36 -0
  66. data/lib/mml/v4/mfrac.rb +35 -0
  67. data/lib/mml/v4/mfraction.rb +31 -0
  68. data/lib/mml/v4/mglyph.rb +46 -0
  69. data/lib/mml/v4/mi.rb +41 -0
  70. data/lib/mml/v4/mlabeledtr.rb +34 -0
  71. data/lib/mml/v4/mlongdiv.rb +29 -0
  72. data/lib/mml/v4/mmultiscripts.rb +35 -0
  73. data/lib/mml/v4/mn.rb +40 -0
  74. data/lib/mml/v4/mo.rb +86 -0
  75. data/lib/mml/v4/mover.rb +31 -0
  76. data/lib/mml/v4/mpadded.rb +37 -0
  77. data/lib/mml/v4/mphantom.rb +27 -0
  78. data/lib/mml/v4/mprescripts.rb +22 -0
  79. data/lib/mml/v4/mroot.rb +27 -0
  80. data/lib/mml/v4/mrow.rb +31 -0
  81. data/lib/mml/v4/ms.rb +45 -0
  82. data/lib/mml/v4/mscarries.rb +31 -0
  83. data/lib/mml/v4/mscarry.rb +27 -0
  84. data/lib/mml/v4/msgroup.rb +29 -0
  85. data/lib/mml/v4/msline.rb +32 -0
  86. data/lib/mml/v4/mspace.rb +60 -0
  87. data/lib/mml/v4/msqrt.rb +27 -0
  88. data/lib/mml/v4/msrow.rb +29 -0
  89. data/lib/mml/v4/mstack.rb +35 -0
  90. data/lib/mml/v4/mstyle.rb +197 -0
  91. data/lib/mml/v4/msub.rb +29 -0
  92. data/lib/mml/v4/msubsup.rb +31 -0
  93. data/lib/mml/v4/msup.rb +29 -0
  94. data/lib/mml/v4/mtable.rb +66 -0
  95. data/lib/mml/v4/mtd.rb +31 -0
  96. data/lib/mml/v4/mtext.rb +40 -0
  97. data/lib/mml/v4/mtr.rb +36 -0
  98. data/lib/mml/v4/munder.rb +33 -0
  99. data/lib/mml/v4/munderover.rb +33 -0
  100. data/lib/mml/v4/namespace.rb +10 -0
  101. data/lib/mml/v4/none.rb +22 -0
  102. data/lib/mml/v4/opal_setup.rb.erb +6 -0
  103. data/lib/mml/v4/semantics.rb +23 -0
  104. data/lib/mml/v4/version.rb +7 -0
  105. data/lib/mml/v4.rb +81 -0
  106. data/lib/mml/version.rb +1 -1
  107. data/lib/mml.rb +25 -43
  108. data/mml.gemspec +1 -1
  109. metadata +105 -53
  110. data/lib/mml/common_attributes.rb +0 -23
  111. data/lib/mml/configuration.rb +0 -104
  112. data/lib/mml/maction.rb +0 -19
  113. data/lib/mml/maligngroup.rb +0 -17
  114. data/lib/mml/malignmark.rb +0 -17
  115. data/lib/mml/math_with_namespace.rb +0 -14
  116. data/lib/mml/math_with_nil_namespace.rb +0 -13
  117. data/lib/mml/menclose.rb +0 -17
  118. data/lib/mml/merror.rb +0 -15
  119. data/lib/mml/mfenced.rb +0 -24
  120. data/lib/mml/mfrac.rb +0 -23
  121. data/lib/mml/mfraction.rb +0 -23
  122. data/lib/mml/mglyph.rb +0 -43
  123. data/lib/mml/mi.rb +0 -35
  124. data/lib/mml/mlabeledtr.rb +0 -27
  125. data/lib/mml/mlongdiv.rb +0 -21
  126. data/lib/mml/mmultiscripts.rb +0 -23
  127. data/lib/mml/mn.rb +0 -35
  128. data/lib/mml/mo.rb +0 -83
  129. data/lib/mml/mover.rb +0 -19
  130. data/lib/mml/mpadded.rb +0 -25
  131. data/lib/mml/mphantom.rb +0 -15
  132. data/lib/mml/mprescripts.rb +0 -15
  133. data/lib/mml/mroot.rb +0 -15
  134. data/lib/mml/mrow.rb +0 -21
  135. data/lib/mml/ms.rb +0 -39
  136. data/lib/mml/mscarries.rb +0 -24
  137. data/lib/mml/mscarry.rb +0 -19
  138. data/lib/mml/msgroup.rb +0 -21
  139. data/lib/mml/msline.rb +0 -25
  140. data/lib/mml/mspace.rb +0 -55
  141. data/lib/mml/msqrt.rb +0 -15
  142. data/lib/mml/msrow.rb +0 -17
  143. data/lib/mml/mstack.rb +0 -23
  144. data/lib/mml/mstyle.rb +0 -212
  145. data/lib/mml/msub.rb +0 -17
  146. data/lib/mml/msubsup.rb +0 -19
  147. data/lib/mml/msup.rb +0 -17
  148. data/lib/mml/mtable.rb +0 -57
  149. data/lib/mml/mtd.rb +0 -19
  150. data/lib/mml/mtext.rb +0 -35
  151. data/lib/mml/mtr.rb +0 -25
  152. data/lib/mml/munder.rb +0 -21
  153. data/lib/mml/munderover.rb +0 -21
  154. data/lib/mml/none.rb +0 -15
  155. data/lib/mml/semantics.rb +0 -15
  156. /data/lib/mml/{opal_setup.rb.erb → v3/opal_setup.rb.erb} +0 -0
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ autoload(:Mlabeledtr, "mml/v3/mlabeledtr")
6
+ autoload(:Mtr, "mml/v3/mtr")
7
+ class Mtable < Lutaml::Model::Serializable
8
+ attribute :mathcolor, :string
9
+ attribute :mathbackground, :string
10
+ attribute :align, :string
11
+ attribute :rowalign, :string
12
+ attribute :columnalign, :string
13
+ attribute :groupalign, :string
14
+ attribute :alignmentscope, :string
15
+ attribute :columnwidth, :string
16
+ attribute :width, :string
17
+ attribute :rowspacing, :string
18
+ attribute :columnspacing, :string
19
+ attribute :rowlines, :string
20
+ attribute :columnlines, :string
21
+ attribute :frame, :string
22
+ attribute :framespacing, :string
23
+ attribute :equalrows, :string
24
+ attribute :equalcolumns, :string
25
+ attribute :displaystyle, :string
26
+ attribute :side, :string
27
+ attribute :minlabelspacing, :string
28
+ attribute :mlabeledtr_value, Mlabeledtr, collection: true
29
+ attribute :mtr_value, Mtr, collection: true
30
+
31
+ xml do
32
+ namespace Namespace
33
+ element "mtable"
34
+ mixed_content
35
+
36
+ map_attribute "mathcolor", to: :mathcolor
37
+ map_attribute "mathbackground", to: :mathbackground
38
+ map_attribute "align", to: :align
39
+ map_attribute "rowalign", to: :rowalign
40
+ map_attribute "columnalign", to: :columnalign
41
+ map_attribute "groupalign", to: :groupalign
42
+ map_attribute "alignmentscope", to: :alignmentscope
43
+ map_attribute "columnwidth", to: :columnwidth
44
+ map_attribute "width", to: :width
45
+ map_attribute "rowspacing", to: :rowspacing
46
+ map_attribute "columnspacing", to: :columnspacing
47
+ map_attribute "rowlines", to: :rowlines
48
+ map_attribute "columnlines", to: :columnlines
49
+ map_attribute "frame", to: :frame
50
+ map_attribute "framespacing", to: :framespacing
51
+ map_attribute "equalrows", to: :equalrows
52
+ map_attribute "equalcolumns", to: :equalcolumns
53
+ map_attribute "displaystyle", to: :displaystyle
54
+ map_attribute "side", to: :side
55
+ map_attribute "minlabelspacing", to: :minlabelspacing
56
+ map_element "mlabeledtr", to: :mlabeledtr_value
57
+ map_element "mtr", to: :mtr_value
58
+ end
59
+ end
60
+ end
61
+ end
data/lib/mml/v3/mtd.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class Mtd < Lutaml::Model::Serializable
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :rowalign, :string
9
+ attribute :columnalign, :string
10
+
11
+ xml do
12
+ namespace Namespace
13
+ element "mtd"
14
+ mixed_content
15
+
16
+ map_attribute "mathcolor", to: :mathcolor
17
+ map_attribute "mathbackground", to: :mathbackground
18
+ map_attribute "rowalign", to: :rowalign
19
+ map_attribute "columnalign", to: :columnalign
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class Mtext < Lutaml::Model::Serializable
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
+
19
+ xml do
20
+ namespace Namespace
21
+ element "mtext"
22
+
23
+ map_content to: :value
24
+ map_attribute "mathcolor", to: :mathcolor
25
+ map_attribute "mathbackground", to: :mathbackground
26
+ map_attribute "mathvariant", to: :mathvariant
27
+ map_attribute "mathsize", to: :mathsize
28
+ map_attribute "dir", to: :dir
29
+ map_attribute "fontfamily", to: :fontfamily
30
+ map_attribute "fontweight", to: :fontweight
31
+ map_attribute "fontstyle", to: :fontstyle
32
+ map_attribute "fontsize", to: :fontsize
33
+ map_attribute "color", to: :color
34
+ map_attribute "background", to: :background
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/mml/v3/mtr.rb ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ autoload(:Mtd, "mml/v3/mtd")
6
+
7
+ class Mtr < Lutaml::Model::Serializable
8
+ attribute :mathcolor, :string
9
+ attribute :mathbackground, :string
10
+ attribute :rowalign, :string
11
+ attribute :columnalign, :string
12
+ attribute :groupalign, :string
13
+ attribute :mtd_value, Mtd, collection: true
14
+
15
+ xml do
16
+ namespace Namespace
17
+ element "mtr"
18
+ mixed_content
19
+
20
+ map_attribute "mathcolor", to: :mathcolor
21
+ map_attribute "mathbackground", to: :mathbackground
22
+ map_attribute "rowalign", to: :rowalign
23
+ map_attribute "columnalign", to: :columnalign
24
+ map_attribute "groupalign", to: :groupalign
25
+ map_element "mtd", to: :mtd_value
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class Munder < Lutaml::Model::Serializable
6
+ attribute :mathbackground, :string
7
+ attribute :accentunder, :string
8
+ attribute :mathcolor, :string
9
+ attribute :content, :string
10
+ attribute :align, :string
11
+
12
+ xml do
13
+ namespace Namespace
14
+ element "munder"
15
+ mixed_content
16
+
17
+ map_attribute "mathbackground", to: :mathbackground
18
+ map_attribute "accentunder", to: :accentunder
19
+ map_attribute "mathcolor", to: :mathcolor
20
+ map_attribute "align", to: :align
21
+ map_content to: :content
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class Munderover < Lutaml::Model::Serializable
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :accent, :string
9
+ attribute :accentunder, :string
10
+ attribute :align, :string
11
+
12
+ xml do
13
+ namespace Namespace
14
+ element "munderover"
15
+ mixed_content
16
+
17
+ map_attribute "mathcolor", to: :mathcolor
18
+ map_attribute "mathbackground", to: :mathbackground
19
+ map_attribute "accent", to: :accent
20
+ map_attribute "accentunder", to: :accentunder
21
+ map_attribute "align", to: :align
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class Namespace < Lutaml::Xml::Namespace
6
+ uri "http://www.w3.org/1998/Math/MathML"
7
+ prefix_default "mml"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ class None < Lutaml::Model::Serializable
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+
9
+ xml do
10
+ namespace Namespace
11
+ element "none"
12
+
13
+ map_attribute "mathcolor", to: :mathcolor
14
+ map_attribute "mathbackground", to: :mathbackground
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ autoload(:Mi, "mml/v3/mi")
6
+
7
+ class Semantics < Lutaml::Model::Serializable
8
+ attribute :annotation, Mi, collection: true
9
+
10
+ xml do
11
+ namespace Namespace
12
+ element "semantics"
13
+ mixed_content
14
+
15
+ map_element :annotation, to: :annotation
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V3
5
+ VERSION = "2.1.0"
6
+ end
7
+ end
data/lib/mml/v3.rb ADDED
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+ require "mml/v3/configuration"
5
+
6
+ DEFAULT_ADAPTER = :ox
7
+
8
+ Moxml::Config.default_adapter = DEFAULT_ADAPTER
9
+
10
+ module Mml
11
+ module V3
12
+ autoload :Namespace, "mml/v3/namespace"
13
+ autoload :Maction, "mml/v3/maction"
14
+ autoload :Maligngroup, "mml/v3/maligngroup"
15
+ autoload :Malignmark, "mml/v3/malignmark"
16
+ autoload :Math, "mml/v3/math"
17
+ autoload :Menclose, "mml/v3/menclose"
18
+ autoload :Merror, "mml/v3/merror"
19
+ autoload :Mfenced, "mml/v3/mfenced"
20
+ autoload :Mfrac, "mml/v3/mfrac"
21
+ autoload :Mfraction, "mml/v3/mfraction"
22
+ autoload :Mglyph, "mml/v3/mglyph"
23
+ autoload :Mi, "mml/v3/mi"
24
+ autoload :Mlabeledtr, "mml/v3/mlabeledtr"
25
+ autoload :Mlongdiv, "mml/v3/mlongdiv"
26
+ autoload :Mmultiscripts, "mml/v3/mmultiscripts"
27
+ autoload :Mn, "mml/v3/mn"
28
+ autoload :Mo, "mml/v3/mo"
29
+ autoload :Mover, "mml/v3/mover"
30
+ autoload :Mpadded, "mml/v3/mpadded"
31
+ autoload :Mphantom, "mml/v3/mphantom"
32
+ autoload :Mprescripts, "mml/v3/mprescripts"
33
+ autoload :Mroot, "mml/v3/mroot"
34
+ autoload :Mrow, "mml/v3/mrow"
35
+ autoload :Ms, "mml/v3/ms"
36
+ autoload :Mscarries, "mml/v3/mscarries"
37
+ autoload :Mscarry, "mml/v3/mscarry"
38
+ autoload :Msgroup, "mml/v3/msgroup"
39
+ autoload :Msline, "mml/v3/msline"
40
+ autoload :Mspace, "mml/v3/mspace"
41
+ autoload :Msqrt, "mml/v3/msqrt"
42
+ autoload :Msrow, "mml/v3/msrow"
43
+ autoload :Mstack, "mml/v3/mstack"
44
+ autoload :Mstyle, "mml/v3/mstyle"
45
+ autoload :Msub, "mml/v3/msub"
46
+ autoload :Msubsup, "mml/v3/msubsup"
47
+ autoload :Msup, "mml/v3/msup"
48
+ autoload :Mtable, "mml/v3/mtable"
49
+ autoload :Mtd, "mml/v3/mtd"
50
+ autoload :Mtext, "mml/v3/mtext"
51
+ autoload :Mtr, "mml/v3/mtr"
52
+ autoload :Munder, "mml/v3/munder"
53
+ autoload :Munderover, "mml/v3/munderover"
54
+ autoload :None, "mml/v3/none"
55
+ autoload :Semantics, "mml/v3/semantics"
56
+
57
+ # Ensure that the CommonAttributes class is loaded after all
58
+ # other classes
59
+ require "mml/v3/common_attributes"
60
+
61
+ def self.update_attributes
62
+ Configuration::COMMON_ATTRIBUTES_CLASSES.each do |klass|
63
+ const_get(klass).import_model(CommonAttributes)
64
+ end
65
+ end
66
+
67
+ def self.parse(input, namespace_exist: true)
68
+ Configuration.adapter ||= DEFAULT_ADAPTER
69
+
70
+ return parse_with_no_namespace(input) unless namespace_exist
71
+
72
+ Mml::V3::Math.from_xml(input)
73
+ end
74
+
75
+ def self.parse_with_no_namespace(input)
76
+ with_ns = Nokogiri::XML.parse(input).tap do |doc|
77
+ doc.root["xmlns"] = Namespace.uri
78
+ end.to_xml
79
+
80
+ Mml::V3::Math.from_xml(with_ns)
81
+ end
82
+ end
83
+ end
84
+
85
+ Mml::V3.update_attributes
data/lib/mml/v4/a.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class A < Lutaml::Model::Serializable
6
+ attribute :href, :string
7
+ attribute :hreflang, :string
8
+ attribute :mathcolor, :string
9
+ attribute :mathbackground, :string
10
+ attribute :intent, :string
11
+ attribute :arg, :string
12
+ attribute :displaystyle, :string
13
+ attribute :scriptlevel, :integer
14
+
15
+ xml do
16
+ namespace Namespace
17
+ element "a"
18
+ mixed_content
19
+
20
+ map_attribute "href", to: :href
21
+ map_attribute "hreflang", to: :hreflang
22
+ map_attribute "mathcolor", to: :mathcolor
23
+ map_attribute "mathbackground", to: :mathbackground
24
+ map_attribute "intent", to: :intent
25
+ map_attribute "arg", to: :arg
26
+ map_attribute "displaystyle", to: :displaystyle
27
+ map_attribute "scriptlevel", to: :scriptlevel
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ Mml::V4::Configuration::SUPPORTED_TAGS.each do |tag|
6
+ autoload(tag.to_s.capitalize.to_sym, "mml/v4/#{tag}.rb")
7
+ end
8
+
9
+ class CommonAttributes < Mml::V3::CommonAttributes
10
+ Mml::V4::Configuration::SUPPORTED_TAGS.each do |tag|
11
+ tag_class = if Mml::V3.const_defined?(tag.to_s.capitalize)
12
+ Mml::V3.const_get(tag.to_s.capitalize)
13
+ else
14
+ Mml::V4.const_get(tag.to_s.capitalize)
15
+ end
16
+ attribute :"#{tag}_value", tag_class, collection: true
17
+ end
18
+
19
+ xml do
20
+ Mml::V4::Configuration::SUPPORTED_TAGS.each do |tag|
21
+ map_element tag, to: :"#{tag}_value"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ module Configuration
6
+ SUPPORTED_TAGS = %i[
7
+ a
8
+ mmultiscripts
9
+ maligngroup
10
+ malignmark
11
+ munderover
12
+ semantics
13
+ mscarries
14
+ mfraction
15
+ mphantom
16
+ menclose
17
+ mlongdiv
18
+ mpadded
19
+ msubsup
20
+ mscarry
21
+ mfenced
22
+ msgroup
23
+ mglyph
24
+ mstack
25
+ munder
26
+ mtable
27
+ mstyle
28
+ mspace
29
+ msline
30
+ merror
31
+ msrow
32
+ mfrac
33
+ mover
34
+ mroot
35
+ mtext
36
+ msqrt
37
+ mrow
38
+ msub
39
+ msup
40
+ mi
41
+ mo
42
+ mn
43
+ ms
44
+ ].freeze
45
+
46
+ COMMON_ATTRIBUTES_CLASSES = %w[
47
+ A
48
+ Math
49
+ Mmultiscripts
50
+ Munderover
51
+ Semantics
52
+ Mscarries
53
+ Mfraction
54
+ Mlongdiv
55
+ Mphantom
56
+ Menclose
57
+ Mfenced
58
+ Mpadded
59
+ Msubsup
60
+ Msgroup
61
+ Mscarry
62
+ Munder
63
+ Mstyle
64
+ Mstack
65
+ Merror
66
+ Mover
67
+ Mfrac
68
+ Msrow
69
+ Mroot
70
+ Msqrt
71
+ Mrow
72
+ Msub
73
+ Msup
74
+ Mtd
75
+ Ms
76
+ ].freeze
77
+
78
+ module_function
79
+
80
+ def config
81
+ @config ||= {}
82
+ end
83
+
84
+ def config=(config)
85
+ self.config.merge!(config)
86
+ end
87
+
88
+ def custom_models=(models_hash)
89
+ # { Mi => CustomMiClass, Mo => CustomMoClass }
90
+ models_hash.each { |klass, model| klass.model(model) }
91
+ end
92
+
93
+ def adapter
94
+ Lutaml::Model::Config.xml_adapter
95
+ end
96
+
97
+ def adapter=(adapter)
98
+ Lutaml::Model::Config.xml_adapter_type = adapter
99
+ end
100
+
101
+ def class_for(class_name)
102
+ config[class_name]
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class Maction < Mml::V3::Maction
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :actiontype, :string
9
+ attribute :selection, :string
10
+ attribute :intent, :string
11
+ attribute :arg, :string
12
+ attribute :displaystyle, :string
13
+ attribute :scriptlevel, :integer
14
+
15
+ xml do
16
+ namespace Namespace
17
+ element "maction"
18
+
19
+ map_attribute "mathcolor", to: :mathcolor
20
+ map_attribute "mathbackground", to: :mathbackground
21
+ map_attribute "actiontype", to: :actiontype
22
+ map_attribute "selection", to: :selection
23
+ map_attribute "intent", to: :intent
24
+ map_attribute "arg", to: :arg
25
+ map_attribute "displaystyle", to: :displaystyle
26
+ map_attribute "scriptlevel", to: :scriptlevel
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class Maligngroup < Mml::V3::Maligngroup
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :groupalign, :string
9
+ attribute :intent, :string
10
+ attribute :arg, :string
11
+ attribute :displaystyle, :string
12
+ attribute :scriptlevel, :integer
13
+
14
+ xml do
15
+ namespace Namespace
16
+ element "maligngroup"
17
+
18
+ map_attribute "mathcolor", to: :mathcolor
19
+ map_attribute "mathbackground", to: :mathbackground
20
+ map_attribute "groupalign", to: :groupalign
21
+ map_attribute "intent", to: :intent
22
+ map_attribute "arg", to: :arg
23
+ map_attribute "displaystyle", to: :displaystyle
24
+ map_attribute "scriptlevel", to: :scriptlevel
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class Malignmark < Mml::V3::Malignmark
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :edge, :string
9
+ attribute :intent, :string
10
+ attribute :arg, :string
11
+ attribute :displaystyle, :string
12
+ attribute :scriptlevel, :integer
13
+
14
+ xml do
15
+ namespace Namespace
16
+ element "malignmark"
17
+
18
+ map_attribute "mathcolor", to: :mathcolor
19
+ map_attribute "mathbackground", to: :mathbackground
20
+ map_attribute "edge", to: :edge
21
+ map_attribute "intent", to: :intent
22
+ map_attribute "arg", to: :arg
23
+ map_attribute "displaystyle", to: :displaystyle
24
+ map_attribute "scriptlevel", to: :scriptlevel
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class Math < Mml::V3::Math
6
+ attribute :intent, :string
7
+ attribute :arg, :string
8
+ attribute :displaystyle, :string
9
+ attribute :scriptlevel, :integer
10
+
11
+ xml do
12
+ namespace Namespace
13
+ element "math"
14
+ mixed_content
15
+
16
+ map_attribute :display, to: :display
17
+ map_attribute "intent", to: :intent
18
+ map_attribute "arg", to: :arg
19
+ map_attribute "displaystyle", to: :displaystyle
20
+ map_attribute "scriptlevel", to: :scriptlevel
21
+ end
22
+ end
23
+
24
+ # For backward compatibility, we keep MathWithNamespace as an alias to Math.
25
+ MathWithNamespace = Math
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class Menclose < Mml::V3::Menclose
6
+ attribute :mathcolor, :string
7
+ attribute :mathbackground, :string
8
+ attribute :notation, :string
9
+ attribute :intent, :string
10
+ attribute :arg, :string
11
+ attribute :displaystyle, :string
12
+ attribute :scriptlevel, :integer
13
+
14
+ xml do
15
+ namespace Namespace
16
+ element "menclose"
17
+ mixed_content
18
+
19
+ map_attribute "mathcolor", to: :mathcolor
20
+ map_attribute "mathbackground", to: :mathbackground
21
+ map_attribute "notation", to: :notation
22
+ map_attribute "intent", to: :intent
23
+ map_attribute "arg", to: :arg
24
+ map_attribute "displaystyle", to: :displaystyle
25
+ map_attribute "scriptlevel", to: :scriptlevel
26
+ end
27
+ end
28
+ end
29
+ end