From 17e39e50fab9f5396e243b6c46315fc2a6893d78 Mon Sep 17 00:00:00 2001 From: Rodrigo Pavano Date: Sat, 24 Nov 2012 12:43:08 -0300 Subject: [PATCH] added support for non us-ascii characters in presentations --- lib/keydown/tasks/slides.rb | 4 ++-- spec/fixtures/with_non_usascii_chars.md | 13 +++++++++++++ spec/tasks/slides_spec.rb | 20 +++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/with_non_usascii_chars.md diff --git a/lib/keydown/tasks/slides.rb b/lib/keydown/tasks/slides.rb index 5060c29..3ec2a2e 100644 --- a/lib/keydown/tasks/slides.rb +++ b/lib/keydown/tasks/slides.rb @@ -19,7 +19,7 @@ def slides(file) say "Creating Keydown presentation from #{file}", :yellow - slide_deck = SlideDeck.new(File.new(file).read) + slide_deck = SlideDeck.new(File.new(file, 'rb').read) backgrounds = slide_deck.slides.collect do |slide| slide.background_image unless slide.background_image.empty? end.compact @@ -41,4 +41,4 @@ def slides(file) end end end -end \ No newline at end of file +end diff --git a/spec/fixtures/with_non_usascii_chars.md b/spec/fixtures/with_non_usascii_chars.md new file mode 100644 index 0000000..4bb1404 --- /dev/null +++ b/spec/fixtures/with_non_usascii_chars.md @@ -0,0 +1,13 @@ +# Kermit the Frog Says... + +!SLIDE + +# Esta presentación + +!SLIDE foo + +# es traída a ustedes por + +!SLIDE foo bar + +# un ñandú diff --git a/spec/tasks/slides_spec.rb b/spec/tasks/slides_spec.rb index 6602463..1c322d7 100644 --- a/spec/tasks/slides_spec.rb +++ b/spec/tasks/slides_spec.rb @@ -213,4 +213,22 @@ @doc.css('link[@href="css/keydown.css"]').length.should == 1 end end -end \ No newline at end of file + + describe "for a presentation that has non US-ASCII characters" do + before(:each) do + capture_output do + Dir.chdir project_dir do + file_name = "with_non_usascii_chars.md" + system "cp #{Keydown::Tasks.source_root}/spec/fixtures/#{file_name} #{tmp_dir}/test/#{file_name}" + + @thor.invoke Keydown::Tasks, ["slides", file_name] + + @file = File.new('with_non_usascii_chars.html') + @doc = Nokogiri(@file) + end + end + end + + it_should_behave_like "generating a presentation file" + end +end