latexmath 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +14 -0
- data/.github/workflows/test.yml +80 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +132 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +44 -3
- data/README.adoc +28 -0
- data/Rakefile +29 -3
- data/bin/console +3 -3
- data/exe/latexmath +8 -0
- data/latexmath.gemspec +17 -14
- data/lib/latexmath.rb +80 -10
- data/lib/latexmath/aggregator.rb +351 -0
- data/lib/latexmath/converter.rb +421 -0
- data/lib/latexmath/equation.rb +3 -30
- data/lib/latexmath/ext.rb +9 -0
- data/lib/latexmath/latexml_requirement.rb +11 -12
- data/lib/latexmath/requirement.rb +2 -3
- data/lib/latexmath/symbol.rb +43 -0
- data/lib/latexmath/tokenizer.rb +81 -0
- data/lib/latexmath/version.rb +1 -1
- data/lib/latexmath/xml/builder.rb +4 -0
- data/lib/latexmath/xml/element.rb +25 -0
- data/lib/unimathsymbols.js.erb +4 -0
- data/lib/unimathsymbols.txt +2864 -0
- data/opal/latexmath-opal.rb +40 -0
- data/opal/ox.rb +64 -0
- data/opal/pseudoenumerator.rb +19 -0
- metadata +73 -15
- data/.travis.yml +0 -6
- data/README.md +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b0d3e40c0a302dcec54e7690c09cf45a4a96a1032b6ddae604e01ff7cc24fc8
|
4
|
+
data.tar.gz: ab2f29a511adf26da60f5141c25e61cd5f2acdbdc2978740c1a07777c3665a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b9d4f62bd5d9e50da58f62b659141ab76d8f71296eb6ef2b73cb4c1f3b471d06043de27343b8c3d41267e9258bd6a8124d4b33a27a5fdb69aec2c617c696661
|
7
|
+
data.tar.gz: 7114340479c2e338147a3324b748f7d66460e9fe119e2ab16e0e34d0f17ebca83da5de653cf36858dbed208589407c5a30278908b1b57bc76a138aae09ed8deb
|
data/.editorconfig
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Run specs on ${{ matrix.os }} ruby ${{ matrix.ruby }}
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
continue-on-error: ${{ matrix.experimental }}
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
17
|
+
ruby: ['2.6', '2.5', '2.4']
|
18
|
+
experimental: [false]
|
19
|
+
include:
|
20
|
+
- ruby: '2.7'
|
21
|
+
os: ubuntu-latest
|
22
|
+
experimental: true
|
23
|
+
- ruby: '2.7'
|
24
|
+
os: macos-latest
|
25
|
+
experimental: true
|
26
|
+
- ruby: '2.7'
|
27
|
+
os: windows-latest
|
28
|
+
experimental: true
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- name: Use Ruby
|
32
|
+
uses: actions/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
|
36
|
+
- uses: actions/checkout@master
|
37
|
+
|
38
|
+
- name: Install gems
|
39
|
+
run: |
|
40
|
+
gem install bundler -v "~> 2"
|
41
|
+
bundle install --jobs 4 --retry 5
|
42
|
+
|
43
|
+
- name: Install LaTeXML on Ubuntu
|
44
|
+
if: matrix.os == 'ubuntu-latest'
|
45
|
+
run: |
|
46
|
+
sudo snap install latexml --edge
|
47
|
+
echo "::add-path::/snap/bin"
|
48
|
+
|
49
|
+
- name: Install LaTeXML on macOS
|
50
|
+
if: matrix.os == 'macos-latest'
|
51
|
+
run: |
|
52
|
+
brew install libxml2 cpanminus
|
53
|
+
env PATH=$(brew --prefix libxml2)/bin:$PATH \
|
54
|
+
cpanm --notest XML::LibXSLT@1.96 git://github.com/brucemiller/LaTeXML.git@9a0e7dc5
|
55
|
+
|
56
|
+
- name: Install LaTeXML on Windows
|
57
|
+
if: matrix.os == 'windows-latest'
|
58
|
+
shell: cmd
|
59
|
+
run: |
|
60
|
+
cinst -y latexml
|
61
|
+
refreshenv
|
62
|
+
set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
|
63
|
+
where latexmlmath
|
64
|
+
|
65
|
+
- name: Run RSpecs
|
66
|
+
if: matrix.os == 'ubuntu-latest'
|
67
|
+
run: |
|
68
|
+
bundle exec rake
|
69
|
+
|
70
|
+
- name: Run RSpecs
|
71
|
+
if: matrix.os == 'macos-latest'
|
72
|
+
run: |
|
73
|
+
env PATH=$(brew --prefix perl)/bin:$PATH bundle exec rake
|
74
|
+
|
75
|
+
- name: Run specs
|
76
|
+
if: matrix.os == 'windows-latest'
|
77
|
+
shell: pwsh
|
78
|
+
run: |
|
79
|
+
$env:Path = "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;$env:Path"
|
80
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
Layout/EndAlignment:
|
2
|
+
Exclude:
|
3
|
+
- 'lib/latexmath/converter.rb'
|
4
|
+
- 'lib/latexmath/tokenizer.rb'
|
5
|
+
|
6
|
+
# Offense count: 1
|
7
|
+
# Configuration parameters: AllowSafeAssignment.
|
8
|
+
Lint/AssignmentInCondition:
|
9
|
+
Exclude:
|
10
|
+
- 'lib/latexmath/tokenizer.rb'
|
11
|
+
|
12
|
+
# Offense count: 2
|
13
|
+
Lint/ImplicitStringConcatenation:
|
14
|
+
Exclude:
|
15
|
+
- 'spec/tokenizer_spec.rb'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: AllowKeywordBlockArguments.
|
19
|
+
Lint/UnderscorePrefixedVariableName:
|
20
|
+
Exclude:
|
21
|
+
- 'lib/latexmath/converter.rb'
|
22
|
+
|
23
|
+
# Offense count: 2
|
24
|
+
Lint/UselessAssignment:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/latexmath/converter.rb'
|
27
|
+
|
28
|
+
# Offense count: 7
|
29
|
+
# Configuration parameters: IgnoredMethods.
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Max: 32
|
32
|
+
|
33
|
+
# Offense count: 1
|
34
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
35
|
+
# ExcludedMethods: refine
|
36
|
+
Metrics/BlockLength:
|
37
|
+
Max: 35
|
38
|
+
|
39
|
+
# Offense count: 1
|
40
|
+
# Configuration parameters: CountBlocks.
|
41
|
+
Metrics/BlockNesting:
|
42
|
+
Max: 4
|
43
|
+
|
44
|
+
# Offense count: 1
|
45
|
+
# Configuration parameters: CountComments, CountAsOne.
|
46
|
+
Metrics/ClassLength:
|
47
|
+
Max: 157
|
48
|
+
|
49
|
+
# Offense count: 6
|
50
|
+
# Configuration parameters: IgnoredMethods.
|
51
|
+
Metrics/CyclomaticComplexity:
|
52
|
+
Max: 13
|
53
|
+
|
54
|
+
# Offense count: 9
|
55
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
56
|
+
Metrics/MethodLength:
|
57
|
+
Max: 39
|
58
|
+
|
59
|
+
# Offense count: 6
|
60
|
+
# Configuration parameters: IgnoredMethods.
|
61
|
+
Metrics/PerceivedComplexity:
|
62
|
+
Max: 14
|
63
|
+
|
64
|
+
# Offense count: 1
|
65
|
+
Naming/ConstantName:
|
66
|
+
Exclude:
|
67
|
+
- 'lib/latexmath.rb'
|
68
|
+
|
69
|
+
# Offense count: 2
|
70
|
+
# Cop supports --auto-correct.
|
71
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
72
|
+
# SupportedStyles: nested, compact
|
73
|
+
Style/ClassAndModuleChildren:
|
74
|
+
Exclude:
|
75
|
+
- 'lib/latexmath/xml/builder.rb'
|
76
|
+
- 'lib/latexmath/xml/element.rb'
|
77
|
+
|
78
|
+
# Offense count: 7
|
79
|
+
Style/Documentation:
|
80
|
+
Exclude:
|
81
|
+
- 'spec/**/*'
|
82
|
+
- 'test/**/*'
|
83
|
+
- 'lib/latexmath.rb'
|
84
|
+
- 'lib/latexmath/aggregator.rb'
|
85
|
+
- 'lib/latexmath/converter.rb'
|
86
|
+
- 'lib/latexmath/equation.rb'
|
87
|
+
- 'lib/latexmath/latexml_requirement.rb'
|
88
|
+
- 'lib/latexmath/requirement.rb'
|
89
|
+
- 'lib/latexmath/tokenizer.rb'
|
90
|
+
|
91
|
+
# Offense count: 18
|
92
|
+
# Cop supports --auto-correct.
|
93
|
+
# Configuration parameters: EnforcedStyle.
|
94
|
+
# SupportedStyles: always, always_true, never
|
95
|
+
Style/FrozenStringLiteralComment:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Offense count: 2
|
99
|
+
# Configuration parameters: MinBodyLength.
|
100
|
+
Style/GuardClause:
|
101
|
+
Exclude:
|
102
|
+
- 'lib/latexmath/aggregator.rb'
|
103
|
+
|
104
|
+
# Offense count: 5
|
105
|
+
Style/IdenticalConditionalBranches:
|
106
|
+
Exclude:
|
107
|
+
- 'lib/latexmath/converter.rb'
|
108
|
+
|
109
|
+
# Offense count: 1
|
110
|
+
# Cop supports --auto-correct.
|
111
|
+
Style/LineEndConcatenation:
|
112
|
+
Exclude:
|
113
|
+
- 'spec/tokenizer_spec.rb'
|
114
|
+
|
115
|
+
# Offense count: 5
|
116
|
+
# Cop supports --auto-correct.
|
117
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
118
|
+
# SupportedStyles: predicate, comparison
|
119
|
+
Style/NumericPredicate:
|
120
|
+
Exclude:
|
121
|
+
- 'spec/**/*'
|
122
|
+
- 'lib/latexmath/aggregator.rb'
|
123
|
+
- 'lib/latexmath/converter.rb'
|
124
|
+
- 'lib/latexmath/latexml_requirement.rb'
|
125
|
+
|
126
|
+
# Offense count: 2
|
127
|
+
# Cop supports --auto-correct.
|
128
|
+
Style/ZeroLengthPredicate:
|
129
|
+
Exclude:
|
130
|
+
- 'lib/latexmath/converter.rb'
|
131
|
+
|
132
|
+
|
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in latexmath.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
7
|
-
gem
|
6
|
+
gem 'byebug'
|
7
|
+
gem 'pry'
|
8
|
+
gem 'rake', '~> 12.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rubocop'
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
latexmath (0.1.
|
4
|
+
latexmath (0.1.1)
|
5
5
|
htmlentities (~> 4.3)
|
6
|
-
|
6
|
+
ox (~> 2.13)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
+
ast (2.4.1)
|
12
|
+
byebug (11.1.3)
|
13
|
+
coderay (1.1.3)
|
11
14
|
diff-lcs (1.4.4)
|
15
|
+
equivalent-xml (0.6.0)
|
16
|
+
nokogiri (>= 1.4.3)
|
17
|
+
execjs (2.7.0)
|
12
18
|
htmlentities (4.3.4)
|
19
|
+
method_source (1.0.0)
|
20
|
+
mini_portile2 (2.4.0)
|
21
|
+
nokogiri (1.10.10)
|
22
|
+
mini_portile2 (~> 2.4.0)
|
23
|
+
opal (1.0.3)
|
24
|
+
ast (>= 2.3.0)
|
25
|
+
parser (~> 2.6)
|
26
|
+
ox (2.13.3)
|
27
|
+
parallel (1.19.2)
|
28
|
+
parser (2.7.1.4)
|
29
|
+
ast (~> 2.4.1)
|
30
|
+
pry (0.13.1)
|
31
|
+
coderay (~> 1.1)
|
32
|
+
method_source (~> 1.0)
|
33
|
+
rainbow (3.0.0)
|
13
34
|
rake (12.3.3)
|
35
|
+
regexp_parser (1.7.1)
|
36
|
+
rexml (3.2.4)
|
14
37
|
rspec (3.9.0)
|
15
38
|
rspec-core (~> 3.9.0)
|
16
39
|
rspec-expectations (~> 3.9.0)
|
@@ -24,15 +47,33 @@ GEM
|
|
24
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
25
48
|
rspec-support (~> 3.9.0)
|
26
49
|
rspec-support (3.9.3)
|
27
|
-
|
50
|
+
rubocop (0.89.1)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 2.7.1.1)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.7)
|
55
|
+
rexml
|
56
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
57
|
+
ruby-progressbar (~> 1.7)
|
58
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
59
|
+
rubocop-ast (0.3.0)
|
60
|
+
parser (>= 2.7.1.4)
|
61
|
+
ruby-progressbar (1.10.1)
|
62
|
+
unicode-display_width (1.7.0)
|
28
63
|
|
29
64
|
PLATFORMS
|
30
65
|
ruby
|
31
66
|
|
32
67
|
DEPENDENCIES
|
68
|
+
byebug
|
69
|
+
equivalent-xml
|
70
|
+
execjs
|
33
71
|
latexmath!
|
72
|
+
opal
|
73
|
+
pry
|
34
74
|
rake (~> 12.0)
|
35
75
|
rspec (~> 3.0)
|
76
|
+
rubocop
|
36
77
|
|
37
78
|
BUNDLED WITH
|
38
79
|
2.1.4
|
data/README.adoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= latexmath
|
2
|
+
|
3
|
+
image:https://img.shields.io/gem/v/latexmath.svg["Gem Version", link="https://rubygems.org/gems/latexmath"]
|
4
|
+
image:https://github.com/metanorma/latexmath/workflows/test/badge.svg["Build Status", link="https://github.com/metanorma/latexmath/actions?workflow=test"]
|
5
|
+
image:https://codeclimate.com/github/metanorma/latexmath/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/latexmath"]
|
6
|
+
image:https://img.shields.io/github/issues-pr-raw/metanorma/latexmath.svg["Pull Requests", link="https://github.com/metanorma/latexmath/pulls"]
|
7
|
+
image:https://img.shields.io/github/commits-since/metanorma/latexmath/latest.svg["Commits since latest",link="https://github.com/metanorma/latexmath/releases"]
|
8
|
+
|
9
|
+
== Purpose
|
10
|
+
|
11
|
+
Ruby gem to translate LaTeX math into MathML.
|
12
|
+
The MathML is supposed to be compliant with output of LaTeXML.
|
13
|
+
|
14
|
+
It also works in reverse by translating MathML into LaTeX code.
|
15
|
+
|
16
|
+
The LaTeX math syntax supports `amsmath`, `array`, `split` and `pmatrix` packages.
|
17
|
+
|
18
|
+
NOTE: Bolding, symbols like `\backepsilon`, equation alignment, are all supported.
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
22
|
+
[source,ruby]
|
23
|
+
-------------
|
24
|
+
require "latexmath"
|
25
|
+
|
26
|
+
latex = "$$f_i = \sum_{j=1}^2 s_{ij} n_j \quad {\rm for} \quad i = 1,2$$"
|
27
|
+
mathml = Latexmath.parse(latex).to_mathml
|
28
|
+
-------------
|
data/Rakefile
CHANGED
@@ -1,6 +1,32 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
task
|
7
|
+
task 'build-opal' do
|
8
|
+
require 'opal'
|
9
|
+
require 'erb'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
b = Opal::Builder.new
|
13
|
+
|
14
|
+
b.append_paths __dir__ + '/lib'
|
15
|
+
b.append_paths __dir__ + '/opal'
|
16
|
+
b.use_gem 'htmlentities'
|
17
|
+
|
18
|
+
build = b.build('latexmath-opal').to_s
|
19
|
+
# This is a hack intended for ExecJS to work properly.
|
20
|
+
build = build.gsub('Object freezing is not supported by Opal', '')
|
21
|
+
|
22
|
+
FileUtils.mkdir_p 'dist'
|
23
|
+
File.write('dist/latexmath.js', build)
|
24
|
+
end
|
25
|
+
|
26
|
+
task 'spec-opal' => 'build-opal' do
|
27
|
+
ENV['TEST_OPAL'] = '1'
|
28
|
+
Rake::Task['spec'].execute
|
29
|
+
ENV.delete 'TEST_OPAL'
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: [:spec, 'spec-opal']
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'latexmath'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "latexmath"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/exe/latexmath
ADDED
data/latexmath.gemspec
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
require_relative 'lib/latexmath/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
4
|
+
spec.name = 'latexmath'
|
5
5
|
spec.version = Latexmath::VERSION
|
6
6
|
spec.authors = ['Ribose Inc.']
|
7
7
|
spec.email = ['open.source@ribose.com']
|
8
8
|
|
9
|
-
spec.summary =
|
10
|
-
spec.description =
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
9
|
+
spec.summary = 'Converts LaTeX math into MathML.'
|
10
|
+
spec.description = 'Converts LaTeX math into MathML.'
|
11
|
+
spec.homepage = 'https://github.com/plurimath/latexmath'
|
12
|
+
spec.license = 'BSD-2-Clause'
|
13
13
|
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
15
15
|
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/plurimath/latexmath'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/plurimath/latexmath/blob/master/CHANGELOG.md.'
|
19
19
|
|
20
20
|
# Specify which files should be added to the gem when it is released.
|
21
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
23
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
24
|
end
|
25
|
-
spec.bindir =
|
25
|
+
spec.bindir = 'exe'
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
27
|
+
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_dependency
|
30
|
-
spec.add_dependency
|
29
|
+
spec.add_dependency 'htmlentities', '~> 4.3'
|
30
|
+
spec.add_dependency 'ox', '~> 2.13'
|
31
|
+
spec.add_development_dependency 'equivalent-xml'
|
32
|
+
spec.add_development_dependency 'execjs'
|
33
|
+
spec.add_development_dependency 'opal'
|
31
34
|
end
|