Skip to content

Commit

Permalink
Merge pull request #38 from mvz/immutable-strings
Browse files Browse the repository at this point in the history
Immutable strings
  • Loading branch information
joshuasiler committed Sep 13, 2017
2 parents e88dfef + 00b55ac commit 4808b36
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# encoding: utf-8
require 'rubygems'
require 'bundler'
ENV['RUBYOPT'] = nil # Necessary to prevent Bundler from *&^%$#ing up rake-compiler.

require 'rake/clean'

Expand All @@ -15,4 +14,4 @@ else
Bundler.settings.without = [:compilation]
Bundler.setup(:default, :development)
load 'tasks/rspec.rake'
end
end
2 changes: 1 addition & 1 deletion lib/redcloth/formatters/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def pba(opts)
opts.delete(:class) if filter_classes
opts.delete(:id) if filter_ids

atts = ''
atts = ''.dup
opts[:"text-align"] = opts.delete(:align)
opts[:style] += ';' if opts[:style] && (opts[:style][-1..-1] != ';')
[:float, :"text-align", :"vertical-align"].each do |a|
Expand Down
2 changes: 1 addition & 1 deletion lib/redcloth/formatters/latex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def table_open(opts)

# FIXME: need caption and label elements similar to image -> figure
def table_close(opts)
output = "\\begin{table}\n"
output = "\\begin{table}\n".dup
output << " \\centering\n"
output << " \\begin{tabular}{ #{"l " * @table[0].size }}\n"
@table.each do |row|
Expand Down
8 changes: 4 additions & 4 deletions spec/custom_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module FigureTag
def fig( opts )
label, img = opts[:text].split('|').map! {|str| str.strip}

html = %Q{<div class="img" id="figure-#{label.tr('.', '-')}">\n}
html = %Q{<div class="img" id="figure-#{label.tr('.', '-')}">\n}.dup
html << %Q{ <a class="fig" href="/images/#{img}">\n}
html << %Q{ <img src="/images/thumbs/#{img}" alt="Figure #{label}" />\n}
html << %Q{ </a>\n}
Expand All @@ -15,13 +15,13 @@ def fig( opts )

describe "custom tags" do
it "should recognize the custom tag" do
input = %Q{The first line of text.\n\n}
input = %Q{The first line of text.\n\n}.dup
input << %Q{fig. 1.1 | img.jpg\n\n}
input << %Q{The last line of text.\n}
r = RedCloth.new input
r.extend FigureTag

html = %Q{<p>The first line of text.</p>\n}
html = %Q{<p>The first line of text.</p>\n}.dup
html << %Q{<div class="img" id="figure-1-1">\n}
html << %Q{ <a class="fig" href="/images/img.jpg">\n}
html << %Q{ <img src="/images/thumbs/img.jpg" alt="Figure 1.1" />\n}
Expand All @@ -47,4 +47,4 @@ def fig( opts )

r.to_html.should == html
end
end
end
5 changes: 3 additions & 2 deletions spec/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,17 @@

if RUBY_VERSION > "1.9.0"
it "should preserve character encoding" do
input = "This is an ISO-8859-1 string"
input = "This is an ISO-8859-1 string".dup
input.force_encoding 'iso-8859-1'

output = RedCloth.new(input).to_html

output.should == "<p>This is an <span class=\"caps\">ISO</span>-8859-1 string</p>"
output.encoding.to_s.should == "ISO-8859-1"
end

it "should not raise ArgumentError: invalid byte sequence" do
s = "\xa3"
s = "\xa3".dup
s.force_encoding 'iso-8859-1'
lambda { RedCloth.new(s).to_html }.should_not raise_error
end
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def fixtures
Dir[File.join(File.dirname(__FILE__), *%w[fixtures *.yml])].each do |testfile|
testgroup = File.basename(testfile, '.yml')
num = 0
YAML::load_documents(File.open(testfile)) do |doc|
YAML::load_stream(File.open(testfile)) do |doc|
name = doc['name'] || num
@fixtures["#{testgroup} #{name}"] = doc
num += 1
end
end
@fixtures
end
end

0 comments on commit 4808b36

Please sign in to comment.