Show More
@@ -379,8 +379,10 b' var IPython = (function (IPython) {' | |||||
379 | OutputArea.prototype.append_text = function (data, element, extra_class) { |
|
379 | OutputArea.prototype.append_text = function (data, element, extra_class) { | |
380 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_text"); |
|
380 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_text"); | |
381 | // escape ANSI & HTML specials in plaintext: |
|
381 | // escape ANSI & HTML specials in plaintext: | |
|
382 | data = utils.wrapUrls(data); | |||
382 | data = utils.fixConsole(data); |
|
383 | data = utils.fixConsole(data); | |
383 | data = utils.fixCarriageReturn(data); |
|
384 | data = utils.fixCarriageReturn(data); | |
|
385 | data = utils.autoLinkUrls(data); | |||
384 | if (extra_class){ |
|
386 | if (extra_class){ | |
385 | toinsert.addClass(extra_class); |
|
387 | toinsert.addClass(extra_class); | |
386 | } |
|
388 | } |
@@ -83,6 +83,24 b' IPython.utils = (function (IPython) {' | |||||
83 | return txt; |
|
83 | return txt; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
|
86 | // Locate URLs in plain text and wrap them in spaces so that they can be | |||
|
87 | // better picked out by autoLinkUrls even after the text has been | |||
|
88 | // converted to HTML | |||
|
89 | function wrapUrls(txt) { | |||
|
90 | // Note this regexp is a modified version of one from | |||
|
91 | // Markdown.Converter For now it only supports http(s) and ftp URLs, | |||
|
92 | // but could easily support others (though file:// should maybe be | |||
|
93 | // avoided) | |||
|
94 | var url_re = /(^|\W)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\]])($|\W)/gi; | |||
|
95 | return txt.replace(url_re, "$1 $2$3 $4"); | |||
|
96 | } | |||
|
97 | ||||
|
98 | // Locate a URL with spaces around it and convert that to a anchor tag | |||
|
99 | function autoLinkUrls(txt) { | |||
|
100 | return txt.replace(/ ((https?|ftp):[^'">\s]+) /gi, | |||
|
101 | "<a target=\"_blank\" href=\"$1\">$1</a>"); | |||
|
102 | } | |||
|
103 | ||||
86 | grow = function(element) { |
|
104 | grow = function(element) { | |
87 | // Grow the cell by hand. This is used upon reloading from JSON, when the |
|
105 | // Grow the cell by hand. This is used upon reloading from JSON, when the | |
88 | // autogrow handler is not called. |
|
106 | // autogrow handler is not called. | |
@@ -143,6 +161,8 b' IPython.utils = (function (IPython) {' | |||||
143 | keycodes : keycodes, |
|
161 | keycodes : keycodes, | |
144 | grow : grow, |
|
162 | grow : grow, | |
145 | fixCarriageReturn : fixCarriageReturn, |
|
163 | fixCarriageReturn : fixCarriageReturn, | |
|
164 | wrapUrls : wrapUrls, | |||
|
165 | autoLinkUrls : autoLinkUrls, | |||
146 | points_to_pixels : points_to_pixels |
|
166 | points_to_pixels : points_to_pixels | |
147 | }; |
|
167 | }; | |
148 |
|
168 |
General Comments 0
You need to be logged in to leave comments.
Login now