mml 2.3.7 → 2.4.1

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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/CLAUDE.md +96 -30
  3. data/TODO.complete/1-v3-autoload.md +63 -0
  4. data/TODO.complete/2-v2-autoload.md +46 -0
  5. data/TODO.complete/3-no-require-relative.md +32 -0
  6. data/TODO.complete/4-remove-duplicate-register-model.md +31 -0
  7. data/TODO.complete/5-context-options-type-check.md +44 -0
  8. data/TODO.complete/6-context-configuration-type-check.md +32 -0
  9. data/TODO.complete/7-specs-for-refactor.md +38 -0
  10. data/lib/mml/base/maction.rb +1 -1
  11. data/lib/mml/base/math.rb +1 -1
  12. data/lib/mml/base/menclose.rb +1 -1
  13. data/lib/mml/base/merror.rb +1 -1
  14. data/lib/mml/base/mfenced.rb +1 -4
  15. data/lib/mml/base/mfrac.rb +1 -1
  16. data/lib/mml/base/mfraction.rb +1 -1
  17. data/lib/mml/base/mi.rb +2 -0
  18. data/lib/mml/base/mlabeledtr.rb +1 -1
  19. data/lib/mml/base/mlongdiv.rb +1 -1
  20. data/lib/mml/base/mmultiscripts.rb +1 -1
  21. data/lib/mml/base/mn.rb +2 -0
  22. data/lib/mml/base/mo.rb +6 -1
  23. data/lib/mml/base/mover.rb +1 -1
  24. data/lib/mml/base/mpadded.rb +1 -1
  25. data/lib/mml/base/mphantom.rb +1 -1
  26. data/lib/mml/base/mroot.rb +1 -1
  27. data/lib/mml/base/mrow.rb +1 -3
  28. data/lib/mml/base/ms.rb +4 -0
  29. data/lib/mml/base/mscarries.rb +1 -1
  30. data/lib/mml/base/mscarry.rb +1 -1
  31. data/lib/mml/base/msgroup.rb +1 -3
  32. data/lib/mml/base/msqrt.rb +1 -1
  33. data/lib/mml/base/msrow.rb +1 -1
  34. data/lib/mml/base/mstack.rb +1 -1
  35. data/lib/mml/base/mstyle.rb +1 -1
  36. data/lib/mml/base/msub.rb +1 -1
  37. data/lib/mml/base/msubsup.rb +1 -1
  38. data/lib/mml/base/msup.rb +1 -1
  39. data/lib/mml/base/mtable.rb +1 -1
  40. data/lib/mml/base/mtd.rb +1 -1
  41. data/lib/mml/base/mtext.rb +6 -1
  42. data/lib/mml/base/mtr.rb +1 -1
  43. data/lib/mml/base/munder.rb +1 -3
  44. data/lib/mml/base/munderover.rb +1 -1
  45. data/lib/mml/base/semantics.rb +1 -1
  46. data/lib/mml/context_configuration.rb +3 -1
  47. data/lib/mml/context_options.rb +10 -1
  48. data/lib/mml/v2/configuration.rb +0 -2
  49. data/lib/mml/v2.rb +382 -246
  50. data/lib/mml/v3/annotation.rb +0 -1
  51. data/lib/mml/v3/annotation_xml.rb +0 -1
  52. data/lib/mml/v3/apply.rb +0 -1
  53. data/lib/mml/v3/arith.rb +0 -22
  54. data/lib/mml/v3/bind.rb +0 -1
  55. data/lib/mml/v3/calculus.rb +0 -7
  56. data/lib/mml/v3/cbytes.rb +0 -1
  57. data/lib/mml/v3/cerror.rb +0 -1
  58. data/lib/mml/v3/ci.rb +0 -1
  59. data/lib/mml/v3/cn.rb +0 -1
  60. data/lib/mml/v3/configuration.rb +0 -2
  61. data/lib/mml/v3/constants.rb +0 -15
  62. data/lib/mml/v3/constructs.rb +0 -10
  63. data/lib/mml/v3/cs.rb +0 -1
  64. data/lib/mml/v3/csymbol.rb +0 -1
  65. data/lib/mml/v3/deprecated_content.rb +0 -7
  66. data/lib/mml/v3/elementary_functions.rb +0 -28
  67. data/lib/mml/v3/functions.rb +0 -6
  68. data/lib/mml/v3/linear_algebra.rb +0 -9
  69. data/lib/mml/v3/logic.rb +0 -7
  70. data/lib/mml/v3/maction.rb +0 -1
  71. data/lib/mml/v3/maligngroup.rb +0 -1
  72. data/lib/mml/v3/malignmark.rb +0 -1
  73. data/lib/mml/v3/math.rb +0 -2
  74. data/lib/mml/v3/menclose.rb +0 -1
  75. data/lib/mml/v3/merror.rb +0 -1
  76. data/lib/mml/v3/mfenced.rb +0 -1
  77. data/lib/mml/v3/mfrac.rb +0 -1
  78. data/lib/mml/v3/mfraction.rb +0 -1
  79. data/lib/mml/v3/mglyph.rb +0 -1
  80. data/lib/mml/v3/mi.rb +0 -1
  81. data/lib/mml/v3/mlabeledtr.rb +0 -1
  82. data/lib/mml/v3/mlongdiv.rb +0 -1
  83. data/lib/mml/v3/mmultiscripts.rb +0 -1
  84. data/lib/mml/v3/mn.rb +0 -1
  85. data/lib/mml/v3/mo.rb +0 -1
  86. data/lib/mml/v3/mover.rb +0 -1
  87. data/lib/mml/v3/mpadded.rb +0 -1
  88. data/lib/mml/v3/mphantom.rb +0 -1
  89. data/lib/mml/v3/mprescripts.rb +0 -1
  90. data/lib/mml/v3/mroot.rb +0 -1
  91. data/lib/mml/v3/mrow.rb +0 -1
  92. data/lib/mml/v3/ms.rb +0 -1
  93. data/lib/mml/v3/mscarries.rb +0 -1
  94. data/lib/mml/v3/mscarry.rb +0 -1
  95. data/lib/mml/v3/msgroup.rb +0 -1
  96. data/lib/mml/v3/msline.rb +0 -1
  97. data/lib/mml/v3/mspace.rb +0 -1
  98. data/lib/mml/v3/msqrt.rb +0 -1
  99. data/lib/mml/v3/msrow.rb +0 -1
  100. data/lib/mml/v3/mstack.rb +0 -1
  101. data/lib/mml/v3/mstyle.rb +0 -1
  102. data/lib/mml/v3/msub.rb +0 -1
  103. data/lib/mml/v3/msubsup.rb +0 -1
  104. data/lib/mml/v3/msup.rb +0 -1
  105. data/lib/mml/v3/mtable.rb +0 -1
  106. data/lib/mml/v3/mtd.rb +0 -1
  107. data/lib/mml/v3/mtext.rb +0 -1
  108. data/lib/mml/v3/mtr.rb +0 -1
  109. data/lib/mml/v3/munder.rb +0 -1
  110. data/lib/mml/v3/munderover.rb +0 -1
  111. data/lib/mml/v3/none.rb +0 -1
  112. data/lib/mml/v3/relations.rb +0 -9
  113. data/lib/mml/v3/semantics.rb +0 -1
  114. data/lib/mml/v3/sets.rb +0 -13
  115. data/lib/mml/v3/statistics.rb +0 -7
  116. data/lib/mml/v3/vector_calculus.rb +0 -4
  117. data/lib/mml/v3.rb +451 -73
  118. data/lib/mml/v4/annotation.rb +0 -1
  119. data/lib/mml/v4/configuration.rb +0 -2
  120. data/lib/mml/v4/elementary_functions.rb +0 -1
  121. data/lib/mml/v4/functions.rb +0 -1
  122. data/lib/mml/v4.rb +21 -17
  123. data/lib/mml/version.rb +1 -1
  124. data/lib/mml.rb +2 -0
  125. metadata +9 -2
data/lib/mml/base/mo.rb CHANGED
@@ -7,7 +7,7 @@ module Mml
7
7
  # Use fully qualified names (e.g., Mml::Namespace).
8
8
  def self.included(klass)
9
9
  klass.class_eval do
10
- attribute :value, :string
10
+ attribute :value, :string, collection: true
11
11
  attribute :mathcolor, :string
12
12
  attribute :mathbackground, :string
13
13
  attribute :mathvariant, :string
@@ -34,11 +34,14 @@ module Mml
34
34
  attribute :indentshiftfirst, :string
35
35
  attribute :indentalignlast, :string
36
36
  attribute :indentshiftlast, :string
37
+ attribute :mglyph_value, :mglyph, collection: true
38
+ attribute :malignmark_value, :malignmark, collection: true
37
39
 
38
40
  # rubocop:disable Metrics/BlockLength
39
41
  xml do
40
42
  namespace Mml::Namespace
41
43
  element "mo"
44
+ mixed_content
42
45
 
43
46
  map_content to: :value
44
47
  map_attribute "form", to: :form
@@ -67,6 +70,8 @@ module Mml
67
70
  map_attribute "indentalignfirst", to: :indentalignfirst
68
71
  map_attribute "indentshiftfirst", to: :indentshiftfirst
69
72
  map_attribute "linebreakmultchar", to: :linebreakmultchar
73
+ map_element "mglyph", to: :mglyph_value
74
+ map_element "malignmark", to: :malignmark_value
70
75
  end
71
76
  # rubocop:enable Metrics/BlockLength
72
77
  end
@@ -15,7 +15,7 @@ module Mml
15
15
  xml do
16
16
  namespace Mml::Namespace
17
17
  element "mover"
18
- mixed_content
18
+ ordered
19
19
 
20
20
  map_attribute "mathbackground", to: :mathbackground
21
21
  map_attribute "mathcolor", to: :mathcolor
@@ -19,7 +19,7 @@ module Mml
19
19
  xml do
20
20
  namespace Mml::Namespace
21
21
  element "mpadded"
22
- mixed_content
22
+ ordered
23
23
 
24
24
  map_attribute "mathbackground", to: :mathbackground
25
25
  map_attribute "mathcolor", to: :mathcolor
@@ -13,7 +13,7 @@ module Mml
13
13
  xml do
14
14
  namespace Mml::Namespace
15
15
  element "mphantom"
16
- mixed_content
16
+ ordered
17
17
 
18
18
  map_attribute "mathcolor", to: :mathcolor
19
19
  map_attribute "mathbackground", to: :mathbackground
@@ -13,7 +13,7 @@ module Mml
13
13
  xml do
14
14
  namespace Mml::Namespace
15
15
  element "mroot"
16
- mixed_content
16
+ ordered
17
17
 
18
18
  map_attribute "mathcolor", to: :mathcolor
19
19
  map_attribute "mathbackground", to: :mathbackground
data/lib/mml/base/mrow.rb CHANGED
@@ -9,13 +9,11 @@ module Mml
9
9
  klass.class_eval do
10
10
  attribute :mathbackground, :string
11
11
  attribute :mathcolor, :string
12
- attribute :content, :string, collection: true
13
12
  xml do
14
13
  namespace Mml::Namespace
15
14
  element "mrow"
16
- mixed_content
15
+ ordered
17
16
 
18
- map_content to: :content
19
17
  map_attribute "mathcolor", to: :mathcolor
20
18
  map_attribute "mathbackground", to: :mathbackground
21
19
  end
data/lib/mml/base/ms.rb CHANGED
@@ -14,6 +14,8 @@ module Mml
14
14
  attribute :lquote, :string
15
15
  attribute :rquote, :string
16
16
  attribute :value, :string, collection: true
17
+ attribute :mglyph_value, :mglyph, collection: true
18
+ attribute :malignmark_value, :malignmark, collection: true
17
19
  xml do
18
20
  namespace Mml::Namespace
19
21
  element "ms"
@@ -26,6 +28,8 @@ module Mml
26
28
  map_attribute "mathvariant", to: :mathvariant
27
29
  map_attribute "lquote", to: :lquote, render_empty: true
28
30
  map_attribute "rquote", to: :rquote, render_empty: true
31
+ map_element "mglyph", to: :mglyph_value
32
+ map_element "malignmark", to: :malignmark_value
29
33
  end
30
34
  end
31
35
  end
@@ -17,7 +17,7 @@ module Mml
17
17
  xml do
18
18
  namespace Mml::Namespace
19
19
  element "mscarries"
20
- mixed_content
20
+ ordered
21
21
 
22
22
  map_attribute "scriptsizemultiplier", to: :scriptsizemultiplier
23
23
  map_attribute "mathbackground", to: :mathbackground
@@ -15,7 +15,7 @@ module Mml
15
15
  xml do
16
16
  namespace Mml::Namespace
17
17
  element "mscarry"
18
- mixed_content
18
+ ordered
19
19
 
20
20
  map_attribute "mathcolor", to: :mathcolor
21
21
  map_attribute "mathbackground", to: :mathbackground
@@ -11,13 +11,11 @@ module Mml
11
11
  attribute :mathbackground, :string
12
12
  attribute :position, :integer
13
13
  attribute :shift, :integer
14
- attribute :msgroup_text, :string, collection: true
15
14
  xml do
16
15
  namespace Mml::Namespace
17
16
  element "msgroup"
18
- mixed_content
17
+ ordered
19
18
 
20
- map_content to: :msgroup_text
21
19
  map_attribute "mathcolor", to: :mathcolor
22
20
  map_attribute "mathbackground", to: :mathbackground
23
21
  map_attribute "position", to: :position
@@ -13,7 +13,7 @@ module Mml
13
13
  xml do
14
14
  namespace Mml::Namespace
15
15
  element "msqrt"
16
- mixed_content
16
+ ordered
17
17
 
18
18
  map_attribute "mathcolor", to: :mathcolor
19
19
  map_attribute "mathbackground", to: :mathbackground
@@ -14,7 +14,7 @@ module Mml
14
14
  xml do
15
15
  namespace Mml::Namespace
16
16
  element "msrow"
17
- mixed_content
17
+ ordered
18
18
 
19
19
  map_attribute "mathcolor", to: :mathcolor
20
20
  map_attribute "mathbackground", to: :mathbackground
@@ -17,7 +17,7 @@ module Mml
17
17
  xml do
18
18
  namespace Mml::Namespace
19
19
  element "mstack"
20
- mixed_content
20
+ ordered
21
21
 
22
22
  map_attribute "mathcolor", to: :mathcolor
23
23
  map_attribute "mathbackground", to: :mathbackground
@@ -94,7 +94,7 @@ module Mml
94
94
  xml do
95
95
  namespace Mml::Namespace
96
96
  element "mstyle"
97
- mixed_content
97
+ ordered
98
98
 
99
99
  map_attribute "scriptsizemultiplier", to: :scriptsizemultiplier
100
100
  map_attribute "scriptminsize", to: :scriptminsize
data/lib/mml/base/msub.rb CHANGED
@@ -14,7 +14,7 @@ module Mml
14
14
  xml do
15
15
  namespace Mml::Namespace
16
16
  element "msub"
17
- mixed_content
17
+ ordered
18
18
 
19
19
  map_attribute "mathbackground", to: :mathbackground
20
20
  map_attribute "subscriptshift", to: :subscriptshift
@@ -15,7 +15,7 @@ module Mml
15
15
  xml do
16
16
  namespace Mml::Namespace
17
17
  element "msubsup"
18
- mixed_content
18
+ ordered
19
19
 
20
20
  map_attribute "mathcolor", to: :mathcolor
21
21
  map_attribute "mathbackground", to: :mathbackground
data/lib/mml/base/msup.rb CHANGED
@@ -14,7 +14,7 @@ module Mml
14
14
  xml do
15
15
  namespace Mml::Namespace
16
16
  element "msup"
17
- mixed_content
17
+ ordered
18
18
 
19
19
  map_attribute "mathcolor", to: :mathcolor
20
20
  map_attribute "mathbackground", to: :mathbackground
@@ -33,7 +33,7 @@ module Mml
33
33
  xml do
34
34
  namespace Mml::Namespace
35
35
  element "mtable"
36
- mixed_content
36
+ ordered
37
37
 
38
38
  map_attribute "mathcolor", to: :mathcolor
39
39
  map_attribute "mathbackground", to: :mathbackground
data/lib/mml/base/mtd.rb CHANGED
@@ -18,7 +18,7 @@ module Mml
18
18
  xml do
19
19
  namespace Mml::Namespace
20
20
  element "mtd"
21
- mixed_content
21
+ ordered
22
22
 
23
23
  map_attribute "mathcolor", to: :mathcolor
24
24
  map_attribute "mathbackground", to: :mathbackground
@@ -7,21 +7,26 @@ module Mml
7
7
  # Use fully qualified names (e.g., Mml::Namespace).
8
8
  def self.included(klass)
9
9
  klass.class_eval do
10
- attribute :value, :string
10
+ attribute :value, :string, collection: true
11
11
  attribute :mathcolor, :string
12
12
  attribute :mathbackground, :string
13
13
  attribute :mathvariant, :string
14
14
  attribute :mathsize, :string
15
+ attribute :mglyph_value, :mglyph, collection: true
16
+ attribute :malignmark_value, :malignmark, collection: true
15
17
 
16
18
  xml do
17
19
  namespace Mml::Namespace
18
20
  element "mtext"
21
+ mixed_content
19
22
 
20
23
  map_content to: :value
21
24
  map_attribute "mathcolor", to: :mathcolor
22
25
  map_attribute "mathbackground", to: :mathbackground
23
26
  map_attribute "mathvariant", to: :mathvariant
24
27
  map_attribute "mathsize", to: :mathsize
28
+ map_element "mglyph", to: :mglyph_value
29
+ map_element "malignmark", to: :malignmark_value
25
30
  end
26
31
  end
27
32
  end
data/lib/mml/base/mtr.rb CHANGED
@@ -18,7 +18,7 @@ module Mml
18
18
  xml do
19
19
  namespace Mml::Namespace
20
20
  element "mtr"
21
- mixed_content
21
+ ordered
22
22
 
23
23
  map_attribute "mathcolor", to: :mathcolor
24
24
  map_attribute "mathbackground", to: :mathbackground
@@ -10,19 +10,17 @@ module Mml
10
10
  attribute :mathbackground, :string
11
11
  attribute :accentunder, :string
12
12
  attribute :mathcolor, :string
13
- attribute :content, :string, collection: true
14
13
  attribute :align, :string
15
14
 
16
15
  xml do
17
16
  namespace Mml::Namespace
18
17
  element "munder"
19
- mixed_content
18
+ ordered
20
19
 
21
20
  map_attribute "mathbackground", to: :mathbackground
22
21
  map_attribute "accentunder", to: :accentunder
23
22
  map_attribute "mathcolor", to: :mathcolor
24
23
  map_attribute "align", to: :align
25
- map_content to: :content
26
24
  end
27
25
  end
28
26
  end
@@ -16,7 +16,7 @@ module Mml
16
16
  xml do
17
17
  namespace Mml::Namespace
18
18
  element "munderover"
19
- mixed_content
19
+ ordered
20
20
 
21
21
  map_attribute "mathcolor", to: :mathcolor
22
22
  map_attribute "mathbackground", to: :mathbackground
@@ -13,7 +13,7 @@ module Mml
13
13
  xml do
14
14
  namespace Mml::Namespace
15
15
  element "semantics"
16
- mixed_content
16
+ ordered
17
17
 
18
18
  map_attribute "definitionURL", to: :definition_url
19
19
  map_attribute "encoding", to: :semantics_encoding
@@ -141,7 +141,9 @@ module Mml
141
141
  end
142
142
 
143
143
  def clear_cache(klass)
144
- klass.clear_cache(context_id) if klass.respond_to?(:clear_cache)
144
+ return unless klass.is_a?(Class) && (klass <= Lutaml::Model::Serialize)
145
+
146
+ klass.clear_cache(context_id)
145
147
  end
146
148
  end
147
149
  end
@@ -31,7 +31,7 @@ module Mml
31
31
  return nil if reference.nil?
32
32
  return reference if reference.is_a?(Symbol)
33
33
  return reference.to_sym if reference.is_a?(String)
34
- return reference.id.to_sym if reference.respond_to?(:id)
34
+ return reference.id.to_sym if lutaml_context_reference?(reference)
35
35
 
36
36
  raise ArgumentError,
37
37
  "Unsupported context/register reference: #{reference.inspect}"
@@ -48,6 +48,15 @@ module Mml
48
48
  !context.equal?(Mml::UNSPECIFIED_CONTEXT)
49
49
  end
50
50
 
51
+ # Lutaml::Model exposes context identity through both TypeContext (returned
52
+ # by GlobalContext.context) and Register (the public registration handle).
53
+ # Both classes expose `attr_reader :id`. We accept either by explicit type
54
+ # check rather than `respond_to?` duck-typing so the contract is verifiable.
55
+ def lutaml_context_reference?(reference)
56
+ reference.is_a?(Lutaml::Model::TypeContext) ||
57
+ reference.is_a?(Lutaml::Model::Register)
58
+ end
59
+
51
60
  # MML accepts the old `register:` alias, but never both inputs at once.
52
61
  def raise_if_conflicting_context_options!(context, register)
53
62
  return unless context_specified?(context) && register
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../context_configuration"
4
-
5
3
  module Mml
6
4
  module V2
7
5
  module Configuration