Skip to content

Commit d194163

Browse files
committed
Specials inside tt are no longer converted
1 parent 0eaa328 commit d194163

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

History.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Travis D. Warlick, Jr.
66
* Image paths at HTTPS URLs are now turned into +<img>+ tags. Pull
77
Request #60 by James Mead
8+
* Markup defined by RDoc::Markup#add_special inside a <tt><tt></tt> is no
9+
longer converted.
810

911
=== 3.9.2 / 2011-08-11
1012

Manifest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ test/test_rdoc_include.rb
136136
test/test_rdoc_markup.rb
137137
test/test_rdoc_markup_attribute_manager.rb
138138
test/test_rdoc_markup_document.rb
139+
test/test_rdoc_markup_formatter.rb
139140
test/test_rdoc_markup_indented_paragraph.rb
140141
test/test_rdoc_markup_paragraph.rb
141142
test/test_rdoc_markup_parser.rb

lib/rdoc/markup/formatter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def convert_flow(flow)
8888
##
8989
# Converts added specials. See RDoc::Markup#add_special
9090

91-
def convert_special(special)
91+
def convert_special special
92+
return special.text if in_tt?
93+
9294
handled = false
9395

9496
RDoc::Markup::Attribute.each_name_of special.type do |name|

test/test_rdoc_markup_formatter.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
require 'rubygems'
2+
require 'minitest/autorun'
3+
require 'rdoc'
4+
require 'rdoc/markup'
5+
require 'rdoc/markup/formatter'
6+
7+
class TestRDocMarkupFormatter < MiniTest::Unit::TestCase
8+
9+
class ToTest < RDoc::Markup::Formatter
10+
11+
def initialize markup
12+
super
13+
14+
add_tag :TT, '<tt>', '</tt>'
15+
end
16+
17+
def accept_paragraph paragraph
18+
@res << attributes(paragraph.text)
19+
end
20+
21+
def attributes text
22+
convert_flow @am.flow text.dup
23+
end
24+
25+
def handle_special_CAPS special
26+
"handled #{special.text}"
27+
end
28+
29+
def start_accepting
30+
@res = ""
31+
end
32+
33+
def end_accepting
34+
@res
35+
end
36+
37+
end
38+
39+
def setup
40+
@markup = RDoc::Markup.new
41+
@markup.add_special(/[A-Z]+/, :CAPS)
42+
43+
@to = ToTest.new @markup
44+
45+
@caps = RDoc::Markup::Attribute.bitmap_for :CAPS
46+
@special = RDoc::Markup::Attribute.bitmap_for :_SPECIAL_
47+
@tt = RDoc::Markup::Attribute.bitmap_for :TT
48+
end
49+
50+
def test_convert_tt_special
51+
converted = @to.convert '<tt>AAA</tt>'
52+
53+
assert_equal '<tt>AAA</tt>', converted
54+
end
55+
56+
end
57+

0 commit comments

Comments
 (0)