-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic configuration, errors, and parsing structure
removed Parser namespace, generated parsing files Updated namespaces, configuration, and parsing attributes Updated attributes, and parsing structure Added model class from configuration for all files and mn, ms, mi, etc classes in math, mstyle, and mrow files removed namespace for all the tags, updated parsing for Munderover, Msubsup, and others updated namespace for all tags/classes and linked table, tr, and td with math and other main tags Added msqrt files Added msqrt, fenced, and munder classes support Linked Mroot with root/collection classes is_mrow for mrow specific check for Plurimath::Math::Formula class Removed namespace prefix from all files, added msgroup support Added msgroup, msline, mstack, semantics, and others Added ms and mrow contents parsing Added/updated merror, mlongdiv and other tags Added mpadded and menclose support and updated configuration Added support for Mfraction, Mphantom, and Mmultiscripts tags Updated attributes for ms tag Added mglyph tag support added lutaml-model version and updated mi and mfenced files disabled top level documentation removed namepspace from all files and changed lutaml-model to git branch for testing test: removed lutaml-model deleted branch WIP: added specs and relevant changes Added/fixed spec fix: rubocop offenses Added zeitwerk and fixed rubocop offenses fixed rubocop offenses removed table_cell_expression file and content chore: removed unused line from table file chore: moved development gem from gemspec to gemfile
- Loading branch information
suleman-uzair
committed
Nov 12, 2024
1 parent
e4e2323
commit 83d45b7
Showing
54 changed files
with
1,895 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "mml/version" | ||
require "zeitwerk" | ||
require "lutaml/model" | ||
require_relative "mml/mml" | ||
|
||
module Mml | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
end | ||
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false) | ||
loader.ignore("#{__dir__}/lib/mml.rb") | ||
loader.setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
module Configuration | ||
SUPPORTED_TAGS = %w[ | ||
mmultiscripts | ||
maligngroup | ||
malignmark | ||
munderover | ||
semantics | ||
mscarries | ||
mfraction | ||
mphantom | ||
menclose | ||
mlongdiv | ||
mpadded | ||
msubsup | ||
mscarry | ||
mfenced | ||
msgroup | ||
mglyph | ||
mstack | ||
munder | ||
mtable | ||
mstyle | ||
mspace | ||
msline | ||
merror | ||
msrow | ||
mfrac | ||
mover | ||
mroot | ||
mtext | ||
msqrt | ||
none | ||
mrow | ||
msub | ||
msup | ||
mi | ||
mo | ||
mn | ||
ms | ||
].freeze | ||
|
||
module_function | ||
|
||
def config | ||
@config ||= {} | ||
end | ||
|
||
def config=(config) | ||
self.config.merge!(config) | ||
end | ||
|
||
def adapter | ||
Lutaml::Model::Config.xml_adapter | ||
end | ||
|
||
def adapter=(adapter) | ||
Lutaml::Model::Config.configure do |config| | ||
require "lutaml/model/xml_adapter/#{adapter.downcase}_adapter" | ||
config.xml_adapter = Lutaml::Model::XmlAdapter.const_get("#{adapter.to_s.capitalize}Adapter") | ||
end | ||
end | ||
|
||
def class_for(class_name) | ||
config[class_name] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Maction < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:maction) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :actiontype, :string | ||
attribute :selection, :string | ||
|
||
xml do | ||
root "maction" | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "actiontype", to: :actiontype, namespace: nil | ||
map_attribute "selection", to: :selection, namespace: nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Maligngroup < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:maligngroup) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :groupalign, :string | ||
|
||
xml do | ||
root "maligngroup" | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "groupalign", to: :groupalign, namespace: nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Malignmark < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:malignmark) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :edge, :string | ||
|
||
xml do | ||
root "malignmark" | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "edge", to: :edge, namespace: nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class MathWithNamespace < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:math) | ||
|
||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "math", mixed: true | ||
namespace "http://www.w3.org/1998/Math/MathML", nil | ||
|
||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class MathWithNilNamespace < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:math) | ||
|
||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "math", mixed: true | ||
|
||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Menclose < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:menclose) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :notation, :string | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "menclose", mixed: true | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "notation", to: :notation, namespace: nil | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Merror < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:merror) | ||
|
||
attribute :mathbackground, :string | ||
attribute :mathcolor, :string | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "merror", mixed: true | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Mfenced < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:mfenced) | ||
|
||
attribute :mathbackground, :string | ||
attribute :separators, :string | ||
attribute :mathcolor, :string | ||
attribute :content, :string | ||
attribute :close, :string | ||
attribute :open, :string | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "mfenced", mixed: true | ||
|
||
map_content to: :content | ||
|
||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "separators", to: :separators, namespace: nil | ||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "close", to: :close, namespace: nil | ||
map_attribute "open", to: :open, namespace: nil | ||
|
||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Mfrac < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:mfrac) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :linethickness, :string | ||
attribute :numalign, :string | ||
attribute :denomalign, :string | ||
attribute :bevelled, :string | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "mfrac", mixed: true | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "linethickness", to: :linethickness, namespace: nil | ||
map_attribute "numalign", to: :numalign, namespace: nil | ||
map_attribute "denomalign", to: :denomalign, namespace: nil | ||
map_attribute "bevelled", to: :bevelled, namespace: nil | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Mfraction < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:mfraction) | ||
|
||
attribute :mathcolor, :string | ||
attribute :mathbackground, :string | ||
attribute :linethickness, :string | ||
attribute :numalign, :string | ||
attribute :denomalign, :string | ||
attribute :bevelled, :string | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
attribute :"#{tag}_value", Mml.const_get(tag.capitalize), collection: true | ||
end | ||
|
||
xml do | ||
root "mfraction", mixed: true | ||
|
||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
map_attribute "linethickness", to: :linethickness, namespace: nil | ||
map_attribute "numalign", to: :numalign, namespace: nil | ||
map_attribute "denomalign", to: :denomalign, namespace: nil | ||
map_attribute "bevelled", to: :bevelled, namespace: nil | ||
Mml::Configuration::SUPPORTED_TAGS.each do |tag| | ||
map_element tag.to_sym, to: :"#{tag}_value" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mml | ||
class Mglyph < Lutaml::Model::Serializable | ||
model Mml::Configuration.class_for(:mglyph) | ||
|
||
attribute :alt, :string | ||
attribute :src, :string | ||
attribute :width, :string | ||
attribute :color, :string | ||
attribute :index, :integer | ||
attribute :height, :string | ||
attribute :valign, :string | ||
attribute :mathsize, :string | ||
attribute :fontsize, :string | ||
attribute :fontstyle, :string | ||
attribute :mathcolor, :string | ||
attribute :fontfamily, :string | ||
attribute :fontweight, :string | ||
attribute :background, :string | ||
attribute :mathvariant, :string | ||
attribute :mathbackground, :string | ||
|
||
xml do | ||
root "mglyph" | ||
|
||
map_attribute "src", to: :src, namespace: nil | ||
map_attribute "alt", to: :alt, namespace: nil | ||
map_attribute "color", to: :color, namespace: nil | ||
map_attribute "index", to: :index, namespace: nil | ||
map_attribute "width", to: :width, namespace: nil | ||
map_attribute "height", to: :height, namespace: nil | ||
map_attribute "valign", to: :valign, namespace: nil | ||
map_attribute "mathsize", to: :mathsize, namespace: nil | ||
map_attribute "fontsize", to: :fontsize, namespace: nil | ||
map_attribute "fontstyle", to: :fontstyle, namespace: nil | ||
map_attribute "mathcolor", to: :mathcolor, namespace: nil | ||
map_attribute "background", to: :background, namespace: nil | ||
map_attribute "fontfamily", to: :fontfamily, namespace: nil | ||
map_attribute "fontweight", to: :fontweight, namespace: nil | ||
map_attribute "mathvariant", to: :mathvariant, namespace: nil | ||
map_attribute "mathbackground", to: :mathbackground, namespace: nil | ||
end | ||
end | ||
end |
Oops, something went wrong.