mml 2.0.1 → 2.1.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +10 -4
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +12 -9
  5. data/.rubocop_todo.yml +52 -0
  6. data/Gemfile +4 -2
  7. data/README.adoc +313 -4
  8. data/lib/mml/common_attributes.rb +21 -0
  9. data/lib/mml/configuration.rb +33 -2
  10. data/lib/mml/maction.rb +6 -5
  11. data/lib/mml/maligngroup.rb +5 -4
  12. data/lib/mml/malignmark.rb +5 -4
  13. data/lib/mml/math.rb +18 -0
  14. data/lib/mml/menclose.rb +6 -10
  15. data/lib/mml/merror.rb +5 -9
  16. data/lib/mml/mfenced.rb +8 -13
  17. data/lib/mml/mfrac.rb +9 -13
  18. data/lib/mml/mfraction.rb +9 -13
  19. data/lib/mml/mglyph.rb +18 -17
  20. data/lib/mml/mi.rb +13 -12
  21. data/lib/mml/mlabeledtr.rb +11 -7
  22. data/lib/mml/mlongdiv.rb +8 -12
  23. data/lib/mml/mmultiscripts.rb +9 -11
  24. data/lib/mml/mn.rb +13 -12
  25. data/lib/mml/mo.rb +36 -35
  26. data/lib/mml/mover.rb +7 -11
  27. data/lib/mml/mpadded.rb +10 -14
  28. data/lib/mml/mphantom.rb +5 -9
  29. data/lib/mml/mprescripts.rb +4 -3
  30. data/lib/mml/mroot.rb +5 -9
  31. data/lib/mml/mrow.rb +7 -13
  32. data/lib/mml/ms.rb +16 -20
  33. data/lib/mml/mscarries.rb +9 -13
  34. data/lib/mml/mscarry.rb +7 -11
  35. data/lib/mml/msgroup.rb +7 -14
  36. data/lib/mml/msline.rb +9 -8
  37. data/lib/mml/mspace.rb +24 -23
  38. data/lib/mml/msqrt.rb +5 -10
  39. data/lib/mml/msrow.rb +6 -11
  40. data/lib/mml/mstack.rb +9 -13
  41. data/lib/mml/mstyle.rb +99 -103
  42. data/lib/mml/msub.rb +6 -10
  43. data/lib/mml/msubsup.rb +7 -11
  44. data/lib/mml/msup.rb +6 -10
  45. data/lib/mml/mtable.rb +25 -21
  46. data/lib/mml/mtd.rb +7 -11
  47. data/lib/mml/mtext.rb +13 -12
  48. data/lib/mml/mtr.rb +10 -6
  49. data/lib/mml/munder.rb +7 -11
  50. data/lib/mml/munderover.rb +8 -12
  51. data/lib/mml/namespace.rb +9 -0
  52. data/lib/mml/none.rb +4 -3
  53. data/lib/mml/opal_setup.rb.erb +6 -0
  54. data/lib/mml/semantics.rb +6 -8
  55. data/lib/mml/version.rb +1 -1
  56. data/lib/mml.rb +79 -16
  57. data/mml.gemspec +3 -3
  58. metadata +15 -11
  59. data/lib/mml/math_with_namespace.rb +0 -22
  60. data/lib/mml/math_with_nil_namespace.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4edc2cd98bf5ea40cd990bc2f7de88334fda8964d0d50b5c7a3347624276dca6
4
- data.tar.gz: aaec60ab3f027aa98e7f1bc8690551714414f463802cd981c6f724da8c4c8e9a
3
+ metadata.gz: 0edf00bb97f74177c28a416132046bd265a61a8720de3a0a9d1b9515721170db
4
+ data.tar.gz: 9b11f8ecc3869145617584f9afb422ae3ced36db62994f89750483f039e1bb99
5
5
  SHA512:
6
- metadata.gz: d6db4bcf4ae1dd66116a5e6e5a90915f2e03ccf205840752fcf682f693e0078a46a38a89f5fa7178101d2fa0400c4638d3afda8561ecc6cdd7ec04f75b5b7b6f
7
- data.tar.gz: 412834bc7a1872505e480d35c01a58c35cde48eeac5525239d6da2d0622e67597a2735ada95baf0f9fa77c4155c330e8597b98b960282e364d3399a8f5de37d3
6
+ metadata.gz: ce86364277e4aae63f893d64ccbabb3752beb2acb11f634caaab20fb01b2768902180eab714dbcb69ab91fcc183778004dcbbf50fb3da4f976071effc687d293
7
+ data.tar.gz: b3ae2643d010604f0a293fbf35ca7d5ad776055a67b9c90293e4fd7a97a7b8ae70735526c5cd3bf2c96cd2528f3d27048069a481590d6119f7fed7a2d9a365da
@@ -2,20 +2,26 @@
2
2
  # See https://github.com/metanorma/cimas
3
3
  name: release
4
4
 
5
+ permissions:
6
+ contents: write
7
+ packages: write
8
+ id-token: write
9
+
5
10
  on:
6
11
  workflow_dispatch:
7
12
  inputs:
8
13
  next_version:
9
14
  description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
15
+ Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
16
+ Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
11
17
  required: true
12
18
  default: 'skip'
13
- push:
14
- tags: [ v* ]
19
+ repository_dispatch:
20
+ types: [ do-release ]
15
21
 
16
22
  jobs:
17
23
  release:
18
- uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
24
+ uses: relaton/support/.github/workflows/release.yml@main
19
25
  with:
20
26
  next_version: ${{ github.event.inputs.next_version }}
21
27
  secrets:
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
data/.rubocop.yml CHANGED
@@ -1,11 +1,14 @@
1
- AllCops:
2
- TargetRubyVersion: 3.0
3
-
4
- Style/StringLiterals:
5
- EnforcedStyle: double_quotes
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
3
+ - .rubocop_todo.yml
6
4
 
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
5
+ plugins:
6
+ - rubocop-performance
7
+ - rubocop-rake
8
+ - rubocop-rspec
9
9
 
10
- Documentation:
11
- Enabled: false
10
+ AllCops:
11
+ TargetRubyVersion: 3.0
12
+ NewCops: enable
13
+ Exclude:
14
+ - 'vendor/**/*'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,52 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2026-03-26 05:47:46 UTC using RuboCop version 1.86.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
12
+ # SupportedStyles: with_first_argument, with_fixed_indentation
13
+ Layout/ArgumentAlignment:
14
+ Exclude:
15
+ - 'spec/mml_spec.rb'
16
+
17
+ # Offense count: 5
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
20
+ # URISchemes: http, https
21
+ Layout/LineLength:
22
+ Exclude:
23
+ - 'mml.gemspec'
24
+ - 'spec/mml_spec.rb'
25
+ - 'spec/spec_helper.rb'
26
+
27
+ # Offense count: 1
28
+ # This cop supports safe autocorrection (--autocorrect).
29
+ # Configuration parameters: AllowInHeredoc.
30
+ Layout/TrailingWhitespace:
31
+ Exclude:
32
+ - 'spec/mml_spec.rb'
33
+
34
+ # Offense count: 1
35
+ # Configuration parameters: Prefixes, AllowedPatterns.
36
+ # Prefixes: when, with, without
37
+ RSpec/ContextWording:
38
+ Exclude:
39
+ - 'spec/mml_spec.rb'
40
+
41
+ # Offense count: 1
42
+ RSpec/PendingWithoutReason:
43
+ Exclude:
44
+ - 'spec/mml_spec.rb'
45
+
46
+ # Offense count: 1
47
+ # This cop supports safe autocorrection (--autocorrect).
48
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
49
+ # SupportedStyles: single_quotes, double_quotes
50
+ Style/StringLiterals:
51
+ Exclude:
52
+ - 'spec/mml_spec.rb'
data/Gemfile CHANGED
@@ -5,11 +5,13 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
 
8
- gem "equivalent-xml"
8
+ gem "canon"
9
+ gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
9
10
  gem "ox"
10
11
  gem "pry"
11
12
  gem "rake", "~> 12.0"
12
13
  gem "rspec", "~> 3.0"
13
14
  gem "rubocop"
14
15
  gem "rubocop-performance"
15
- gem "rubocop-rails"
16
+ gem "rubocop-rake"
17
+ gem "rubocop-rspec"
data/README.adoc CHANGED
@@ -1,9 +1,318 @@
1
- = Plurimath MathML library
1
+ = Mml: MathML parser and builder
2
+
3
+ :toc:
4
+ :toclevels: 2
2
5
 
3
6
  == Purpose
4
7
 
5
- Mml is the MathML library used by Plurimath.
8
+ Mml provides MathML 3 XML parsing and serialization for Ruby. It maps the full
9
+ MathML element set into Ruby model classes using the
10
+ https://github.com/lutaml/lutaml-model[lutaml-model] framework and is used by
11
+ https://github.com/plurimath/plurimath[Plurimath] for mathematical formula
12
+ representation.
13
+
14
+ Key features:
15
+
16
+ * **MathML 3 element support**: 43 elements including presentation markup,
17
+ tables, scripts, fractions, and more
18
+ * **Namespace handling**: Default `xmlns`, prefixed `mml:`, and namespace-less
19
+ input
20
+ * **Round-trip fidelity**: Parse XML to an object graph, modify, and serialize
21
+ back
22
+ * **Opal support**: Runs in the browser via Ruby-to-JavaScript compilation
23
+
24
+ == Installation
25
+
26
+ Add to your application's Gemfile:
27
+
28
+ [source,ruby]
29
+ ----
30
+ gem 'mml'
31
+ ----
32
+
33
+ Then execute:
34
+
35
+ [source,bash]
36
+ ----
37
+ $ bundle install
38
+ ----
39
+
40
+ Or install directly:
41
+
42
+ [source,bash]
43
+ ----
44
+ $ gem install mml
45
+ ----
46
+
47
+ == Quick start
48
+
49
+ === Parse with a namespace (compliant)
50
+
51
+ `Mml.parse` expects a namespace by default (`namespace_exist: true`). It accepts
52
+ both default and prefixed forms:
53
+
54
+ [source,ruby]
55
+ ----
56
+ require "mml"
57
+
58
+ # Default namespace
59
+ math = Mml.parse('<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>x</mi></math>')
60
+
61
+ # Prefixed namespace
62
+ math = Mml.parse('<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mi>x</mml:mi></mml:math>')
63
+ ----
64
+
65
+ === Parse without namespace (non-compliant)
66
+
67
+ Some XML schemas embed MathML without a namespace declaration, which is
68
+ non-compliant but common in practice. Pass `namespace_exist: false` to handle
69
+ this — the namespace is injected internally before parsing:
70
+
71
+ [source,ruby]
72
+ ----
73
+ math = Mml.parse("<math><mi>x</mi></math>", namespace_exist: false)
74
+ ----
75
+
76
+ === Serialize to XML
77
+
78
+ [source,ruby]
79
+ ----
80
+ # Default namespace (default)
81
+ math.to_xml
82
+ # => "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>x</mi></math>"
83
+
84
+ # Prefixed namespace
85
+ math.to_xml(prefix: true)
86
+ # => "<mml:math xmlns:mml=\"http://www.w3.org/1998/Math/MathML\"><mml:mi>x</mml:mi></mml:math>"
87
+
88
+ # Omit XML declaration
89
+ math.to_xml(declaration: false)
90
+ ----
91
+
92
+ == Building MathML with the API
93
+
94
+ === Leaf elements
95
+
96
+ Leaf elements (`Mi`, `Mn`, `Mo`, `Ms`, `Mtext`) hold text content in the `value`
97
+ attribute:
98
+
99
+ [source,ruby]
100
+ ----
101
+ # An identifier: <mi>x</mi>
102
+ Mml::Mi.new(value: "x")
103
+
104
+ # A number: <mn>42</mn>
105
+ Mml::Mn.new(value: "42")
106
+
107
+ # An operator: <mo>+</mo>
108
+ Mml::Mo.new(value: "+")
109
+
110
+ # With attributes: <mi mathvariant="bold">x</mi>
111
+ Mml::Mi.new(value: "x", mathvariant: "bold")
112
+ ----
113
+
114
+ === Container elements
115
+
116
+ Container elements hold child elements via collection attributes named
117
+ `#{tag}_value`. The supported child types come from the `CommonAttributes` model
118
+ mixed into container classes.
119
+
120
+ [source,ruby]
121
+ ----
122
+ # <mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow>
123
+ Mml::Mrow.new(
124
+ mi_value: [Mml::Mi.new(value: "x")],
125
+ mo_value: [Mml::Mo.new(value: "+")],
126
+ mn_value: [Mml::Mn.new(value: "1")],
127
+ )
128
+ ----
129
+
130
+ === Composing complex expressions
131
+
132
+ Build an expression tree by nesting elements, then wrap in `Mml::Math`:
133
+
134
+ [source,ruby]
135
+ ----
136
+ # <math xmlns="http://www.w3.org/1998/Math/MathML">
137
+ # <mfrac><mi>a</mi><mi>b</mi></mfrac>
138
+ # </math>
139
+ math = Mml::Math.new(
140
+ mfrac_value: [
141
+ Mml::Mfrac.new(
142
+ mi_value: [Mml::Mi.new(value: "a"), Mml::Mi.new(value: "b")],
143
+ ),
144
+ ],
145
+ )
146
+
147
+ math.to_xml
148
+ ----
149
+
150
+ === Fractions, subscripts, and superscripts
151
+
152
+ [source,ruby]
153
+ ----
154
+ # <msup><mi>x</mi><mn>2</mn></msup> — x²
155
+ Mml::Msup.new(mi_value: [Mml::Mi.new(value: "x")],
156
+ mn_value: [Mml::Mn.new(value: "2")])
157
+
158
+ # <msub><mi>a</mi><mn>1</mn></msup> — a₁
159
+ Mml::Msub.new(mi_value: [Mml::Mi.new(value: "a")],
160
+ mn_value: [Mml::Mn.new(value: "1")])
161
+
162
+ # <msubsup><mi>b</mi><mn>1</mn><mn>2</mn></msubsup> — b₁²
163
+ Mml::Msubsup.new(mi_value: [Mml::Mi.new(value: "b")],
164
+ mn_value: [Mml::Mn.new(value: "1"),
165
+ Mml::Mn.new(value: "2")])
166
+
167
+ # <mfrac linethickness="0"><mi>a</mi><mi>b</mi></mfrac> — a/b
168
+ Mml::Mfrac.new(
169
+ linethickness: "0",
170
+ mi_value: [Mml::Mi.new(value: "a"), Mml::Mi.new(value: "b")],
171
+ )
172
+ ----
173
+
174
+ === Tables
175
+
176
+ `Mtable` uses typed `mtr_value` and `mlabeledtr_value` attributes for its rows:
177
+
178
+ [source,ruby]
179
+ ----
180
+ # <mtable>
181
+ # <mtr><mtd><mi>a</mi></mtd><mtd><mi>b</mi></mtd></mtr>
182
+ # </mtable>
183
+ Mml::Mtable.new(
184
+ mtr_value: [
185
+ Mml::Mtr.new(
186
+ mtd_value: [
187
+ Mml::Mtd.new(mi_value: [Mml::Mi.new(value: "a")]),
188
+ Mml::Mtd.new(mi_value: [Mml::Mi.new(value: "b")]),
189
+ ],
190
+ ),
191
+ ],
192
+ )
193
+ ----
194
+
195
+ === Parsing, modifying, and re-serializing
196
+
197
+ The object graph is fully mutable — parse, modify attributes or children, then
198
+ serialize back:
199
+
200
+ [source,ruby]
201
+ ----
202
+ math = Mml.parse('<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>x</mi></math>')
203
+
204
+ # Modify the root element's display attribute
205
+ math.display = "block"
206
+
207
+ # Serialize with the changes
208
+ math.to_xml
209
+ # => "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\">...</math>"
210
+ ----
211
+
212
+ == Architecture
213
+
214
+ Mml follows a data mapper pattern where each MathML element is a Ruby class
215
+ under the `Mml::` namespace, inheriting from `Lutaml::Model::Serializable`.
216
+
217
+ === Element classes
218
+
219
+ Two element patterns:
220
+
221
+ * *Leaf elements* (`Mi`, `Mn`, `Mo`, `Ms`, `Mtext`, `Mspace`): hold text content
222
+ via `map_content to: :value`
223
+ * *Container elements* (`Math`, `Mrow`, `Mfrac`, `Mtable`, `Msubsup`): hold
224
+ child elements via `mixed_content`
225
+
226
+ [source,ruby]
227
+ ----
228
+ # Leaf element — text content
229
+ module Mml
230
+ class Mi < Lutaml::Model::Serializable
231
+ attribute :value, :string
232
+
233
+ xml do
234
+ namespace Namespace
235
+ element "mi"
236
+ map_content to: :value
237
+ end
238
+ end
239
+ end
240
+
241
+ # Container element — child elements
242
+ module Mml
243
+ class Mrow < Lutaml::Model::Serializable
244
+ xml do
245
+ namespace Namespace
246
+ element "mrow"
247
+ mixed_content
248
+ end
249
+ end
250
+ end
251
+ ----
252
+
253
+ === CommonAttributes
254
+
255
+ Container elements that can hold arbitrary MathML children use a shared
256
+ `CommonAttributes` model.
257
+
258
+ The classes that receive it are listed in
259
+ `Configuration::COMMON_ATTRIBUTES_CLASSES`.
260
+
261
+ === Namespace
262
+
263
+ All elements declare `namespace Namespace` using the MathML namespace URI
264
+ (`http://www.w3.org/1998/Math/MathML`) with prefix `mml`. The `Mml.parse`
265
+ method handles three input forms:
266
+
267
+ * Default namespace: `<math xmlns="http://www.w3.org/1998/Math/MathML">`
268
+ * Prefixed: `<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">`
269
+ * No namespace: handled by injecting the namespace before parsing
270
+
271
+ === Configuration
272
+
273
+ [source,ruby]
274
+ ----
275
+ # Switch XML adapter
276
+ Mml::Configuration.adapter = :nokogiri
277
+
278
+ # Register custom model replacements
279
+ Mml::Configuration.custom_models = { Mi => MyCustomMi }
280
+ ----
281
+
282
+ == Supported elements
283
+
284
+ Mml supports the following MathML 3 presentation elements:
285
+
286
+ `math`, `mi`, `mn`, `mo`, `ms`, `mtext`, `mspace`, `mglyph`
287
+ `mrow`, `mfrac`, `msqrt`, `mroot`, `mstyle`, `merror`, `mpadded`,
288
+ `mphantom`, `mfenced`, `menclose`, `maction`
289
+ `msub`, `msup`, `msubsup`, `munder`, `mover`, `munderover`,
290
+ `mmultiscripts`, `mprescripts`
291
+ `mtable`, `mtr`, `mtd`, `mlabeledtr`
292
+ `mstack`, `msrow`, `mscarries`, `mscarry`, `msline`, `msgroup`, `mlongdiv`
293
+ `mfraction`, `semantics`, `none`
294
+
295
+ == Development
296
+
297
+ After checking out the repo, run `bin/setup` to install dependencies. Then run
298
+ `rake` to run the tests and linter. You can also run `bin/console` for an
299
+ interactive prompt.
300
+
301
+ [source,bash]
302
+ ----
303
+ rake # Run specs + rubocop
304
+ bundle exec rspec # Run tests
305
+ bundle exec rubocop # Lint
306
+ bin/console # Interactive IRB
307
+ ----
308
+
309
+ == Contributing
310
+
311
+ Bug reports and pull requests are welcome on GitHub at
312
+ https://github.com/plurimath/mml.
313
+
314
+ == Copyright and license
6
315
 
7
- == Copyright and License
316
+ Copyright Ribose Inc.
8
317
 
9
- Copyright (c) 2024 Ribose Inc.
318
+ https://opensource.org/licenses/BSD-2-Clause[BSD-2-Clause License].
@@ -0,0 +1,21 @@
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
+ Mml::Configuration::SUPPORTED_TAGS.each do |tag|
17
+ map_element tag, to: :"#{tag}_value"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mml
4
4
  module Configuration
5
- SUPPORTED_TAGS = %w[
5
+ SUPPORTED_TAGS = %i[
6
6
  mmultiscripts
7
7
  maligngroup
8
8
  malignmark
@@ -42,6 +42,37 @@ module Mml
42
42
  ms
43
43
  ].freeze
44
44
 
45
+ COMMON_ATTRIBUTES_CLASSES = %w[
46
+ Math
47
+ Mmultiscripts
48
+ Munderover
49
+ Semantics
50
+ Mscarries
51
+ Mfraction
52
+ Mlongdiv
53
+ Mphantom
54
+ Menclose
55
+ Mfenced
56
+ Mpadded
57
+ Msubsup
58
+ Msgroup
59
+ Mscarry
60
+ Munder
61
+ Mstyle
62
+ Mstack
63
+ Merror
64
+ Mover
65
+ Mfrac
66
+ Msrow
67
+ Mroot
68
+ Msqrt
69
+ Mrow
70
+ Msub
71
+ Msup
72
+ Mtd
73
+ Ms
74
+ ].freeze
75
+
45
76
  module_function
46
77
 
47
78
  def config
@@ -62,7 +93,7 @@ module Mml
62
93
  end
63
94
 
64
95
  def adapter=(adapter)
65
- Lutaml::Model::Config.xml_adapter_type = adapter.downcase
96
+ Lutaml::Model::Config.xml_adapter_type = adapter
66
97
  end
67
98
 
68
99
  def class_for(class_name)
data/lib/mml/maction.rb CHANGED
@@ -8,12 +8,13 @@ module Mml
8
8
  attribute :selection, :string
9
9
 
10
10
  xml do
11
- root "maction"
11
+ namespace Namespace
12
+ element "maction"
12
13
 
13
- map_attribute "mathcolor", to: :mathcolor, namespace: nil
14
- map_attribute "mathbackground", to: :mathbackground, namespace: nil
15
- map_attribute "actiontype", to: :actiontype, namespace: nil
16
- map_attribute "selection", to: :selection, namespace: nil
14
+ map_attribute "mathcolor", to: :mathcolor
15
+ map_attribute "mathbackground", to: :mathbackground
16
+ map_attribute "actiontype", to: :actiontype
17
+ map_attribute "selection", to: :selection
17
18
  end
18
19
  end
19
20
  end
@@ -7,11 +7,12 @@ module Mml
7
7
  attribute :groupalign, :string
8
8
 
9
9
  xml do
10
- root "maligngroup"
10
+ namespace Namespace
11
+ element "maligngroup"
11
12
 
12
- map_attribute "mathcolor", to: :mathcolor, namespace: nil
13
- map_attribute "mathbackground", to: :mathbackground, namespace: nil
14
- map_attribute "groupalign", to: :groupalign, namespace: nil
13
+ map_attribute "mathcolor", to: :mathcolor
14
+ map_attribute "mathbackground", to: :mathbackground
15
+ map_attribute "groupalign", to: :groupalign
15
16
  end
16
17
  end
17
18
  end
@@ -7,11 +7,12 @@ module Mml
7
7
  attribute :edge, :string
8
8
 
9
9
  xml do
10
- root "malignmark"
10
+ namespace Namespace
11
+ element "malignmark"
11
12
 
12
- map_attribute "mathcolor", to: :mathcolor, namespace: nil
13
- map_attribute "mathbackground", to: :mathbackground, namespace: nil
14
- map_attribute "edge", to: :edge, namespace: nil
13
+ map_attribute "mathcolor", to: :mathcolor
14
+ map_attribute "mathbackground", to: :mathbackground
15
+ map_attribute "edge", to: :edge
15
16
  end
16
17
  end
17
18
  end
data/lib/mml/math.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mml
4
+ class Math < Lutaml::Model::Serializable
5
+ attribute :display, :string
6
+
7
+ xml do
8
+ namespace Namespace
9
+ element "math"
10
+ mixed_content
11
+
12
+ map_attribute :display, to: :display
13
+ end
14
+ end
15
+
16
+ # For backward compatibility, we keep MathWithNamespace as an alias to Math.
17
+ MathWithNamespace = Math
18
+ end
data/lib/mml/menclose.rb CHANGED
@@ -5,19 +5,15 @@ module Mml
5
5
  attribute :mathcolor, :string
6
6
  attribute :mathbackground, :string
7
7
  attribute :notation, :string
8
- Mml::Configuration::SUPPORTED_TAGS.each do |tag|
9
- attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true
10
- end
11
8
 
12
9
  xml do
13
- root "menclose", mixed: true
10
+ namespace Namespace
11
+ element "menclose"
12
+ mixed_content
14
13
 
15
- map_attribute "mathcolor", to: :mathcolor, namespace: nil
16
- map_attribute "mathbackground", to: :mathbackground, namespace: nil
17
- map_attribute "notation", to: :notation, namespace: nil
18
- Mml::Configuration::SUPPORTED_TAGS.each do |tag|
19
- map_element tag.to_sym, to: :"#{tag}_value"
20
- end
14
+ map_attribute "mathcolor", to: :mathcolor
15
+ map_attribute "mathbackground", to: :mathbackground
16
+ map_attribute "notation", to: :notation
21
17
  end
22
18
  end
23
19
  end
data/lib/mml/merror.rb CHANGED
@@ -4,18 +4,14 @@ module Mml
4
4
  class Merror < Lutaml::Model::Serializable
5
5
  attribute :mathbackground, :string
6
6
  attribute :mathcolor, :string
7
- Mml::Configuration::SUPPORTED_TAGS.each do |tag|
8
- attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true
9
- end
10
7
 
11
8
  xml do
12
- root "merror", mixed: true
9
+ namespace Namespace
10
+ element "merror"
11
+ mixed_content
13
12
 
14
- map_attribute "mathcolor", to: :mathcolor, namespace: nil
15
- map_attribute "mathbackground", to: :mathbackground, namespace: nil
16
- Mml::Configuration::SUPPORTED_TAGS.each do |tag|
17
- map_element tag.to_sym, to: :"#{tag}_value"
18
- end
13
+ map_attribute "mathcolor", to: :mathcolor
14
+ map_attribute "mathbackground", to: :mathbackground
19
15
  end
20
16
  end
21
17
  end