Fix Maruku Ruby 1.9 Bug
In Rbuy 1.8, ?c returns an integer. In Ruby 1.9, it returns a 1-character string. This was causing one of our LaTeX conversion functional tests to fail. Fixed.
This commit is contained in:
parent
34b63a8375
commit
063a8ca5a7
|
@ -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
|
||||
|
|
|
@ -23,19 +23,19 @@
|
|||
class String
|
||||
|
||||
# These are TeX's special characters
|
||||
LATEX_ADD_SLASH = [ ?{, ?}, ?$, ?&, ?#, ?_, ?%]
|
||||
LATEX_ADD_SLASH = [ '{', '}', '$', '&', '#', '_', '%']
|
||||
|
||||
# These, we transform to {\tt \char<ascii code>}
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue