asciimath 1.0.0.preview.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -4
- data/asciimath.gemspec +3 -3
- data/bin/asciimath +1 -1
- data/lib/asciimath/cli.rb +2 -2
- data/lib/asciimath/mathml.rb +1 -1
- data/lib/asciimath/parser.rb +1 -1
- data/lib/asciimath/version.rb +2 -2
- data/test/parser_spec.rb +4 -4
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db33412e95fb41f457c468d34b93d85384ebf114
|
4
|
+
data.tar.gz: 6b62bc0d4745fa50df1dc6329c40d819933be1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e3fa85489e4d609c90945c161086bc10c7ead9156ce4d10073cae0ff8b994515ec2b736f4dbe2aa6cb0cde2a5e5bd38ebeb6f3a0240104dca1a1fedec78eab
|
7
|
+
data.tar.gz: 44543b4567c6d9eb2572f0254dd3a36f6dad1dacfde9b0fe2bc7ce8dea99e106ea7aa8a59508731353b68d89746ff0c0711c33d1ea743ac814b32a077be1adc9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# AsciiMath
|
2
2
|
|
3
|
-
An [
|
3
|
+
An [AsciiMath](http://asciimath.org) parser and MathML generator written in pure Ruby.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,11 +20,43 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### Library
|
24
|
+
|
25
|
+
First require the library.
|
26
|
+
|
27
|
+
```
|
28
|
+
require 'asciimath'
|
29
|
+
```
|
30
|
+
|
31
|
+
Then parse an AsciiMath string.
|
32
|
+
|
33
|
+
```
|
34
|
+
parsed_expression = AsciiMath.parse(asciimath)
|
35
|
+
```
|
36
|
+
|
37
|
+
The parsed expression is a set of nested Array and Hash objects.
|
38
|
+
|
39
|
+
This expression can then be converted to MathML.
|
40
|
+
|
41
|
+
```
|
42
|
+
math_ml = parsed_expression.to_mathml
|
43
|
+
```
|
44
|
+
|
45
|
+
The MathML code is returned as a String.
|
46
|
+
|
47
|
+
### Command line
|
48
|
+
|
49
|
+
The AsciiMath parser and MathML converter can be invoked via the command line as follows:
|
50
|
+
|
51
|
+
```
|
52
|
+
asciimath "an asciimath string"
|
53
|
+
```
|
54
|
+
|
55
|
+
This command will print out the generated MathML code on stdout.
|
24
56
|
|
25
57
|
## Contributing
|
26
58
|
|
27
|
-
1. Fork it ( https://github.com/
|
59
|
+
1. Fork it ( https://github.com/pepijnve/asciimath/fork )
|
28
60
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
61
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
62
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/asciimath.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'asciimath/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "asciimath"
|
8
|
-
spec.version =
|
8
|
+
spec.version = AsciiMath::VERSION
|
9
9
|
spec.authors = ["Pepijn Van Eeckhoudt"]
|
10
10
|
spec.email = ["pepijn@vaneeckhoudt.net"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{A pure Ruby
|
11
|
+
spec.summary = %q{AsciiMath parser and converter}
|
12
|
+
spec.description = %q{A pure Ruby AsciiMath parsing and conversion library.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/bin/asciimath
CHANGED
data/lib/asciimath/cli.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require_relative 'parser'
|
2
2
|
require_relative 'mathml'
|
3
3
|
|
4
|
-
module
|
4
|
+
module AsciiMath
|
5
5
|
module CLI
|
6
6
|
def self.run(args)
|
7
7
|
asciimath = args.last
|
8
|
-
mathml =
|
8
|
+
mathml = AsciiMath.parse(asciimath).to_mathml
|
9
9
|
puts mathml
|
10
10
|
end
|
11
11
|
end
|
data/lib/asciimath/mathml.rb
CHANGED
data/lib/asciimath/parser.rb
CHANGED
@@ -26,7 +26,7 @@ require 'strscan'
|
|
26
26
|
# When parsing the 'constant' the parser will try to find the longest matching string in the symbol
|
27
27
|
# table starting at the current position of the parser. If no matching string can be found the
|
28
28
|
# character at the current position of the parser is interpreted as an identifier instead.
|
29
|
-
module
|
29
|
+
module AsciiMath
|
30
30
|
# Internal: Splits an ASCIIMath expression into a sequence of tokens.
|
31
31
|
# Each token is represented as a Hash containing the keys :value and :type.
|
32
32
|
# The :value key is used to store the text associated with each token.
|
data/lib/asciimath/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "1.0.0
|
1
|
+
module AsciiMath
|
2
|
+
VERSION = "1.0.0"
|
3
3
|
end
|
data/test/parser_spec.rb
CHANGED
@@ -44,17 +44,17 @@ TEST_CASES = {
|
|
44
44
|
'<math><munderover><mo>∑</mo><mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><mi>k</mi><mo>=</mo><mn>1</mn><mo>+</mo><mn>2</mn><mo>+</mo><mo>⋯</mo><mo>+</mo><mi>n</mi><mo>=</mo><mfrac><mrow><mi>n</mi><mrow><mo>(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo>)</mo></mrow></mrow><mn>2</mn></mfrac></math>',
|
45
45
|
}
|
46
46
|
|
47
|
-
module
|
47
|
+
module AsciiMathHelper
|
48
48
|
def expect_mathml(asciimath, mathml)
|
49
|
-
expect(
|
49
|
+
expect(AsciiMath.parse(asciimath).to_mathml).to eq(mathml)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
RSpec.configure do |c|
|
54
|
-
c.include
|
54
|
+
c.include AsciiMathHelper
|
55
55
|
end
|
56
56
|
|
57
|
-
describe "
|
57
|
+
describe "AsciiMath::MathMLBuilder" do
|
58
58
|
TEST_CASES.each_pair do |asciimath, mathml|
|
59
59
|
it "should produce identical output to asciimathml.js for '#{asciimath}'" do
|
60
60
|
expect_mathml(asciimath, mathml)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciimath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pepijn Van Eeckhoudt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.1.0
|
55
|
-
description: A pure Ruby
|
55
|
+
description: A pure Ruby AsciiMath parsing and conversion library.
|
56
56
|
email:
|
57
57
|
- pepijn@vaneeckhoudt.net
|
58
58
|
executables:
|
@@ -88,14 +88,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "
|
91
|
+
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.4.7
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
|
-
summary:
|
99
|
+
summary: AsciiMath parser and converter
|
100
100
|
test_files:
|
101
101
|
- test/parser_spec.rb
|
102
|
+
has_rdoc:
|