# HG changeset patch # User Bruce Cohen # Date 1308156704 25200 # Node ID 044a52a07b9bca694e501101aafb6941df4be77f # Parent 155db6f2482dbf65f7d96d9ba989fcba25646b61 #11489: Made docstring a rawstring. Merged two patches to single patch trac 11489 adding html.iframe method * * * trac #11489: make HTML spec-conformant, change the check for URI scheme, fix some formatting diff -r 155db6f2482d -r 044a52a07b9b sage/misc/html.py --- a/sage/misc/html.py Wed Jun 15 15:07:14 2011 -0700 +++ b/sage/misc/html.py Wed Jun 15 09:51:44 2011 -0700 @@ -293,4 +293,54 @@ + latex(row[column]).replace('\\texttt','\\hbox') + '') + def iframe(self, url, height=400, width=800): + r""" + Put an existing web page into a worksheet. + + INPUT: + + - ``url`` -- a url string, either with or without URI scheme + (defaults to "http"). + - ``height`` -- the number of pixels for the page height. + Defaults to 400. + - ``width`` -- the number of pixels for the page width. + Defaults to 800. + + OUTPUT: + + Opens the url in a worksheet. If the url is a regular web page it + will appear in the worksheet. This was originally intended to bring + GeoGebra worksheets into Sage, but it can be used for many other + purposes. + + EXAMPLES:: + + sage: html.iframe("sagemath.org") + + sage: html.iframe("http://sagemath.org",30,40) + + sage: html.iframe("https://sagemath.org",30) + + sage: html.iframe("/home/admin/0/data/filename") + + sage: html.iframe('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA' + ... 'AUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBA' + ... 'AO9TXL0Y4OHwAAAABJRU5ErkJggg=="') + + + AUTHOR: + + - Bruce Cohen (2011-06-14) + """ + if ":" not in url and not url.startswith('/'): + url = "http://" + url + string = ( '' % + (height, width, url) ) + return html(string) + html = HTML()