Sha256: 1d9f5b062f9eb5e17fd33c9fe10e73b789224d0a71f10ef8b5149c5c04d5cb3c
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
require 'bundler/setup' require 'mathematical' require 'minitest/autorun' require 'minitest/pride' require 'math-to-itex' require 'pp' MTEX2MML_FIXTURES_DIR = File.join('ext', 'mathematical', 'mtex2MML', 'tests', 'fixtures') MATHJAX_TEST_DIR = File.join(MTEX2MML_FIXTURES_DIR, 'MathJax') MATHJAX_TEX_DIR = File.join(MATHJAX_TEST_DIR, 'LaTeXToMathML-tex') def fixtures_dir 'test/mathematical/fixtures' end def capture_stderr(&blk) old = $stderr $stderr = fake = StringIO.new blk.call fake.string ensure $stderr = old end def write_base64svg_to_test_file(converted) text = """ <html> <body> <img class=\"display-math\" data-math-type=\"display-math\" src=\"#{converted}\"/> </body> </html> """ File.open('test.html', 'w') { |f| f.write(text) } end def write_svg_to_test_file(converted) text = """ <html> <body> #{converted} </body> </html> """ File.open('test.html', 'w') { |f| f.write(text) } end def write_sample(source, name = nil) return unless ENV['MATHEMATICAL_GENERATE_SAMPLE'] MathToItex(source).convert do |eq, type| svg_content = Mathematical.new(:base64 => false).render(eq) # remove \ and $, remove whitespace, keep alphanums, remove extraneous - and trailing - filename = name || eq.gsub(/[\$\\]*/, '').gsub(/\s+/, '-').gsub(/[^a-zA-Z\d]/, '-').gsub(/-{2,}/, '-').gsub(/-$/, '') File.open("samples/fixtures/#{filename}.svg", 'w') { |file| file.write svg_content[:data] } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mathematical-1.5.12 | test/test_helper.rb |
mathematical-1.5.0 | test/test_helper.rb |
mathematical-1.4.2 | test/test_helper.rb |