latexmath 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ require 'opal'
2
+ require 'corelib/string/unpack'
3
+ require 'pseudoenumerator'
4
+ require 'htmlentities'
5
+ require 'htmlentities/mappings/html4' # Dynamic require
6
+ require 'htmlentities/mappings/xhtml1' # Dynamic require
7
+ require 'htmlentities/mappings/expanded' # Dynamic require
8
+ require 'latexmath'
9
+
10
+ # Override 2 methods that use dynamic execution so we don't need to require a parser
11
+ class HTMLEntities
12
+ class Encoder
13
+ def build_basic_entity_encoder(instructions)
14
+ if instructions.include?(:basic) || instructions.include?(:named)
15
+ method = :encode_named
16
+ elsif instructions.include?(:decimal)
17
+ method = :encode_decimal
18
+ elsif instructions.include?(:hexadecimal)
19
+ method = :encode_hexadecimal
20
+ end
21
+ self.class.define_method :encode_basic do |char|
22
+ send(method, char)
23
+ end
24
+ end
25
+
26
+ def build_extended_entity_encoder(instructions)
27
+ operations = [:named, :decimal, :hexadecimal] & instructions
28
+
29
+ self.class.define_method :encode_extended do |char|
30
+
31
+ operations.each do |encoder|
32
+ encoded = send(:"encode_#{encoder}", char)
33
+ return encoded if encoded
34
+ end
35
+
36
+ char
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,64 @@
1
+ # A minimal Ox implementation for Opal
2
+
3
+ module Ox
4
+ CODER = HTMLEntities.new
5
+
6
+ class Document
7
+ def initialize
8
+ @root = nil
9
+ end
10
+
11
+ def << child
12
+ @root = child
13
+ end
14
+
15
+ def dump
16
+ @root.dump
17
+ end
18
+ end
19
+
20
+ class Element
21
+ def initialize tag_name
22
+ @tag_name = tag_name
23
+ @attrs = {}
24
+ @children = []
25
+ end
26
+
27
+ def []= key, value
28
+ @attrs[key] = value
29
+ end
30
+
31
+ def << child
32
+ @children << child
33
+ self
34
+ end
35
+
36
+ def value= value
37
+ @tag_name = value
38
+ end
39
+
40
+ def dump
41
+ attrs = @attrs.map do |k,v|
42
+ %Q< #{k}="#{CODER.encode(v)}">
43
+ end.join("")
44
+ "<#{@tag_name}#{attrs}>"+
45
+ @children.map(&:dump).join("")+
46
+ "</#{@tag_name}>"
47
+ end
48
+ end
49
+
50
+ class Raw
51
+ def initialize value
52
+ @value = value
53
+ end
54
+
55
+ def dump
56
+ #CODER.encode(@value)
57
+ @value
58
+ end
59
+ end
60
+
61
+ def self.dump doc
62
+ doc.dump
63
+ end
64
+ end
@@ -0,0 +1,19 @@
1
+ # Opal doesn't support Enumerator's #next and #peek extended methods. This tries
2
+ # to emulate them.
3
+
4
+ class Pseudoenumerator
5
+ def initialize obj
6
+ @obj = obj.to_a.reverse
7
+ end
8
+
9
+ def next
10
+ out = peek
11
+ @obj.pop
12
+ out
13
+ end
14
+
15
+ def peek
16
+ raise StopIteration if @obj.length == 0
17
+ @obj.last
18
+ end
19
+ end
metadata CHANGED
@@ -1,73 +1,131 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latexmath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: unicode2latex
14
+ name: htmlentities
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: '4.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: '4.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: htmlentities
28
+ name: ox
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.3'
33
+ version: '2.13'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.3'
40
+ version: '2.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: equivalent-xml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: execjs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: opal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  description: Converts LaTeX math into MathML.
42
84
  email:
43
85
  - open.source@ribose.com
44
- executables: []
86
+ executables:
87
+ - latexmath
45
88
  extensions: []
46
89
  extra_rdoc_files: []
47
90
  files:
91
+ - ".editorconfig"
92
+ - ".github/workflows/test.yml"
48
93
  - ".gitignore"
49
94
  - ".rspec"
50
- - ".travis.yml"
95
+ - ".rubocop.yml"
51
96
  - CODE_OF_CONDUCT.md
52
97
  - Gemfile
53
98
  - Gemfile.lock
54
- - README.md
99
+ - README.adoc
55
100
  - Rakefile
56
101
  - bin/console
57
102
  - bin/setup
103
+ - exe/latexmath
58
104
  - latexmath.gemspec
59
105
  - lib/latexmath.rb
106
+ - lib/latexmath/aggregator.rb
107
+ - lib/latexmath/converter.rb
60
108
  - lib/latexmath/equation.rb
109
+ - lib/latexmath/ext.rb
61
110
  - lib/latexmath/latexml_requirement.rb
62
111
  - lib/latexmath/requirement.rb
112
+ - lib/latexmath/symbol.rb
113
+ - lib/latexmath/tokenizer.rb
63
114
  - lib/latexmath/version.rb
64
- homepage: https://github.com/metanorma/latexmath
115
+ - lib/latexmath/xml/builder.rb
116
+ - lib/latexmath/xml/element.rb
117
+ - lib/unimathsymbols.js.erb
118
+ - lib/unimathsymbols.txt
119
+ - opal/latexmath-opal.rb
120
+ - opal/ox.rb
121
+ - opal/pseudoenumerator.rb
122
+ homepage: https://github.com/plurimath/latexmath
65
123
  licenses:
66
124
  - BSD-2-Clause
67
125
  metadata:
68
- homepage_uri: https://github.com/metanorma/latexmath
69
- source_code_uri: https://github.com/metanorma/latexmath
70
- changelog_uri: https://github.com/metanorma/latexmath/blob/master/CHANGELOG.md.
126
+ homepage_uri: https://github.com/plurimath/latexmath
127
+ source_code_uri: https://github.com/plurimath/latexmath
128
+ changelog_uri: https://github.com/plurimath/latexmath/blob/master/CHANGELOG.md.
71
129
  post_install_message:
72
130
  rdoc_options: []
73
131
  require_paths:
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.5
6
- before_install: gem install bundler -v 2.1.4
data/README.md DELETED
@@ -1,40 +0,0 @@
1
- # Latexmath
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/latexmath`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'latexmath'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install latexmath
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/latexmath. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/latexmath/blob/master/CODE_OF_CONDUCT.md).
36
-
37
-
38
- ## Code of Conduct
39
-
40
- Everyone interacting in the Latexmath project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/latexmath/blob/master/CODE_OF_CONDUCT.md).