diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index de43c267..3d0ce78c 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -1263,6 +1263,23 @@ HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWa +\end{document} +!, r.body + end + + def test_tex_character_conversions + @wiki.write_page('wiki1', 'Page2', + "Page2 contents { & ^ <.\n", + Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) + r = process('tex', 'web' => 'wiki1', 'id' => 'Page2') + assert_response(:success) + + assert_equal @tex_header1 + @tex_header2 + %q!\section*{Page2} + +Page2 contents \{ \& {\tt \symbol{94}} {\tt \symbol{60}}. + + + \end{document} !, r.body end diff --git a/vendor/plugins/maruku/lib/maruku/output/to_latex_strings.rb b/vendor/plugins/maruku/lib/maruku/output/to_latex_strings.rb index da043a79..ab54ba43 100644 --- a/vendor/plugins/maruku/lib/maruku/output/to_latex_strings.rb +++ b/vendor/plugins/maruku/lib/maruku/output/to_latex_strings.rb @@ -23,19 +23,19 @@ class String # These are TeX's special characters - LATEX_ADD_SLASH = [ ?{, ?}, ?$, ?&, ?#, ?_, ?%] + LATEX_ADD_SLASH = [ '{', '}', '$', '&', '#', '_', '%'] # These, we transform to {\tt \char} - LATEX_TO_CHARCODE = [ ?^, ?~, ?>,?<] + LATEX_TO_CHARCODE = [ '^', '~', '>', '<'] def escape_to_latex(s) s2 = "" - s.each_byte do |b| + s.each_char do |b| if LATEX_TO_CHARCODE.include? b - s2 += "{\\tt \\char#{b}}" + s2 += "{\\tt \\symbol{#{b.ord}}}" elsif LATEX_ADD_SLASH.include? b s2 << ?\\ << b - elsif b == ?\\ + elsif b == '\\' # there is no backslash in cmr10 fonts s2 += "$\\backslash$" else