2012-11-27 08:28:14 +04:00
|
|
|
require 'rdoc/test_case'
|
2011-08-24 03:53:49 +04:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
class TestRDocMarkupFormatter < RDoc::TestCase
|
2011-08-24 03:53:49 +04:00
|
|
|
|
|
|
|
class ToTest < RDoc::Markup::Formatter
|
|
|
|
|
|
|
|
def initialize markup
|
2012-11-27 08:28:14 +04:00
|
|
|
super nil, markup
|
2011-08-24 03:53:49 +04:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
add_tag :TT, '<code>', '</code>'
|
2011-08-24 03:53:49 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def accept_paragraph paragraph
|
|
|
|
@res << attributes(paragraph.text)
|
|
|
|
end
|
|
|
|
|
|
|
|
def attributes text
|
|
|
|
convert_flow @am.flow text.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def handle_special_CAPS special
|
|
|
|
"handled #{special.text}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_accepting
|
|
|
|
@res = ""
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_accepting
|
|
|
|
@res
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
2012-11-27 08:28:14 +04:00
|
|
|
super
|
|
|
|
|
|
|
|
@markup = @RM.new
|
2011-08-24 03:53:49 +04:00
|
|
|
@markup.add_special(/[A-Z]+/, :CAPS)
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@attribute_manager = @markup.attribute_manager
|
|
|
|
@attributes = @attribute_manager.attributes
|
|
|
|
|
2011-08-24 03:53:49 +04:00
|
|
|
@to = ToTest.new @markup
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@caps = @attributes.bitmap_for :CAPS
|
|
|
|
@special = @attributes.bitmap_for :_SPECIAL_
|
|
|
|
@tt = @attributes.bitmap_for :TT
|
2011-08-24 03:53:49 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_convert_tt_special
|
2012-11-27 08:28:14 +04:00
|
|
|
converted = @to.convert '<code>AAA</code>'
|
2011-08-24 03:53:49 +04:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
assert_equal '<code>AAA</code>', converted
|
2011-08-24 03:53:49 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|