mml 2.2.1 → 2.3.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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +14 -4
  3. data/CLAUDE.md +79 -0
  4. data/README.adoc +166 -43
  5. data/lib/mml/base/deprecated_font_attributes.rb +31 -0
  6. data/lib/mml/base/maction.rb +28 -0
  7. data/lib/mml/base/maligngroup.rb +26 -0
  8. data/lib/mml/base/malignmark.rb +26 -0
  9. data/lib/mml/base/math.rb +23 -0
  10. data/lib/mml/base/menclose.rb +27 -0
  11. data/lib/mml/base/merror.rb +25 -0
  12. data/lib/mml/base/mfenced.rb +34 -0
  13. data/lib/mml/base/mfrac.rb +33 -0
  14. data/lib/mml/base/mfraction.rb +33 -0
  15. data/lib/mml/base/mglyph.rb +42 -0
  16. data/lib/mml/base/mi.rb +32 -0
  17. data/lib/mml/base/mlabeledtr.rb +37 -0
  18. data/lib/mml/base/mlongdiv.rb +31 -0
  19. data/lib/mml/base/mmultiscripts.rb +31 -0
  20. data/lib/mml/base/mn.rb +32 -0
  21. data/lib/mml/base/mo.rb +76 -0
  22. data/lib/mml/base/mover.rb +29 -0
  23. data/lib/mml/base/mpadded.rb +35 -0
  24. data/lib/mml/base/mphantom.rb +25 -0
  25. data/lib/mml/base/mprescripts.rb +24 -0
  26. data/lib/mml/base/mroot.rb +25 -0
  27. data/lib/mml/base/mrow.rb +29 -0
  28. data/lib/mml/base/ms.rb +37 -0
  29. data/lib/mml/base/mscarries.rb +33 -0
  30. data/lib/mml/base/mscarry.rb +29 -0
  31. data/lib/mml/base/msgroup.rb +31 -0
  32. data/lib/mml/base/msline.rb +34 -0
  33. data/lib/mml/base/mspace.rb +52 -0
  34. data/lib/mml/base/msqrt.rb +25 -0
  35. data/lib/mml/base/msrow.rb +27 -0
  36. data/lib/mml/base/mstack.rb +33 -0
  37. data/lib/mml/base/mstyle.rb +189 -0
  38. data/lib/mml/base/msub.rb +27 -0
  39. data/lib/mml/base/msubsup.rb +29 -0
  40. data/lib/mml/base/msup.rb +27 -0
  41. data/lib/mml/base/mtable.rb +57 -0
  42. data/lib/mml/base/mtd.rb +29 -0
  43. data/lib/mml/base/mtext.rb +32 -0
  44. data/lib/mml/base/mtr.rb +35 -0
  45. data/lib/mml/base/munder.rb +31 -0
  46. data/lib/mml/base/munderover.rb +31 -0
  47. data/lib/mml/base/none.rb +24 -0
  48. data/lib/mml/base/semantics.rb +23 -0
  49. data/lib/mml/base/v3_only/operator_attrs.rb +24 -0
  50. data/lib/mml/base/v3_only/style_attrs.rb +31 -0
  51. data/lib/mml/base/v3_only/table_attrs.rb +28 -0
  52. data/lib/mml/base/v3_only.rb +11 -0
  53. data/lib/mml/base/v4_attributes.rb +30 -0
  54. data/lib/mml/base.rb +51 -0
  55. data/lib/mml/common_elements.rb +85 -0
  56. data/lib/mml/context_configuration.rb +118 -0
  57. data/lib/mml/context_options.rb +64 -0
  58. data/lib/mml/namespace.rb +10 -0
  59. data/lib/mml/v3/common_elements.rb +8 -0
  60. data/lib/mml/v3/configuration.rb +4 -96
  61. data/lib/mml/v3/maction.rb +2 -14
  62. data/lib/mml/v3/maligngroup.rb +2 -12
  63. data/lib/mml/v3/malignmark.rb +2 -12
  64. data/lib/mml/v3/math.rb +3 -10
  65. data/lib/mml/v3/menclose.rb +3 -14
  66. data/lib/mml/v3/merror.rb +3 -12
  67. data/lib/mml/v3/mfenced.rb +3 -21
  68. data/lib/mml/v3/mfrac.rb +3 -20
  69. data/lib/mml/v3/mfraction.rb +3 -20
  70. data/lib/mml/v3/mglyph.rb +3 -38
  71. data/lib/mml/v3/mi.rb +3 -30
  72. data/lib/mml/v3/mlabeledtr.rb +2 -23
  73. data/lib/mml/v3/mlongdiv.rb +3 -18
  74. data/lib/mml/v3/mmultiscripts.rb +3 -20
  75. data/lib/mml/v3/mn.rb +3 -30
  76. data/lib/mml/v3/mo.rb +4 -78
  77. data/lib/mml/v3/mover.rb +3 -16
  78. data/lib/mml/v3/mpadded.rb +3 -22
  79. data/lib/mml/v3/mphantom.rb +3 -12
  80. data/lib/mml/v3/mprescripts.rb +2 -10
  81. data/lib/mml/v3/mroot.rb +3 -12
  82. data/lib/mml/v3/mrow.rb +3 -18
  83. data/lib/mml/v3/ms.rb +4 -36
  84. data/lib/mml/v3/mscarries.rb +3 -20
  85. data/lib/mml/v3/mscarry.rb +3 -16
  86. data/lib/mml/v3/msgroup.rb +3 -18
  87. data/lib/mml/v3/msline.rb +2 -20
  88. data/lib/mml/v3/mspace.rb +3 -50
  89. data/lib/mml/v3/msqrt.rb +3 -12
  90. data/lib/mml/v3/msrow.rb +3 -14
  91. data/lib/mml/v3/mstack.rb +3 -20
  92. data/lib/mml/v3/mstyle.rb +5 -204
  93. data/lib/mml/v3/msub.rb +3 -14
  94. data/lib/mml/v3/msubsup.rb +3 -16
  95. data/lib/mml/v3/msup.rb +3 -14
  96. data/lib/mml/v3/mtable.rb +3 -53
  97. data/lib/mml/v3/mtd.rb +3 -16
  98. data/lib/mml/v3/mtext.rb +3 -30
  99. data/lib/mml/v3/mtr.rb +2 -21
  100. data/lib/mml/v3/munder.rb +3 -18
  101. data/lib/mml/v3/munderover.rb +3 -18
  102. data/lib/mml/v3/namespace.rb +1 -4
  103. data/lib/mml/v3/none.rb +2 -10
  104. data/lib/mml/v3/semantics.rb +3 -12
  105. data/lib/mml/v3.rb +51 -77
  106. data/lib/mml/v4/a.rb +4 -13
  107. data/lib/mml/v4/common_elements.rb +13 -0
  108. data/lib/mml/v4/configuration.rb +4 -97
  109. data/lib/mml/v4/maction.rb +4 -19
  110. data/lib/mml/v4/maligngroup.rb +4 -17
  111. data/lib/mml/v4/malignmark.rb +4 -17
  112. data/lib/mml/v4/math.rb +4 -14
  113. data/lib/mml/v4/menclose.rb +4 -18
  114. data/lib/mml/v4/merror.rb +4 -16
  115. data/lib/mml/v4/mfenced.rb +4 -25
  116. data/lib/mml/v4/mfrac.rb +4 -24
  117. data/lib/mml/v4/mfraction.rb +4 -20
  118. data/lib/mml/v4/mglyph.rb +4 -35
  119. data/lib/mml/v4/mi.rb +4 -30
  120. data/lib/mml/v4/mlabeledtr.rb +6 -23
  121. data/lib/mml/v4/mlongdiv.rb +4 -18
  122. data/lib/mml/v4/mmultiscripts.rb +4 -24
  123. data/lib/mml/v4/mn.rb +4 -29
  124. data/lib/mml/v4/mo.rb +4 -75
  125. data/lib/mml/v4/mover.rb +4 -20
  126. data/lib/mml/v4/mpadded.rb +4 -26
  127. data/lib/mml/v4/mphantom.rb +4 -16
  128. data/lib/mml/v4/mprescripts.rb +4 -11
  129. data/lib/mml/v4/mroot.rb +4 -16
  130. data/lib/mml/v4/mrow.rb +4 -20
  131. data/lib/mml/v4/ms.rb +4 -34
  132. data/lib/mml/v4/mscarries.rb +4 -20
  133. data/lib/mml/v4/mscarry.rb +4 -16
  134. data/lib/mml/v4/msgroup.rb +4 -18
  135. data/lib/mml/v4/msline.rb +4 -21
  136. data/lib/mml/v4/mspace.rb +4 -49
  137. data/lib/mml/v4/msqrt.rb +4 -16
  138. data/lib/mml/v4/msrow.rb +4 -18
  139. data/lib/mml/v4/mstack.rb +4 -24
  140. data/lib/mml/v4/mstyle.rb +4 -186
  141. data/lib/mml/v4/msub.rb +4 -18
  142. data/lib/mml/v4/msubsup.rb +4 -20
  143. data/lib/mml/v4/msup.rb +4 -18
  144. data/lib/mml/v4/mtable.rb +4 -55
  145. data/lib/mml/v4/mtd.rb +4 -20
  146. data/lib/mml/v4/mtext.rb +4 -29
  147. data/lib/mml/v4/mtr.rb +4 -25
  148. data/lib/mml/v4/munder.rb +4 -22
  149. data/lib/mml/v4/munderover.rb +4 -22
  150. data/lib/mml/v4/namespace.rb +1 -4
  151. data/lib/mml/v4/none.rb +6 -11
  152. data/lib/mml/v4/semantics.rb +4 -12
  153. data/lib/mml/v4.rb +52 -74
  154. data/lib/mml/version.rb +1 -1
  155. data/lib/mml/versioned_parser.rb +46 -0
  156. data/lib/mml.rb +34 -6
  157. metadata +60 -4
  158. data/lib/mml/v3/common_attributes.rb +0 -22
  159. data/lib/mml/v4/common_attributes.rb +0 -26
data/lib/mml/v3/mtext.rb CHANGED
@@ -3,36 +3,9 @@
3
3
  module Mml
4
4
  module V3
5
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
6
+ include Base::Mtext
7
+ include Base::DeprecatedFontAttributes
36
8
  end
9
+ Configuration.register_model(Mtext, id: :mtext)
37
10
  end
38
11
  end
data/lib/mml/v3/mtr.rb CHANGED
@@ -2,28 +2,9 @@
2
2
 
3
3
  module Mml
4
4
  module V3
5
- autoload(:Mtd, "mml/v3/mtd")
6
-
7
5
  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
6
+ include Base::Mtr
27
7
  end
8
+ Configuration.register_model(Mtr, id: :mtr)
28
9
  end
29
10
  end
data/lib/mml/v3/munder.rb CHANGED
@@ -2,24 +2,9 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Munder < CommonElements
6
+ include Base::Munder
23
7
  end
8
+ Configuration.register_model(Munder, id: :munder)
24
9
  end
25
10
  end
@@ -2,24 +2,9 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Munderover < CommonElements
6
+ include Base::Munderover
23
7
  end
8
+ Configuration.register_model(Munderover, id: :munderover)
24
9
  end
25
10
  end
@@ -2,9 +2,6 @@
2
2
 
3
3
  module Mml
4
4
  module V3
5
- class Namespace < Lutaml::Xml::Namespace
6
- uri "http://www.w3.org/1998/Math/MathML"
7
- prefix_default "mml"
8
- end
5
+ Namespace = Mml::Namespace
9
6
  end
10
7
  end
data/lib/mml/v3/none.rb CHANGED
@@ -3,16 +3,8 @@
3
3
  module Mml
4
4
  module V3
5
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
6
+ include Base::None
16
7
  end
8
+ Configuration.register_model(None, id: :none)
17
9
  end
18
10
  end
@@ -2,18 +2,9 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Semantics < CommonElements
6
+ include Base::Semantics
17
7
  end
8
+ Configuration.register_model(Semantics, id: :semantics)
18
9
  end
19
10
  end
data/lib/mml/v3.rb CHANGED
@@ -1,85 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "lutaml/model"
4
- require "mml/v3/configuration"
5
-
6
- DEFAULT_ADAPTER = :ox
7
-
8
- Moxml::Config.default_adapter = DEFAULT_ADAPTER
4
+ require_relative "versioned_parser"
5
+
6
+ Moxml::Config.default_adapter = Mml::DEFAULT_ADAPTER
7
+
8
+ require_relative "v3/configuration"
9
+ require_relative "v3/namespace"
10
+ require_relative "v3/common_elements"
11
+ require_relative "v3/maction"
12
+ require_relative "v3/maligngroup"
13
+ require_relative "v3/malignmark"
14
+ require_relative "v3/menclose"
15
+ require_relative "v3/merror"
16
+ require_relative "v3/mfenced"
17
+ require_relative "v3/mfrac"
18
+ require_relative "v3/mfraction"
19
+ require_relative "v3/mglyph"
20
+ require_relative "v3/mi"
21
+ require_relative "v3/mlongdiv"
22
+ require_relative "v3/mn"
23
+ require_relative "v3/mo"
24
+ require_relative "v3/mover"
25
+ require_relative "v3/mpadded"
26
+ require_relative "v3/mphantom"
27
+ require_relative "v3/mprescripts"
28
+ require_relative "v3/mroot"
29
+ require_relative "v3/mrow"
30
+ require_relative "v3/ms"
31
+ require_relative "v3/mscarries"
32
+ require_relative "v3/mscarry"
33
+ require_relative "v3/msgroup"
34
+ require_relative "v3/msline"
35
+ require_relative "v3/mspace"
36
+ require_relative "v3/msqrt"
37
+ require_relative "v3/msrow"
38
+ require_relative "v3/mstack"
39
+ require_relative "v3/mstyle"
40
+ require_relative "v3/msub"
41
+ require_relative "v3/msubsup"
42
+ require_relative "v3/msup"
43
+ require_relative "v3/mtd"
44
+ require_relative "v3/mtable"
45
+ require_relative "v3/mtext"
46
+ require_relative "v3/mtr"
47
+ require_relative "v3/mlabeledtr"
48
+ require_relative "v3/munder"
49
+ require_relative "v3/munderover"
50
+ require_relative "v3/mmultiscripts"
51
+ require_relative "v3/none"
52
+ require_relative "v3/semantics"
53
+ require_relative "v3/math"
9
54
 
10
55
  module Mml
11
56
  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
57
+ extend Mml::VersionedParser
82
58
  end
83
59
  end
84
-
85
- Mml::V3.update_attributes
data/lib/mml/v4/a.rb CHANGED
@@ -2,15 +2,11 @@
2
2
 
3
3
  module Mml
4
4
  module V4
5
- class A < Lutaml::Model::Serializable
5
+ class A < CommonElements
6
+ include Base::V4Attributes
7
+
6
8
  attribute :href, :string
7
9
  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
10
 
15
11
  xml do
16
12
  namespace Namespace
@@ -19,13 +15,8 @@ module Mml
19
15
 
20
16
  map_attribute "href", to: :href
21
17
  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
18
  end
29
19
  end
20
+ Configuration.register_model(A, id: :a)
30
21
  end
31
22
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ module V4
5
+ class CommonElements < Mml::CommonElements
6
+ attribute :a_value, :a, collection: true
7
+
8
+ xml do
9
+ map_element "a", to: :a_value
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,106 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../context_configuration"
4
+
3
5
  module Mml
4
6
  module V4
5
7
  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
8
+ extend Mml::ContextConfiguration
100
9
 
101
- def class_for(class_name)
102
- config[class_name]
103
- end
10
+ CONTEXT_ID = :mml_v4
104
11
  end
105
12
  end
106
13
  end
@@ -2,29 +2,14 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Maction < Lutaml::Model::Serializable
6
+ include Base::Maction
7
+ include Base::V4Attributes
14
8
 
15
9
  xml do
16
10
  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
11
  end
28
12
  end
13
+ Configuration.register_model(Maction, id: :maction)
29
14
  end
30
15
  end
@@ -2,27 +2,14 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Maligngroup < Lutaml::Model::Serializable
6
+ include Base::Maligngroup
7
+ include Base::V4Attributes
13
8
 
14
9
  xml do
15
10
  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
11
  end
26
12
  end
13
+ Configuration.register_model(Maligngroup, id: :maligngroup)
27
14
  end
28
15
  end
@@ -2,27 +2,14 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Malignmark < Lutaml::Model::Serializable
6
+ include Base::Malignmark
7
+ include Base::V4Attributes
13
8
 
14
9
  xml do
15
10
  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
11
  end
26
12
  end
13
+ Configuration.register_model(Malignmark, id: :malignmark)
27
14
  end
28
15
  end
data/lib/mml/v4/math.rb CHANGED
@@ -2,26 +2,16 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Math < CommonElements
6
+ include Base::Math
7
+ include Base::V4Attributes
10
8
 
11
9
  xml do
12
10
  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
11
  end
22
12
  end
13
+ Configuration.register_model(Math, id: :math)
23
14
 
24
- # For backward compatibility, we keep MathWithNamespace as an alias to Math.
25
15
  MathWithNamespace = Math
26
16
  end
27
17
  end
@@ -2,28 +2,14 @@
2
2
 
3
3
  module Mml
4
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
5
+ class Menclose < CommonElements
6
+ include Base::Menclose
7
+ include Base::V4Attributes
13
8
 
14
9
  xml do
15
10
  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
11
  end
27
12
  end
13
+ Configuration.register_model(Menclose, id: :menclose)
28
14
  end
29
15
  end
data/lib/mml/v4/merror.rb CHANGED
@@ -2,26 +2,14 @@
2
2
 
3
3
  module Mml
4
4
  module V4
5
- class Merror < Mml::V3::Merror
6
- attribute :mathbackground, :string
7
- attribute :mathcolor, :string
8
- attribute :intent, :string
9
- attribute :arg, :string
10
- attribute :displaystyle, :string
11
- attribute :scriptlevel, :integer
5
+ class Merror < CommonElements
6
+ include Base::Merror
7
+ include Base::V4Attributes
12
8
 
13
9
  xml do
14
10
  namespace Namespace
15
- element "merror"
16
- mixed_content
17
-
18
- map_attribute "mathcolor", to: :mathcolor
19
- map_attribute "mathbackground", to: :mathbackground
20
- map_attribute "intent", to: :intent
21
- map_attribute "arg", to: :arg
22
- map_attribute "displaystyle", to: :displaystyle
23
- map_attribute "scriptlevel", to: :scriptlevel
24
11
  end
25
12
  end
13
+ Configuration.register_model(Merror, id: :merror)
26
14
  end
27
15
  end