asciimath 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ac3713271b5ebfc1878d30dc820458ad9e6cc1
4
- data.tar.gz: 99b1031e60e3681265cb98d8a74f7470341787cf
3
+ metadata.gz: aa1c3652a0a8ee204467385b78c06902d31c473d
4
+ data.tar.gz: 5c5f71402ee68f2b5f4fbbcca771b2f0f7b1107b
5
5
  SHA512:
6
- metadata.gz: d315370a018cacd96a53a2abd8026d596b8dd4f0e7449ed9f5affa6e222b534c2ba2508e7de4df5235ab3a6291272f40c6529deac709e0a6ff6be70d68bd97e8
7
- data.tar.gz: 6c652b60fe2a67c1fca6322d668488d9570c9b78114d54013f970d3d6a4d5a2ad10fa49506c1222031ab2c2c1bbd158ac481931aa5742d472d0e8ac4cc1155d1
6
+ metadata.gz: d0c849c8dbcafb79620ae2b1358629e4644f6372f324b0e56a74beabc4509b395512dd3a64deb9916dc864bda42a16a013253db3a75818268a3193a82da6fa82
7
+ data.tar.gz: fbd88a8fa50bd2042976f9fe9b2529af73f4d8dac108197d316aa1e2b9666694ec283ce218f5af1862fe619b9cd79a692f3d05a6ef381e104d60c0258aa9f22a
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache:
3
+ apt: true
4
+ directories:
5
+ - vendor/bundle
6
+ - $HOME/.cache/pip
7
+ rvm:
8
+ - 1.8.7
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.0
12
+ - jruby
13
+ install:
14
+ - bundle install --path vendor/bundle --jobs=3 --retry=3
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:test)
6
+
7
+ task :default => :test
@@ -53,7 +53,6 @@ module AsciiMath
53
53
  #
54
54
  class Tokenizer
55
55
  WHITESPACE = /^\s+/
56
- NUMBER_START = /[-0-9]/
57
56
  NUMBER = /-?[0-9]+(?:\.[0-9]+)?/
58
57
  TEXT = /"[^"]+"/
59
58
 
@@ -87,7 +86,7 @@ module AsciiMath
87
86
  case @string.peek(1)
88
87
  when '"'
89
88
  read_text
90
- when NUMBER_START
89
+ when '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
91
90
  read_number() || read_symbol
92
91
  else
93
92
  read_symbol()
@@ -125,6 +124,17 @@ module AsciiMath
125
124
  end
126
125
  end
127
126
 
127
+ if String.method_defined?(:bytesize)
128
+ def bytesize(s)
129
+ s.bytesize
130
+ end
131
+ else
132
+ def bytesize(s)
133
+ s.length
134
+ end
135
+ end
136
+
137
+
128
138
  # Private: Reads a symbol token from the input string. This method first creates
129
139
  # a String from the input String starting from the current position with a length
130
140
  # that matches that of the longest key in the symbol table. It then looks up that
@@ -143,7 +153,7 @@ module AsciiMath
143
153
  until s.length == 1 || @symbols.include?(s)
144
154
  s.chop!
145
155
  end
146
- @string.pos = position + s.length
156
+ @string.pos = position + bytesize(s)
147
157
  @symbols[s] || {:value => s, :type => :identifier}
148
158
  end
149
159
  end
@@ -162,6 +172,12 @@ module AsciiMath
162
172
  s
163
173
  end
164
174
  end
175
+
176
+ if String.respond_to?(:byte_size)
177
+ def byte_size(s)
178
+ s.byte_size
179
+ end
180
+ end
165
181
  end
166
182
 
167
183
  class Parser
@@ -1,3 +1,3 @@
1
1
  module AsciiMath
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -42,8 +42,16 @@ TEST_CASES = {
42
42
  '<math><mrow><mo>(</mo><mtable><mtr><mtd><msub><mi>a</mi><mn>11</mn></msub></mtd><mtd><mo>&#x22EF;</mo></mtd><mtd><msub><mi>a</mi><mrow><mn>1</mn><mi>n</mi></mrow></msub></mtd></mtr><mtr><mtd><mo>&#x22EE;</mo></mtd><mtd><mo>&#x22F1;</mo></mtd><mtd><mo>&#x22EE;</mo></mtd></mtr><mtr><mtd><msub><mi>a</mi><mrow><mi>m</mi><mn>1</mn></mrow></msub></mtd><mtd><mo>&#x22EF;</mo></mtd><mtd><msub><mi>a</mi><mrow><mi>m</mi><mi>n</mi></mrow></msub></mtd></mtr></mtable><mo>)</mo></mrow></math>',
43
43
  'sum_(k=1)^n k = 1+2+ cdots +n=(n(n+1))/2' =>
44
44
  '<math><munderover><mo>&#x2211;</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>&#x22EF;</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
+ '"Скорость"=("Расстояние")/("Время")' =>
46
+ '<math><mtext>Скорость</mtext><mo>=</mo><mfrac><mtext>Расстояние</mtext><mtext>Время</mtext></mfrac></math>'
45
47
  }
46
48
 
49
+ version = RUBY_VERSION.split('.').map { |s| s.to_i }
50
+
51
+ if version[0] > 1 || version[1] > 8
52
+ TEST_CASES['Скорость=(Расстояние)/(Время)'] = '<math><mi>С</mi><mi>к</mi><mi>о</mi><mi>р</mi><mi>о</mi><mi>с</mi><mi>т</mi><mi>ь</mi><mo>=</mo><mfrac><mrow><mi>Р</mi><mi>а</mi><mi>с</mi><mi>с</mi><mi>т</mi><mi>о</mi><mi>я</mi><mi>н</mi><mi>и</mi><mi>е</mi></mrow><mrow><mi>В</mi><mi>р</mi><mi>е</mi><mi>м</mi><mi>я</mi></mrow></mfrac></math>'
53
+ end
54
+
47
55
  module AsciiMathHelper
48
56
  def expect_mathml(asciimath, mathml)
49
57
  expect(AsciiMath.parse(asciimath).to_mathml).to eq(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.2
4
+ version: 1.0.3
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: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
+ - ".travis.yml"
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md
@@ -72,7 +73,7 @@ files:
72
73
  - lib/asciimath/mathml.rb
73
74
  - lib/asciimath/parser.rb
74
75
  - lib/asciimath/version.rb
75
- - test/parser_spec.rb
76
+ - spec/parser_spec.rb
76
77
  homepage: ''
77
78
  licenses:
78
79
  - MIT
@@ -98,5 +99,5 @@ signing_key:
98
99
  specification_version: 4
99
100
  summary: AsciiMath parser and converter
100
101
  test_files:
101
- - test/parser_spec.rb
102
+ - spec/parser_spec.rb
102
103
  has_rdoc: