File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,11 @@ def handle_RDOCLINK(url) # :nodoc:
9898
9999 gen_url CGI . escapeHTML ( url ) , CGI . escapeHTML ( text )
100100 when /^rdoc-image:/
101- url , alt = $'. split ( ":" , 2 ) # Split the string after "rdoc-image:" into url and alt
101+ # Split the string after "rdoc-image:" into url and alt
102+ url_alt = $'
103+ split_pos = url_alt . index ( %r{:[^/]} )
104+ url = split_pos ? url_alt [ 0 , split_pos ] : url_alt
105+ alt = split_pos ? url_alt [ split_pos + 1 , url_alt . size ] : nil
102106 if alt && !alt . empty?
103107 %[<img src="#{ CGI . escapeHTML ( url ) } " alt="#{ CGI . escapeHTML ( alt ) } ">]
104108 else
Original file line number Diff line number Diff line change @@ -749,6 +749,36 @@ def test_convert_TIDYLINK_image
749749 assert_not_include result , "<script>"
750750 end
751751
752+ def test_convert_TIDYLINK_image_with_alt
753+ result =
754+ @to . convert '{rdoc-image:path/to/image.jpg:alt text}[http://example.com]'
755+
756+ expected =
757+ "\n <p><a href=\" http://example.com\" ><img src=\" path/to/image.jpg\" alt=\" alt text\" ></a></p>\n "
758+
759+ assert_equal expected , result
760+ end
761+
762+ def test_convert_TIDYLINK_image_external
763+ result =
764+ @to . convert '{rdoc-image:http://example.com/path/to/image.jpg}[http://example.com]'
765+
766+ expected =
767+ "\n <p><a href=\" http://example.com\" ><img src=\" http://example.com/path/to/image.jpg\" ></a></p>\n "
768+
769+ assert_equal expected , result
770+ end
771+
772+ def test_convert_TIDYLINK_image_external_with_alt
773+ result =
774+ @to . convert '{rdoc-image:http://example.com/path/to/image.jpg:alt text}[http://example.com]'
775+
776+ expected =
777+ "\n <p><a href=\" http://example.com\" ><img src=\" http://example.com/path/to/image.jpg\" alt=\" alt text\" ></a></p>\n "
778+
779+ assert_equal expected , result
780+ end
781+
752782 def test_convert_TIDYLINK_rdoc_label
753783 result = @to . convert '{foo}[rdoc-label:foottext-1]'
754784
You can’t perform that action at this time.
0 commit comments