Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
4e554c4c committed Nov 30, 2023
2 parents 5beaddc + d9ee16a commit ba88e1e
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Linting

on:
pull_request:
paths:
- "**/*.rb"
branches:
- main

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
script/install_linux_deps
- name: Install MacOS packages
if: ${{ matrix.os == 'macos-11.0' }}
if: ${{ matrix.os == 'macos-latest' }}
run: script/install_macos_deps

- name: Set up Ruby ${{ matrix.ruby-version }}
Expand Down
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[submodule "ext/mathematical/lasem"]
path = ext/mathematical/lasem
url = https://gitlab.gnome.org/GNOME/lasem.git
url = https://github.com/LasemProject/lasem.git
ignore = dirty
branch = main
[submodule "ext/mathematical/mtex2MML"]
path = ext/mathematical/mtex2MML
url = https://github.com/gjtorikian/mtex2MML
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ inherit_gem:
rubocop-standard:
- config/default.yml
- config/minitest.yml

AllCops:
Exclude:
- 'ext/mathematical/mtex2MML/**/*'
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [v1.6.17] - 30-11-2023
## What's Changed
* Fix tests by @4e554c4c in https://github.com/gjtorikian/mathematical/pull/121
* Update mtex2MML to 43f9e36f4b01013100f86073ac70d1855b3cc4cb by @lukel97 in https://github.com/gjtorikian/mathematical/pull/120
* Update README by @4e554c4c in https://github.com/gjtorikian/mathematical/pull/122
* Update Lasem by @4e554c4c in https://github.com/gjtorikian/mathematical/pull/123
* bump version by @4e554c4c in https://github.com/gjtorikian/mathematical/pull/125

## New Contributors
* @4e554c4c made their first contribution in https://github.com/gjtorikian/mathematical/pull/121
* @lukel97 made their first contribution in https://github.com/gjtorikian/mathematical/pull/120

**Full Changelog**: https://github.com/gjtorikian/mathematical/compare/v1.6.16...v1.6.17
## [v1.6.16] - 20-07-2023
null
## [v1.6.15] - 20-07-2023
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Quickly convert math equations into beautiful SVGs (or PNGs/MathML).

![Mathematical](https://i.imgur.com/JC7HT32.gif)

## ⚠️ Maintenance Status ⚠️

SVG and especially PNG generation is currently unmaintained. This library should primarily be used for MathML generation.

Please reach out if you would like to mantain SVG and PNG portions of the library.

## Installation

Add this line to your application's Gemfile:
Expand Down Expand Up @@ -244,7 +250,7 @@ no intermediate binaries. It was, unfortunately, a bit slow: for an arbitrary
composition of 880 equations, it took about eight seconds to complete. Could I
do better?

* I came across [Lasem](https://wiki.gnome.org/action/show/Projects/Lasem?action=show&redirect=Lasem),
* I came across [Lasem](https://github.com/LasemProject/lasem),
which met every need. It has no external binary dependencies (only library packages),
can convert directly to SVG, and it's fast. The same arbitrary 880 equations were
rendered in moments.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Rake::Task[:test].prerequisites
task build: [:clean]

Rake::Task[:clean].enhance do
Dir.chdir(LASEM_DIR) { puts %x(git clean -fdx); }
Dir.chdir(LASEM_DIR) { puts %x(git clean -fdx) }
end

desc "Copy samples to gh-pages"
Expand Down
2 changes: 1 addition & 1 deletion ext/mathematical/lasem
Submodule lasem updated from d47c0a to 62b629
2 changes: 1 addition & 1 deletion ext/mathematical/mtex2MML
2 changes: 1 addition & 1 deletion lib/mathematical/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def option_exists?(option)
raise(TypeError, "delimiter type does not exist: #{option}")
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/mathematical/corrections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def apply_corrections(maths)
# inside itex equations. So "<" and ">" are significant.
# To obtain a less-than or greater-than sign, you should use \lt or \gt, respectively.
def adjust_lt_gt(maths)
maths.gsub(/</, '\lt').gsub(/>/, '\gt')
maths.gsub("<", '\lt').gsub(">", '\gt')
end
end
end
2 changes: 1 addition & 1 deletion lib/mathematical/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Mathematical
VERSION = "1.6.16"
VERSION = "1.6.17"
end
2 changes: 1 addition & 1 deletion script/install_linux_deps
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
export CC=gcc

sudo apt-get -qq -y install bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev
sudo apt-get -qq -y install bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev libwebp-dev

# not necessary for tests, but is for any production/development environment
if [[ ! -v CI ]]; then
Expand Down
6 changes: 3 additions & 3 deletions test/mathematical/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "test_helper"
require "nokogiri"

module Mathematical
class BasicTest < MiniTest::Test
class Mathematical
class BasicTest < Minitest::Test
def test_it_has_a_version
assert(Mathematical::VERSION)
end
Expand All @@ -14,7 +14,7 @@ def test_multiple_calls
render.render('$\pi$')
output = render.render('$\pi$')[:data]

assert_equal(1, output.scan(/<svg/).size, "should only contain one svg")
assert_equal(1, output.scan("<svg").size, "should only contain one svg")

# assert the SVG actually rendered
doc = Nokogiri::HTML(output)
Expand Down
4 changes: 2 additions & 2 deletions test/mathematical/corrections_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require "test_helper"

module Mathematical
class CorrectionsTest < MiniTest::Test
class Mathematical
class CorrectionsTest < Minitest::Test
def setup
@render = Mathematical.new
end
Expand Down
4 changes: 2 additions & 2 deletions test/mathematical/delimiters_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require "test_helper"

module Mathematical
class BasicTest < MiniTest::Test
class Mathematical
class BasicTest < Minitest::Test
def test_single_dollar
render = Mathematical.new(delimiter: :DOLLAR, format: :mathml)

Expand Down
8 changes: 4 additions & 4 deletions test/mathematical/fixtures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "test_helper"
require "math-to-itex"

module Mathematical
class FixturesTest < MiniTest::Test
class Mathematical
class FixturesTest < Minitest::Test
# the same SVGs sometimes get random id values, throwing off the tests
def strip_id(blob)
blob.gsub(/id="surface.+?"/, "")
Expand All @@ -17,7 +17,7 @@ def strip_id(blob)
source = File.read(before)

if ENV["MATHEMATICAL_GENERATE_SAMPLE"]
next unless /compliance/.match?(name)
next unless name.include?("compliance")

write_sample(source)
end
Expand All @@ -28,7 +28,7 @@ def strip_id(blob)
%(<img class="#{type}-math" data-math-type="#{type}-math" src="#{svg_content[:data]}"/>)
end.rstrip

expected_file = before.sub(/before/, "after").sub(/text/, "html")
expected_file = before.sub("before", "after").sub("text", "html")

File.open(expected_file, "w") { |file| file.write(actual) } unless ENV["DEBUG_MATHEMATICAL"].nil?

Expand Down
15 changes: 7 additions & 8 deletions test/mathematical/maliciousness_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require "test_helper"

module Mathematical
class MaliciousnessTest < MiniTest::Test
class Mathematical
class MaliciousnessTest < Minitest::Test
def test_it_does_not_error_on_unrecognized_commands
render = Mathematical.new
# In mtex2MML, we raise a ParseError, but Mathematical suppresses it and returns the string.
Expand Down Expand Up @@ -60,9 +60,8 @@ def test_it_does_not_blow_up_on_bad_options
assert_equal('$a \ne b$', output[:data])
assert_equal(output[:exception].class, Mathematical::MaxsizeError)

render = Mathematical.new({ maxsize: 2**80 })
assert_raises(TypeError) do
render.render('$a \ne b$')
render = Mathematical.new({ maxsize: 2**80 })
end
end

Expand Down Expand Up @@ -123,11 +122,11 @@ def test_it_parses_all_possible_array_elements
end

assert_equal(3, output.length)
assert_equal(Hash, output.first.class)
assert_equal(Hash, output.last.class)
assert_instance_of(Hash, output.first)
assert_instance_of(Hash, output.last)

assert_equal("$/this___istotallyfake$", output[1][:data])
assert_equal(Mathematical::ParseError, output[1][:exception].class)
assert_instance_of(Mathematical::ParseError, output[1][:exception])
assert_match("Failed to parse mtex", output[1][:exception].message)

# array errors also output to STDERR
Expand All @@ -145,7 +144,7 @@ def test_it_passes_a_legible_error_for_maxsize
assert_equal(1, output.length)

assert_equal('$a \ne b$', output[0][:data])
assert_equal(Mathematical::MaxsizeError, output[0][:exception].class)
assert_instance_of(Mathematical::MaxsizeError, output[0][:exception])
assert_match("Size of latex string is greater than the maxsize", output[0][:exception].message)

# array errors also output to STDERR
Expand Down
4 changes: 2 additions & 2 deletions test/mathematical/mathjax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "test_helper"
require "nokogiri"

module Mathematical
class MathJaxTest < MiniTest::Test
class Mathematical
class MathJaxTest < Minitest::Test
render_svg = Mathematical.new

SKIPPED = []
Expand Down
4 changes: 2 additions & 2 deletions test/mathematical/mathml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# rubocop:disable Lint/ImplicitStringConcatenation
require "test_helper"

module Mathematical
class MathMLTest < MiniTest::Test
class Mathematical
class MathMLTest < Minitest::Test
def test_it_returns_mathml
string = ""'
$$
Expand Down
7 changes: 4 additions & 3 deletions test/mathematical/multiples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require "test_helper"

module Mathematical
class MultiplesTest < MiniTest::Test
class Mathematical
class MultiplesTest < Minitest::Test
def setup
@render = Mathematical.new(base64: true)
end
Expand All @@ -20,7 +20,7 @@ def test_it_works_for_a_single_numbered_equation
output = @render.render([string])
svg = output.first[:data]

assert_equal(1, svg.scan(/svg\+xml;/).size, "should only contain one svg")
assert_equal(1, svg.scan("svg+xml;").size, "should only contain one svg")
assert_match("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My", svg)
end

Expand All @@ -46,6 +46,7 @@ def test_it_works_for_many_equations
end

def test_it_properly_accounts_for_equations
skip("png tests are currently unsupported")
inputs = []
(1..2).each do |i|
string = """
Expand Down
4 changes: 2 additions & 2 deletions test/mathematical/performance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "test_helper"
require "benchmark"

module Mathematical
class BasicTest < MiniTest::Test
class Mathematical
class BasicTest < Minitest::Test
def test_it_handles_big_files
big_file = File.read("test/mathematical/fixtures/performance/big_file.text")
speed = Benchmark.realtime do
Expand Down
5 changes: 3 additions & 2 deletions test/mathematical/png_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

require "test_helper"

module Mathematical
class PNGTest < MiniTest::Test
class Mathematical
class PNGTest < Minitest::Test
def before
File.delete("#{fixtures_dir}/png/pmatrix.png") if File.exist?("#{fixtures_dir}/png/pmatrix.png")
end

def test_it_creates_a_png
skip("png tests are currently unsupported")
string = ""'
$$
\begin{pmatrix}
Expand Down

0 comments on commit ba88e1e

Please sign in to comment.