File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,10 @@ def handle_RDOCLINK(url) # :nodoc:
98
98
99
99
gen_url CGI . escapeHTML ( url ) , CGI . escapeHTML ( text )
100
100
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
+ # "path/to/image.jpg:alt text" => ["path/to/image.jpg", "alt text"]
103
+ # "http://example.com/path/to/image.jpg:alt text" => ["http://example.com/path/to/image.jpg", "alt text"]
104
+ url , alt = $'. split ( /:(?!\/ )/ , 2 )
102
105
if alt && !alt . empty?
103
106
%[<img src="#{ CGI . escapeHTML ( url ) } " alt="#{ CGI . escapeHTML ( alt ) } ">]
104
107
else
Original file line number Diff line number Diff line change @@ -749,6 +749,36 @@ def test_convert_TIDYLINK_image
749
749
assert_not_include result , "<script>"
750
750
end
751
751
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
+
752
782
def test_convert_TIDYLINK_rdoc_label
753
783
result = @to . convert '{foo}[rdoc-label:foottext-1]'
754
784
You can’t perform that action at this time.
0 commit comments