Skip to content

Commit

Permalink
Fix compatibility with --enable-frozen-string-literal
Browse files Browse the repository at this point in the history
Since Ruby 2.4, Ruby can be launched with `--enable-frozen-string-literal`.
  • Loading branch information
byroot authored and pepijnve committed Oct 31, 2024
1 parent 90d210c commit c415305
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ jobs:
matrix:
ruby: [jruby, 2.3, 2.4, 2.5, 2.6, 2.7]
os: [ubuntu-latest]
rubyopt: [""]
include:
- ruby: 2.7
os: ubuntu-latest
rubyopt: "--enable-frozen-string-literal --debug-frozen-string-literal"

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -17,4 +23,6 @@ jobs:
- name: Build
run: bundle install --jobs 4 --retry 3
- name: Test
env:
RUBYOPT: ${{ matrix.rubyopt }}
run: bundle exec rake test
2 changes: 1 addition & 1 deletion lib/asciimath/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(opts = {})
@prefix = opts[:prefifx] || ''
@inline = opts[:inline]
@escape_non_ascii = opts.fetch(:escape_non_ascii, true)
@html = ''
@html = ''.dup
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/asciimath/latex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LatexBuilder
attr_reader :symbol_table

def initialize(symbol_table = nil)
@latex = ''
@latex = ''.dup
@symbol_table = symbol_table.nil? ? DEFAULT_DISPLAY_SYMBOL_TABLE : symbol_table
end

Expand Down
2 changes: 1 addition & 1 deletion lib/asciimath/mathml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MathMLBuilder < ::AsciiMath::MarkupBuilder
def initialize(opts = {})
super(opts[:symbol_table] || ::AsciiMath::MarkupBuilder.default_display_symbol_table(fix_phi: opts.fetch(:fix_phi, true)))
@prefix = opts[:prefix] || ''
@mathml = ''
@mathml = ''.dup
if opts[:msword]
@row_mode = :force
@fence_mode = :fenced
Expand Down
2 changes: 1 addition & 1 deletion lib/asciimath/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def convert_node(node, converter)
end

def convert_to_color(color_expression)
s = ""
s = "".dup
append_color_text(s, color_expression)

case s
Expand Down

0 comments on commit c415305

Please sign in to comment.