math_ml 0.13 → 0.14

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  load "Rakefile.utirake"
2
2
 
3
- VER = "0.13"
3
+ VER = "0.14"
4
4
 
5
5
  UtiRake.setup do
6
6
  external("https://hg.hinet.mydns.jp", %w[eim_xml])
@@ -530,7 +530,7 @@ EOS
530
530
 
531
531
  def parse_operator
532
532
  o = @scanner.matched
533
- Operator.new << o
533
+ Operator.new.tap{|op| op[:stretchy]="false"} << o
534
534
  end
535
535
 
536
536
  def parse_block
@@ -614,6 +614,7 @@ EOS
614
614
  el.extend(Variant).variant = Variant::NORMAL unless s.is_a?(String)&&s.length>1
615
615
  when :o
616
616
  el = Operator.new
617
+ el[:stretchy] = "false"
617
618
  when :n
618
619
  el = Number.new
619
620
  else
@@ -11,13 +11,15 @@ describe MathML::LaTeX::Parser do
11
11
 
12
12
  def check_chr(tag, src)
13
13
  src.scan(/./) do |c|
14
- smml(c).should == "<#{tag}>#{c}</#{tag}>"
14
+ tag_re = Regexp.escape(tag)
15
+ smml(c).should =~ /\A<#{tag_re}(\s+[^>]+)?>#{Regexp.escape(c)}<\/#{tag_re}>\z/
15
16
  end
16
17
  end
17
18
 
18
19
  def check_hash(tag, hash)
19
20
  hash.each do |k, v|
20
- smml(k).should == "<#{tag}>#{v}</#{tag}>"
21
+ tag_re = Regexp.escape(tag)
22
+ smml(k).should =~ /\A<#{tag_re}(\s+[^>]+)?>#{Regexp.escape(v)}<\/#{tag_re}>\z/
21
23
  end
22
24
  end
23
25
 
@@ -72,7 +74,7 @@ describe MathML::LaTeX::Parser do
72
74
  it "should process numerics" do
73
75
  smml('1234567890').should == "<mn>1234567890</mn>"
74
76
  smml('1.2').should == "<mn>1.2</mn>"
75
- smml('1.').should == "<mn>1</mn><mo>.</mo>"
77
+ smml('1.').should == "<mn>1</mn><mo stretchy='false'>.</mo>"
76
78
  smml('.2').should == "<mn>.2</mn>"
77
79
  smml('1.2.3').should == "<mn>1.2</mn><mn>.3</mn>"
78
80
  end
@@ -83,7 +85,7 @@ describe MathML::LaTeX::Parser do
83
85
  end
84
86
 
85
87
  it "should process non alphabet command" do
86
- smml('\|').should == "<mo>&DoubleVerticalBar;</mo>"
88
+ smml('\|').should == "<mo stretchy='false'>&DoubleVerticalBar;</mo>"
87
89
  end
88
90
 
89
91
  it "should process space commands" do
@@ -150,12 +152,12 @@ describe MathML::LaTeX::Parser do
150
152
  end
151
153
 
152
154
  it "should process underover" do
153
- smml('\sum_a^b', true).should == "<munderover><mo>&sum;</mo><mi>a</mi><mi>b</mi></munderover>"
154
- smml('\sum_a^b').should == "<msubsup><mo>&sum;</mo><mi>a</mi><mi>b</mi></msubsup>"
155
- smml('\sum_a', true).should == "<munder><mo>&sum;</mo><mi>a</mi></munder>"
156
- smml('\sum^a', true).should == "<mover><mo>&sum;</mo><mi>a</mi></mover>"
157
- smml('\sum_a').should == "<msub><mo>&sum;</mo><mi>a</mi></msub>"
158
- smml('\sum^a').should == "<msup><mo>&sum;</mo><mi>a</mi></msup>"
155
+ smml('\sum_a^b', true).should == "<munderover><mo stretchy='false'>&sum;</mo><mi>a</mi><mi>b</mi></munderover>"
156
+ smml('\sum_a^b').should == "<msubsup><mo stretchy='false'>&sum;</mo><mi>a</mi><mi>b</mi></msubsup>"
157
+ smml('\sum_a', true).should == "<munder><mo stretchy='false'>&sum;</mo><mi>a</mi></munder>"
158
+ smml('\sum^a', true).should == "<mover><mo stretchy='false'>&sum;</mo><mi>a</mi></mover>"
159
+ smml('\sum_a').should == "<msub><mo stretchy='false'>&sum;</mo><mi>a</mi></msub>"
160
+ smml('\sum^a').should == "<msup><mo stretchy='false'>&sum;</mo><mi>a</mi></msup>"
159
161
 
160
162
  lambda{smml('\sum_b_c')}.should raise_parse_error("Double subscript.", '\sum_b', "_c")
161
163
  lambda{smml('\sum^b^c')}.should raise_parse_error("Double superscript.", '\sum^b', "^c")
@@ -349,7 +351,7 @@ describe MathML::LaTeX::Parser do
349
351
  end
350
352
 
351
353
  it "should parse stackrel" do
352
- smml('\stackrel\to=').should == "<mover><mo>=</mo><mo>&rightarrow;</mo></mover>"
354
+ smml('\stackrel\to=').should == "<mover><mo stretchy='false'>=</mo><mo stretchy='false'>&rightarrow;</mo></mover>"
353
355
  smml('\stackrel12').should == "<mover><mn>2</mn><mn>1</mn></mover>"
354
356
  end
355
357
 
@@ -490,7 +492,7 @@ EOS
490
492
  end
491
493
 
492
494
  it "should parse symbols" do
493
- smml('\precneqq').should == "<mo>&#x2ab5;</mo>"
495
+ smml('\precneqq').should == "<mo stretchy='false'>&#x2ab5;</mo>"
494
496
  end
495
497
  end
496
498
 
@@ -143,9 +143,9 @@ describe MathML::Util::SimpleLaTeX do
143
143
  "a\n<math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>b</mi></math>\nc<math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>d</mi></math>e")
144
144
 
145
145
  assert_data('$\\$$',
146
- ["<mo>$</mo>"],
146
+ ["<mo stretchy='false'>$</mo>"],
147
147
  ['$\$$'], [], [], [], [], "\001m0\001",
148
- "<math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mo>$</mo></math>")
148
+ "<math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mo stretchy='false'>$</mo></math>")
149
149
  end
150
150
 
151
151
  it "should parse dmath environment" do
@@ -633,7 +633,7 @@ EOT
633
633
  end
634
634
  end
635
635
  encoded.should == "test\n\001u0\001\nend\n"
636
- simplify_math(s.decode(encoded, data)).should == simplify_math("test\n<math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mtable><mtr><mtd><mi>a</mi></mtd><mtd><mo>=</mo></mtd><mtd><mi>b</mi></mtd></mtr><mtr><mtd><mi>c</mi></mtd><mtd><mo>=</mo></mtd><mtd><mi>d</mi></mtd></mtr></mtable></math>\nend\n")
636
+ simplify_math(s.decode(encoded, data)).should == simplify_math("test\n<math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mtable><mtr><mtd><mi>a</mi></mtd><mtd><mo stretchy='false'>=</mo></mtd><mtd><mi>b</mi></mtd></mtr><mtr><mtd><mi>c</mi></mtd><mtd><mo stretchy='false'>=</mo></mtd><mtd><mi>d</mi></mtd></mtr></mtable></math>\nend\n")
637
637
 
638
638
  encoded, data = s.encode('\begin{eqnarray}a\end{eqnarray}', MathML::Util::EQNARRAY_RE) do |scanner|
639
639
  s.parse_eqnarray(scanner[1]) if scanner.scan(MathML::Util::EQNARRAY_RE)
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math_ml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 13
9
- version: "0.13"
8
+ - 14
9
+ version: "0.14"
10
10
  platform: ruby
11
11
  authors:
12
12
  - KURODA Hiraku
@@ -14,7 +14,8 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-08-01 00:00:00 Z
17
+ date: 2012-11-11 00:00:00 +09:00
18
+ default_executable:
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
21
  name: eim_xml
@@ -59,6 +60,7 @@ files:
59
60
  - spec/math_ml/string_spec.rb
60
61
  - spec/math_ml/util_spec.rb
61
62
  - spec/math_ml/element_spec.rb
63
+ has_rdoc: true
62
64
  homepage: http://mathml.rubyforge.org/
63
65
  licenses: []
64
66
 
@@ -90,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
92
  requirements: []
91
93
 
92
94
  rubyforge_project: mathml
93
- rubygems_version: 1.8.18
95
+ rubygems_version: 1.6.2
94
96
  signing_key:
95
97
  specification_version: 3
96
98
  summary: MathML Library