Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tokenizer and start work on packages #29

Open
wants to merge 1 commit into
base: latexml-compat
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AllCops:
NewCops: enable
TargetRubyVersion: 2.4
Layout/EndAlignment:
Exclude:
- 'lib/latexmath/converter.rb'
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.4.10
12 changes: 11 additions & 1 deletion lib/latexmath.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#require 'byebug' unless RUBY_ENGINE == 'opal'
require 'byebug' unless RUBY_ENGINE == 'opal'
require 'json'
require 'htmlentities'
require 'ox'
require_relative 'latexmath/ext'
require_relative 'latexmath/version'
require_relative 'latexmath/common/object'
require_relative 'latexmath/common/number'
require_relative 'latexmath/core/definition/expandable'
require_relative 'latexmath/core/mouth'
require_relative 'latexmath/core/package'
require_relative 'latexmath/core/state'
require_relative 'latexmath/core/token'
require_relative 'latexmath/core/tokens'
require_relative 'latexmath/constants/symbols'
require_relative 'latexmath/packages/aas'
require_relative 'latexmath/packages/amsmath'
require_relative 'latexmath/aggregator'
require_relative 'latexmath/converter'
require_relative 'latexmath/symbol'
Expand Down
7 changes: 7 additions & 0 deletions lib/latexmath/aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ def initialize(tokens)
@tokens = tokens
end

def new_aggregate(tokens)
tokens.each do |token|
Latexmath::Common::Number.new(token)
end
end

def aggregate(tokens = @tokens)
aggregated = []
new_aggregate(tokens.clone)

loop do
begin
Expand Down
17 changes: 17 additions & 0 deletions lib/latexmath/common/number.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Latexmath
module Common
class Number < Latexmath::Common::Object
def initialize(number)
@number = number
end

def larger(other)
value_of > other.value_of ? self : other
end

def value_of
@number
end
end
end
end
6 changes: 6 additions & 0 deletions lib/latexmath/common/object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Latexmath
module Common
class Object
end
end
end
14 changes: 14 additions & 0 deletions lib/latexmath/core/box.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Latexmath
module Core
class Box
def initialize(tokens)
end

def width
end

def total_height
end
end
end
end
11 changes: 11 additions & 0 deletions lib/latexmath/core/definition/char_def.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Latexmath
module Core
module Definition
class CharDef
def initialize(cs, parameters)
# ($class, $cs, $parameters, $replacement, %traits)
end
end
end
end
end
11 changes: 11 additions & 0 deletions lib/latexmath/core/definition/constructor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Latexmath
module Core
module Definition
class Constructor
def initialize(cs, parameters)
# ($class, $cs, $parameters, $replacement, %traits)
end
end
end
end
end
12 changes: 12 additions & 0 deletions lib/latexmath/core/definition/expandable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Latexmath
module Core
module Definition
class Expandable
attr_reader :cs
def initialize(cs, sparamlist, expansion, options)
@cs = cs
end
end
end
end
end
11 changes: 11 additions & 0 deletions lib/latexmath/core/definition/primitive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Latexmath
module Core
module Definition
class Primitive
def initialize(cs, parameters)
# ($class, $cs, $parameters, $replacement, %traits)
end
end
end
end
end
8 changes: 8 additions & 0 deletions lib/latexmath/core/gullet.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Latexmath
module Core
class Gullet
def initialize(options)
end
end
end
end
24 changes: 24 additions & 0 deletions lib/latexmath/core/math/fraction.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Latexmath
module Core
module Math
class Fraction
def initialize(numerator, denominator)
@denominator = denominator
@numerator = numerator
end

def w
@numerator.width.larger(denominator.width)
end

def d
@denominator.total_height.multiply(0.5)
end

def h
@numerator.total_height.add(d)
end
end
end
end
end
8 changes: 8 additions & 0 deletions lib/latexmath/core/math/matrix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Latexmath
module Core
module Math
class Matrix
end
end
end
end