# HG changeset patch
# Date 1308173676 25200
# User Keshav Kini <keshav.kini@gmail.com>
# Parent 879111d2bb0cd7f61dceb232a0d40385393689eb
trac #11489: make HTML spec-conformant, change the check for URI scheme, fix some formatting
diff --git a/sage/misc/html.py b/sage/misc/html.py
a
|
b
|
|
293 | 293 | + latex(row[column]).replace('\\texttt','\\hbox') |
294 | 294 | + '</span>') |
295 | 295 | |
296 | | |
297 | | |
298 | | |
299 | | |
300 | 296 | def iframe(self, url, height=400, width=800): |
301 | 297 | """ |
302 | 298 | Put an existing web page into a worksheet. |
303 | 299 | |
304 | 300 | INPUT: |
305 | 301 | |
306 | | - ``url`` -- a url string. Either with or without "http://". |
307 | | - ``height`` -- the number of pixels for the page height. |
| 302 | - ``url`` -- a url string, either with or without URI scheme |
| 303 | (defaults to "http"). |
| 304 | - ``height`` -- the number of pixels for the page height. |
308 | 305 | Defaults to 400. |
309 | | - ``width`` -- the number of pixels for the page width. |
| 306 | - ``width`` -- the number of pixels for the page width. |
310 | 307 | Defaults to 800. |
311 | 308 | |
312 | 309 | OUTPUT: |
313 | 310 | |
314 | | Opens the url in a worksheet. If the url is a regular web page |
315 | | it will appear in the worksheet. This was originally intended |
316 | | to bring GeoGebra worksheets into Sage, but it can be used for |
317 | | many other purposes. |
318 | | |
| 311 | Opens the url in a worksheet. If the url is a regular web page it |
| 312 | will appear in the worksheet. This was originally intended to bring |
| 313 | GeoGebra worksheets into Sage, but it can be used for many other |
| 314 | purposes. |
319 | 315 | |
320 | 316 | EXAMPLES:: |
321 | | |
| 317 | |
322 | 318 | sage: html.iframe("sagemath.org") |
323 | | <html><font color='black'><iframe height=400 px width=800 px |
| 319 | <html><font color='black'><iframe height="400" width="800" |
324 | 320 | src="http://sagemath.org"></iframe></font></html> |
325 | | |
326 | 321 | sage: html.iframe("http://sagemath.org",30,40) |
327 | | <html><font color='black'><iframe height=30 px width=40 px |
| 322 | <html><font color='black'><iframe height="30" width="40" |
328 | 323 | src="http://sagemath.org"></iframe></font></html> |
329 | | |
330 | 324 | sage: html.iframe("https://sagemath.org",30) |
331 | | <html><font color='black'><iframe height=30 px width=800 px |
| 325 | <html><font color='black'><iframe height="30" width="800" |
332 | 326 | src="https://sagemath.org"></iframe></font></html> |
| 327 | sage: html.iframe("/home/admin/0/data/filename") |
| 328 | <html><font color='black'><iframe height="400" width="800" |
| 329 | src="/home/admin/0/data/filename"></iframe></font></html> |
| 330 | sage: html.iframe('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA' |
| 331 | ... 'AUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBA' |
| 332 | ... 'AO9TXL0Y4OHwAAAABJRU5ErkJggg=="') |
| 333 | <html><font color='black'><iframe height="400" width="800" |
| 334 | src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==""></iframe></font></html> |
333 | 335 | |
334 | 336 | AUTHOR: |
335 | | |
| 337 | |
336 | 338 | - Bruce Cohen (2011-06-14) |
337 | 339 | """ |
338 | | if not url.startswith("http"): |
339 | | url="http://"+url |
340 | | string='<iframe height=%d px width=%d px src="%s"></iframe>'%(height, |
341 | | width, |
342 | | url) |
| 340 | if ":" not in url and not url.startswith('/'): |
| 341 | url = "http://" + url |
| 342 | string = ( '<iframe height="%d" width="%d" src="%s"></iframe>' % |
| 343 | (height, width, url) ) |
343 | 344 | return html(string) |
344 | 345 | |
345 | | |
346 | 346 | html = HTML() |