# HG changeset patch # Date 1308173676 25200 # User Keshav Kini # 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/sage/misc/html.py +++ b/sage/misc/html.py @@ -293,54 +293,54 @@ + latex(row[column]).replace('\\texttt','\\hbox') + '') - - - - def iframe(self, url, height=400, width=800): """ Put an existing web page into a worksheet. INPUT: - - ``url`` -- a url string. Either with or without "http://". - - ``height`` -- the number of pixels for the page height. + - ``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. + - ``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. - + 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 url.startswith("http"): - url="http://"+url - string=''%(height, - width, - url) + if ":" not in url and not url.startswith('/'): + url = "http://" + url + string = ( '' % + (height, width, url) ) return html(string) - html = HTML()