mathml 0.8.0 → 0.8.1
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.
- data/Rakefile +2 -2
- data/lib/math_ml.rb +26 -14
- data/test/math_ml_test.rb +15 -1
- metadata +61 -54
data/Rakefile
CHANGED
@@ -54,7 +54,7 @@ namespace :test do
|
|
54
54
|
end
|
55
55
|
FileList["test/*_test.rb"].sort{|a,b| File.mtime(a)<=>File.mtime(b)}.reverse.each do |i|
|
56
56
|
Rake::TestTask.new(:apart) do |t|
|
57
|
-
t.test_files = i
|
57
|
+
t.test_files = [i]
|
58
58
|
add_libs_for_test(t)
|
59
59
|
end
|
60
60
|
end
|
@@ -80,7 +80,7 @@ def build_gem(unstable=false)
|
|
80
80
|
spec = Gem::Specification.new do |spec|
|
81
81
|
spec.name = "mathml"
|
82
82
|
spec.rubyforge_project = "mathml"
|
83
|
-
spec.version = "
|
83
|
+
spec.version = ENV["VER"] or raise "Need VER=x.y.z(.?)"
|
84
84
|
spec.summary = "MathML Library"
|
85
85
|
spec.author = "KURODA Hiraku"
|
86
86
|
spec.email = "hiraku@hinet.mydns.jp"
|
data/lib/math_ml.rb
CHANGED
@@ -153,16 +153,9 @@ module MathML
|
|
153
153
|
update_name
|
154
154
|
end
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
super
|
160
|
-
end
|
161
|
-
elsif Module.constants.include?("EimXML") && self < EimXML::Element
|
162
|
-
def write(dst=String.new, level=0, is_head=true)
|
163
|
-
update_contents
|
164
|
-
super
|
165
|
-
end
|
156
|
+
def to_xml_with_indent(dst=String.new, level=0, is_head=true)
|
157
|
+
update_contents
|
158
|
+
super
|
166
159
|
end
|
167
160
|
end
|
168
161
|
|
@@ -270,7 +263,7 @@ module MathML
|
|
270
263
|
module RE
|
271
264
|
SPACE = /(?:\s|%.*$)/
|
272
265
|
NUMERICS = /(?:\.\d+)|(?:\d+(\.\d+)?)/
|
273
|
-
OPERATORS = /[,\.\+\-\*=\/\(\)\[\]<>"
|
266
|
+
OPERATORS = /[,\.\+\-\*=\/\(\)\[\]<>"|;:!]/
|
274
267
|
ALPHABETS = /[a-zA-Z]/
|
275
268
|
BLOCK = /\A\{(.*?)\}\z/m
|
276
269
|
OPTION = /\A\[(.*)\]\z/m
|
@@ -746,7 +739,7 @@ EOS
|
|
746
739
|
parse_block
|
747
740
|
when @scanner.scan(/_/)
|
748
741
|
parse_sub
|
749
|
-
when @scanner.scan(
|
742
|
+
when @scanner.scan(/'+|\^/)
|
750
743
|
parse_sup
|
751
744
|
when @scanner.scan_command
|
752
745
|
parse_command
|
@@ -815,8 +808,27 @@ EOS
|
|
815
808
|
e = @container.pop
|
816
809
|
e = None.new unless e
|
817
810
|
e = SubSup.new(@ds && e.display_style, e) unless e.is_a?(SubSup)
|
818
|
-
raise ParseError.new("Double superscript.",
|
819
|
-
|
811
|
+
raise ParseError.new("Double superscript.", @scanner[0]) if e.sup
|
812
|
+
if /'+/=~@scanner[0]
|
813
|
+
prime = Operator.new
|
814
|
+
prime << MathML.pcstring('′'*@scanner[0].size, true)
|
815
|
+
unless @scanner.scan(/\^/)
|
816
|
+
e.sup = prime
|
817
|
+
return e
|
818
|
+
end
|
819
|
+
end
|
820
|
+
sup = parse_any("Superscript not exist.")
|
821
|
+
|
822
|
+
if prime
|
823
|
+
unless sup.is_a?(Row)
|
824
|
+
r = Row.new
|
825
|
+
r << sup
|
826
|
+
sup = r
|
827
|
+
end
|
828
|
+
sup.contents.insert(0, prime)
|
829
|
+
end
|
830
|
+
|
831
|
+
e.sup = sup
|
820
832
|
e
|
821
833
|
end
|
822
834
|
|
data/test/math_ml_test.rb
CHANGED
@@ -459,10 +459,24 @@ class TC_MathML_LaTeX_Parser < Test::Unit::TestCase
|
|
459
459
|
|
460
460
|
def test_operators
|
461
461
|
check_chr("<mo>", "</mo>", ",.+-*=/()[]|;:!")
|
462
|
-
check_entity("<mo>", "</mo>", {"<"=>"lt", ">"=>"gt", '"'=>"quot"
|
462
|
+
check_entity("<mo>", "</mo>", {"<"=>"lt", ">"=>"gt", '"'=>"quot"})
|
463
463
|
check_hash("<mo>", "</mo>", {'\backslash'=>'\\', '\%'=>'%', '\{'=>'{', '\}'=>'}', '\$'=>'$', '\#'=>'#'})
|
464
464
|
end
|
465
465
|
|
466
|
+
def test_prime
|
467
|
+
assert_equal("<msup><mi>a</mi><mo>′</mo></msup>", smml("a'"))
|
468
|
+
assert_equal("<msup><mi>a</mi><mo>′′</mo></msup>", smml("a''"))
|
469
|
+
assert_equal("<msup><mi>a</mi><mo>′′′</mo></msup>", smml("a'''"))
|
470
|
+
assert_equal("<msup><none /><mo>′</mo></msup>", smml("'"))
|
471
|
+
|
472
|
+
e = assert_raises(ParseError){smml("a^b'")}
|
473
|
+
assert_equal(["Double superscript.", "a^b", "'"], parse_error(e))
|
474
|
+
|
475
|
+
assert_equal("<msup><mi>a</mi><mrow><mo>′</mo><mi>b</mi></mrow></msup>", smml("a'^b"))
|
476
|
+
assert_equal("<msup><mi>a</mi><mrow><mo>′′′</mo><mi>b</mi></mrow></msup>", smml("a'''^b"))
|
477
|
+
assert_equal("<msup><mi>a</mi><mo>′</mo></msup><mi>b</mi>", smml("a'b"))
|
478
|
+
end
|
479
|
+
|
466
480
|
def test_sqrt
|
467
481
|
assert_equal("<msqrt><mi>a</mi></msqrt>", smml('\sqrt a'))
|
468
482
|
assert_equal("<mroot><mn>3</mn><mn>2</mn></mroot>", smml('\sqrt[2]3'))
|
metadata
CHANGED
@@ -1,57 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: mathml
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2007-10-23 00:00:00 +09:00
|
8
|
-
summary: MathML Library
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: hiraku@hinet.mydns.jp
|
12
|
-
homepage: http://mathml.rubyforge.org/
|
13
|
-
rubyforge_project: mathml
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.8.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- KURODA Hiraku
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-24 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eimxml
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email: hiraku@hinet.mydns.jp
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
31
32
|
files:
|
32
33
|
- lib
|
33
|
-
- test
|
34
|
-
- Rakefile
|
35
|
-
- README
|
36
|
-
- symbols
|
37
|
-
- lib/math_ml
|
38
34
|
- lib/math_ml.rb
|
35
|
+
- lib/math_ml
|
39
36
|
- lib/math_ml/string.rb
|
40
37
|
- lib/math_ml/util.rb
|
41
|
-
-
|
42
|
-
-
|
43
|
-
- test/string_test.rb
|
44
|
-
- test/math_ml_test_util_test.rb
|
45
|
-
- test/math_ml_test.rb
|
46
|
-
- symbols/list.txt
|
38
|
+
- README
|
39
|
+
- symbols
|
47
40
|
- symbols/fetch_symbol_test.rb
|
41
|
+
- symbols/list.txt
|
48
42
|
- symbols/fetch_symbol.rb
|
49
|
-
|
50
|
-
- test
|
43
|
+
- Rakefile
|
44
|
+
- test
|
51
45
|
- test/util_test.rb
|
52
|
-
- test/string_test.rb
|
53
46
|
- test/math_ml_test_util_test.rb
|
54
47
|
- test/math_ml_test.rb
|
48
|
+
- test/math_ml_test_util.rb
|
49
|
+
- test/string_test.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://mathml.rubyforge.org/
|
52
|
+
post_install_message:
|
55
53
|
rdoc_options:
|
56
54
|
- -S
|
57
55
|
- -w
|
@@ -60,21 +58,30 @@ rdoc_options:
|
|
60
58
|
- UTF-8
|
61
59
|
- -m
|
62
60
|
- README
|
63
|
-
|
64
|
-
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
69
75
|
requirements: []
|
70
76
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
rubyforge_project: mathml
|
78
|
+
rubygems_version: 1.0.1
|
79
|
+
signing_key:
|
80
|
+
specification_version: 2
|
81
|
+
summary: MathML Library
|
82
|
+
test_files:
|
83
|
+
- test/util_test.rb
|
84
|
+
- test/math_ml_test_util_test.rb
|
85
|
+
- test/math_ml_test.rb
|
86
|
+
- test/math_ml_test_util.rb
|
87
|
+
- test/string_test.rb
|