2008-07-17 20:46:16 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'rdoc/markup'
|
|
|
|
require 'rdoc/markup/to_html'
|
|
|
|
|
2008-09-24 22:43:03 -04:00
|
|
|
class TestRDocMarkupToHtml < Test::Unit::TestCase
|
2008-07-17 20:46:16 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
@am = RDoc::Markup::AttributeManager.new
|
|
|
|
@th = RDoc::Markup::ToHtml.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_tt_formatting
|
2008-09-24 22:43:03 -04:00
|
|
|
assert_equal "<p>\n<tt>--</tt> — <tt>cats'</tt> cats’\n</p>\n",
|
|
|
|
util_format("<tt>--</tt> -- <tt>cats'</tt> cats'")
|
2008-07-17 20:46:16 -04:00
|
|
|
assert_equal "<p>\n<b>—</b>\n</p>\n", util_format("<b>--</b>")
|
|
|
|
end
|
|
|
|
|
2008-09-24 22:43:03 -04:00
|
|
|
def test_convert_string_fancy
|
|
|
|
#
|
|
|
|
# The HTML typesetting is broken in a number of ways, but I have fixed
|
|
|
|
# the most glaring issues for single and double quotes. Note that
|
|
|
|
# "strange" symbols (periods or dashes) need to be at the end of the
|
|
|
|
# test case strings in order to suppress cross-references.
|
|
|
|
#
|
|
|
|
assert_equal "<p>\n“cats”.\n</p>\n", util_format("\"cats\".")
|
|
|
|
assert_equal "<p>\n‘cats’.\n</p>\n", util_format("\'cats\'.")
|
|
|
|
assert_equal "<p>\ncat’s-\n</p>\n", util_format("cat\'s-")
|
|
|
|
end
|
|
|
|
|
2008-07-17 20:46:16 -04:00
|
|
|
def util_fragment(text)
|
|
|
|
RDoc::Markup::Fragment.new 0, nil, nil, text
|
|
|
|
end
|
|
|
|
|
|
|
|
def util_format(text)
|
|
|
|
fragment = util_fragment text
|
|
|
|
|
|
|
|
@th.start_accepting
|
|
|
|
@th.accept_paragraph @am, fragment
|
|
|
|
@th.end_accepting
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|