diff --git a/.gitignore b/.gitignore index e69de29..b844b14 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +Gemfile.lock diff --git a/features/step_definitions/latex.rb b/features/step_definitions/latex.rb new file mode 100644 index 0000000..aba45b2 --- /dev/null +++ b/features/step_definitions/latex.rb @@ -0,0 +1,7 @@ +When /^I decode the string '([^']*)'$/ do |string| + @result = LaTeX.decode(string) +end + +Then /^the result should be '([^']*)'$/ do |value| + @result.should == value +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..85d46ac --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1 @@ +require 'latex/decode' \ No newline at end of file diff --git a/features/umlauts.feature b/features/umlauts.feature new file mode 100644 index 0000000..4aff357 --- /dev/null +++ b/features/umlauts.feature @@ -0,0 +1,7 @@ +Feature: Decode LaTeX umlauts + As a hacker who works with LaTeX + I want to be able to decode LaTeX umlauts + + Scenario: German umlauts + When I decode the string '\"a\"o\"u' + Then the result should be 'äöü' \ No newline at end of file diff --git a/lib/latex/decode.rb b/lib/latex/decode.rb index e6bf50c..4903e96 100644 --- a/lib/latex/decode.rb +++ b/lib/latex/decode.rb @@ -1,10 +1,13 @@ +# coding: utf-8 require 'latex/decode/version' module LaTeX class << self def decode (string) - string + return string unless string.is_a? String + + string.gsub(/\\"a/, 'ä').gsub(/\\"o/, 'ö').gsub(/\\"u/, 'ü') end end end \ No newline at end of file