math_ml 0.13 → 1.0.0

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/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 == "&lt;&gt;&amp;&quot;&apos;"
12
- MathML.pcstring('<tag>&amp;"\'</tag>', true).to_s.should == '<tag>&amp;"\'</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