mml 2.3.3 → 2.3.4
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/.rubocop_todo.yml +2 -35
- data/lib/mml/v2.rb +0 -2
- data/lib/mml/v3.rb +0 -2
- data/lib/mml/v4.rb +0 -2
- data/lib/mml/version.rb +1 -1
- data/lib/mml/versioned_parser.rb +18 -11
- data/lib/mml.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6c34ac458f880028a8ff29b3a6c0fd85bd260d8144422226c73b130b0b2642a
|
|
4
|
+
data.tar.gz: 8aba5678561f4d8386d52a19641714cb382ea57c3c56fef0aad6278084ab7db4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58164f249aa46ce4fa584b251b06e1202010a9220d660483a5ac4f27fbaf2a4bee3c3ef442be1c844e71bc66a0659436a8a0405a2ef53c29c4dc92c2099cf998
|
|
7
|
+
data.tar.gz: 74fbb545d21bce6c9b95f2b6be9431f48aea7d0047cafb6bbccb293c70b5fe908b662a22592876421286029b42e027ff85e47b37f2e3c51539016fc36d9b2c17
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-04-
|
|
3
|
+
# on 2026-04-19 00:23:48 UTC using RuboCop version 1.86.0.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
10
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
# Configuration parameters: EnforcedStyleAlignWith.
|
|
12
|
-
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
13
|
-
Layout/BlockAlignment:
|
|
14
|
-
Exclude:
|
|
15
|
-
- 'spec/lutaml_default_register_spec.rb'
|
|
16
|
-
|
|
17
|
-
# Offense count: 1
|
|
18
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
19
|
-
Layout/BlockEndNewline:
|
|
20
|
-
Exclude:
|
|
21
|
-
- 'spec/lutaml_default_register_spec.rb'
|
|
22
|
-
|
|
23
|
-
# Offense count: 2
|
|
24
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
25
|
-
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
26
|
-
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
27
|
-
Layout/IndentationWidth:
|
|
28
|
-
Exclude:
|
|
29
|
-
- 'spec/lutaml_default_register_spec.rb'
|
|
30
|
-
|
|
31
|
-
# Offense count: 137
|
|
9
|
+
# Offense count: 136
|
|
32
10
|
# This cop supports safe autocorrection (--autocorrect).
|
|
33
11
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
34
12
|
# URISchemes: http, https
|
|
@@ -102,14 +80,3 @@ RSpec/SpecFilePathFormat:
|
|
|
102
80
|
RSpec/UnspecifiedException:
|
|
103
81
|
Exclude:
|
|
104
82
|
- 'spec/mml/v3_spec.rb'
|
|
105
|
-
|
|
106
|
-
# Offense count: 1
|
|
107
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
108
|
-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
109
|
-
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
110
|
-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
111
|
-
# FunctionalMethods: let, let!, subject, watch
|
|
112
|
-
# AllowedMethods: lambda, proc, it
|
|
113
|
-
Style/BlockDelimiters:
|
|
114
|
-
Exclude:
|
|
115
|
-
- 'spec/lutaml_default_register_spec.rb'
|
data/lib/mml/v2.rb
CHANGED
data/lib/mml/v3.rb
CHANGED
data/lib/mml/v4.rb
CHANGED
data/lib/mml/version.rb
CHANGED
data/lib/mml/versioned_parser.rb
CHANGED
|
@@ -5,7 +5,6 @@ module Mml
|
|
|
5
5
|
# Shared parse entrypoint for versioned modules.
|
|
6
6
|
def parse(input, namespace_exist: true,
|
|
7
7
|
context: Mml::UNSPECIFIED_CONTEXT, register: nil)
|
|
8
|
-
self::Configuration.adapter ||= Mml::DEFAULT_ADAPTER
|
|
9
8
|
context_id = parse_context_id(context, register)
|
|
10
9
|
root_class = Lutaml::Model::GlobalContext.resolve_type(
|
|
11
10
|
:math,
|
|
@@ -18,14 +17,6 @@ module Mml
|
|
|
18
17
|
)
|
|
19
18
|
end
|
|
20
19
|
|
|
21
|
-
# Namespace-less MathML is normalized before handing it to lutaml-model.
|
|
22
|
-
def parse_with_no_namespace(input)
|
|
23
|
-
adapter = self::Configuration.adapter || Mml::DEFAULT_ADAPTER
|
|
24
|
-
Moxml.new(adapter).parse(input).tap do |doc|
|
|
25
|
-
doc.root.add_namespace(nil, self::Namespace.uri)
|
|
26
|
-
end.to_xml
|
|
27
|
-
end
|
|
28
|
-
|
|
29
20
|
# Version modules keep their own default context id.
|
|
30
21
|
def parse_context_id(context, register)
|
|
31
22
|
Mml::ContextOptions.normalize_context_option(
|
|
@@ -36,11 +27,27 @@ module Mml
|
|
|
36
27
|
)
|
|
37
28
|
end
|
|
38
29
|
|
|
39
|
-
#
|
|
30
|
+
# Inject the MathML namespace into the raw XML string before parsing.
|
|
31
|
+
# This avoids a double parse-serialize cycle (previously the code used
|
|
32
|
+
# Moxml to parse → add namespace → serialize → parse again).
|
|
33
|
+
#
|
|
34
|
+
# String-level injection is safe for well-formed MathML: the root element
|
|
35
|
+
# is always <math>. For malformed input, the subsequent from_xml parse will
|
|
36
|
+
# raise a proper error.
|
|
40
37
|
def xml_input(input, namespace_exist)
|
|
41
38
|
return input if namespace_exist
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
inject_namespace(input, self::Namespace.uri)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def inject_namespace(xml_string, namespace_uri)
|
|
46
|
+
# Add xmlns attribute to the <math> root element in the raw XML string.
|
|
47
|
+
# Handles both <math> and <math ...> (with existing attributes).
|
|
48
|
+
xml_string.sub(/<math([\s>])/) do
|
|
49
|
+
"<math xmlns=\"#{namespace_uri}\"#{::Regexp.last_match(1)}"
|
|
50
|
+
end
|
|
44
51
|
end
|
|
45
52
|
end
|
|
46
53
|
end
|
data/lib/mml.rb
CHANGED
|
@@ -5,10 +5,23 @@ require "lutaml/model"
|
|
|
5
5
|
module Mml
|
|
6
6
|
class Error < StandardError; end
|
|
7
7
|
|
|
8
|
-
DEFAULT_ADAPTER = RUBY_ENGINE == "opal" ? :oga : :ox
|
|
9
8
|
SUPPORTED_VERSIONS = [2, 3, 4].freeze
|
|
10
9
|
UNSPECIFIED_CONTEXT = Object.new.freeze
|
|
11
10
|
|
|
11
|
+
# Returns the appropriate XML adapter, respecting the host application's
|
|
12
|
+
# configuration. Opal always uses Oga; CRuby delegates to
|
|
13
|
+
# Lutaml::Model::Config.xml_adapter_type so that users control the adapter
|
|
14
|
+
# from a single configuration point.
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def default_adapter
|
|
18
|
+
if RUBY_ENGINE == "opal"
|
|
19
|
+
:oga
|
|
20
|
+
else
|
|
21
|
+
Lutaml::Model::Config.xml_adapter_type
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
12
25
|
autoload :Namespace, "mml/namespace"
|
|
13
26
|
autoload :CommonElements, "mml/common_elements"
|
|
14
27
|
autoload :ContextOptions, "mml/context_options"
|
|
@@ -17,8 +30,6 @@ module Mml
|
|
|
17
30
|
autoload :V3, "mml/v3"
|
|
18
31
|
autoload :V4, "mml/v4"
|
|
19
32
|
|
|
20
|
-
module_function
|
|
21
|
-
|
|
22
33
|
def parse(
|
|
23
34
|
input,
|
|
24
35
|
namespace_exist: true,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|