math_ml 0.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +339 -0
- data/lib/math_ml/element.rb +233 -225
- data/lib/math_ml/latex/builtin/symbol.rb +546 -546
- data/lib/math_ml/latex/builtin.rb +3 -3
- data/lib/math_ml/latex.rb +1140 -1103
- data/lib/math_ml/string.rb +17 -16
- data/lib/math_ml/symbol/character_reference.rb +2100 -2101
- data/lib/math_ml/symbol/entity_reference.rb +2100 -2100
- data/lib/math_ml/symbol/utf8.rb +2100 -2102
- data/lib/math_ml/util.rb +350 -339
- data/lib/math_ml.rb +14 -14
- metadata +43 -75
- data/Rakefile +0 -60
- data/Rakefile.utirake +0 -392
- data/spec/math_ml/element_spec.rb +0 -32
- data/spec/math_ml/latex/macro_spec.rb +0 -122
- data/spec/math_ml/latex/parser_spec.rb +0 -580
- data/spec/math_ml/latex/scanner_spec.rb +0 -202
- data/spec/math_ml/string_spec.rb +0 -29
- data/spec/math_ml/util_spec.rb +0 -700
- data/spec/math_ml_spec.rb +0 -14
- data/spec/util.rb +0 -43
data/spec/math_ml_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "math_ml"
|
2
|
-
|
3
|
-
describe MathML do
|
4
|
-
it "should not raise error when math_ml.rb is required twice" do
|
5
|
-
if require("lib/math_ml")
|
6
|
-
lambda{MathML::LaTeX::Parser.new}.should_not raise_error
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
it ".pcstring" do
|
11
|
-
MathML.pcstring('<>&"\'').to_s.should == "<>&"'"
|
12
|
-
MathML.pcstring('<tag>&"\'</tag>', true).to_s.should == '<tag>&"\'</tag>'
|
13
|
-
end
|
14
|
-
end
|
data/spec/util.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
module MathML
|
3
|
-
module Spec
|
4
|
-
module Util
|
5
|
-
def raise_parse_error(message, done, rest)
|
6
|
-
begin
|
7
|
-
matcher_class = RSpec::Matchers::DSL::Matcher
|
8
|
-
rescue NameError
|
9
|
-
matcher_class = RSpec::Matchers::Matcher
|
10
|
-
end
|
11
|
-
matcher_class.new(:raise_parse_error){
|
12
|
-
match do |given|
|
13
|
-
begin
|
14
|
-
given.call
|
15
|
-
@error = nil
|
16
|
-
rescue Exception
|
17
|
-
@error = $!
|
18
|
-
end
|
19
|
-
@error.is_a?(MathML::LaTeX::ParseError) &&
|
20
|
-
[@error.message, @error.done, @error.rest] == [message, done, rest]
|
21
|
-
end
|
22
|
-
}.for_expected
|
23
|
-
end
|
24
|
-
|
25
|
-
def new_parser
|
26
|
-
MathML::LaTeX::Parser.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def math_ml(src, display_style=false, parser=nil)
|
30
|
-
parser ||= @parser || new_parser
|
31
|
-
parser.parse(src, display_style)
|
32
|
-
end
|
33
|
-
|
34
|
-
def strip_math_ml(math_ml)
|
35
|
-
math_ml.to_s.gsub(/>\s*/, ">").gsub(/\s*</, "<")[/\A<math [^>]*>(.*)<\/math>\Z/m, 1]
|
36
|
-
end
|
37
|
-
|
38
|
-
def smml(src, display_style=false, parser=nil)
|
39
|
-
strip_math_ml(math_ml(src, display_style, parser))
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|