Permalink
Browse files

Merge pull request #38 from mvz/immutable-strings

Immutable strings
  • Loading branch information...
joshuasiler committed Sep 13, 2017
2 parents e88dfef + 00b55ac commit 4808b36d7063a7cfade89378d879a9134cd30a3e
Showing with 12 additions and 12 deletions.
  1. +1 −2 Rakefile
  2. +1 −1 lib/redcloth/formatters/base.rb
  3. +1 −1 lib/redcloth/formatters/latex.rb
  4. +4 −4 spec/custom_tags_spec.rb
  5. +3 −2 spec/parser_spec.rb
  6. +2 −2 spec/spec_helper.rb
@@ -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'

@@ -15,4 +14,4 @@ else
Bundler.settings.without = [:compilation]
Bundler.setup(:default, :development)
load 'tasks/rspec.rake'
end
end
@@ -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|
@@ -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|
@@ -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}
@@ -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}
@@ -47,4 +47,4 @@ def fig( opts )

r.to_html.should == html
end
end
end
@@ -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
@@ -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.