@@ -176,16 +176,15 @@ def in_tidylink_label?
176176 # When a tidy link is <tt>{rdoc-image:path/to/image.jpg:alt text}[http://example.com]</tt>,
177177 # label part is normally considered RDOCLINK <tt>rdoc-image:path/to/image.jpg:alt</tt> and a text <tt>" text"</tt>
178178 # but RDoc's test code expects the whole label part to be treated as RDOCLINK only in tidy link label.
179+ # When a tidy link is <tt>{^1}[url]</tt> or <tt>{*1}[url]</tt>, the label part needs to drop leading * or ^.
179180 # TODO: reconsider this workaround.
180181
181- def apply_tidylink_label_special_regexp_handling ( label )
182- @markup . regexp_handlings . each do |pattern , name |
183- if ( pattern =~ label ) == 0
184- # Prefix of a label matches to regexp handling, pass the whole label to it.
185- return public_send ( :"handle_regexp_#{ name } " , label )
186- end
187- end
188- nil
182+ def apply_tidylink_label_special_handling ( label , url )
183+ # ^1 *1 will be converted to just 1 in tidy link label.
184+ return label [ 1 ..] if label . match? ( /\A [*^]\d +\z / )
185+
186+ # rdoc-image in label specially allows spaces in alt text.
187+ return handle_RDOCLINK ( label ) if label . start_with? ( 'rdoc-image:' )
189188 end
190189
191190 def handle_TIDYLINK ( label_part , url )
@@ -202,10 +201,9 @@ def handle_TIDYLINK(label_part, url)
202201 raw_label = label_part [ 0 ]
203202
204203 @in_tidylink_label = true
205- special = apply_tidylink_label_special_regexp_handling ( raw_label )
204+ special = apply_tidylink_label_special_handling ( raw_label , url )
206205 @in_tidylink_label = false
207206
208- special ||= raw_label [ 1 ..] if raw_label . match? ( /\A [*^]\d +\z / )
209207 if special
210208 tag = gen_url ( CGI . escapeHTML ( url ) , special )
211209 unless tag . empty?
0 commit comments