︠a4c04968-4799-4760-9cba-76bb5ffffde3s︠
html??
︡03cf5f69-ae45-4925-9bef-a1791a6194fc︡{"code":{"filename":null,"lineno":-1,"mode":"python","source":" File: /projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py\n Source:\n class HTML:\n \"\"\"\n Cell mode that renders everything after %html as HTML\n\n EXAMPLES::\n\n ---\n %html\n
A Title
\n Subtitle
\n\n ---\n %html(hide=True)\n A Title
\n Subtitle
\n\n ---\n %html(\"A title
\", hide=False)\n\n ---\n %html(hide=False) Title
\n\n \"\"\"\n def __init__(self, hide=False):\n self._hide = hide\n\n def __call__(self, *args, **kwds):\n if len(kwds) > 0 and len(args) == 0:\n return HTML(**kwds)\n if len(args) > 0:\n self._render(args[0], **kwds)\n\n def _render(self, s, hide=None):\n if hide is None:\n hide = self._hide\n if hide:\n salvus.hide('input')\n salvus.html(s)\n\n def table(self, rows = None, header=False):\n \"\"\"\n Renders a given matrix or nested list as an HTML table.\n\n Arguments::\n\n * **rows**: the rows of the table as a list of lists\n * **header**: if True, the first row is formatted as a header (default: False)\n \"\"\"\n # TODO: support columns as in http://doc.sagemath.org/html/en/reference/misc/sage/misc/table.html\n assert rows is not None, '\"rows\" is a mandatory argument, should be a list of lists'\n\n from sage.matrix.matrix import is_Matrix\n import numpy as np\n\n if is_Matrix(rows):\n table = list(rows) # list of Sage Vectors\n elif isinstance(rows, np.ndarray):\n table = rows.tolist()\n else:\n table = rows\n\n assert isinstance(table, (tuple, list)), '\"rows\" must be a list of lists'\n\n def as_unicode(s):\n '''\n This not only deals with unicode strings, but also converts e.g. `Integer` objects to a str\n '''\n if not isinstance(s, unicode):\n try:\n return unicode(s, 'utf8')\n except:\n return unicode(str(s), 'utf8')\n return s\n\n def mk_row(row, header=False):\n is_vector = hasattr(row, 'is_vector') and row.is_vector()\n assert isinstance(row, (tuple, list)) or is_vector, '\"rows\" must contain lists or vectors for each row'\n tag = 'th' if header else 'td'\n row = [u'<{tag}>{}{tag}>'.format(as_unicode(_), tag = tag) for _ in row]\n return u'{}
'.format(u''.join(row))\n\n thead = u'{}'.format(mk_row(table.pop(0), header=True)) if header else ''\n h_rows = [mk_row(row) for row in table]\n html_table = u''\n self(html_table.format(thead, ''.join(h_rows)))\n"}}︡{"done":true}︡
︠40b72461-b976-4c32-98da-66ac63bc129cs︠
salvus.html??
︡dae79089-1246-4945-8839-41685a17c344︡{"code":{"filename":null,"lineno":-1,"mode":"python","source":" File: /projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py\n Source:\n def html(self, html, done=False, once=None):\n \"\"\"\n Display html in the output stream.\n\n EXAMPLE:\n\n salvus.html(\"Hi\")\n \"\"\"\n self._flush_stdio()\n self._send_output(html=unicode8(html), id=self._id, done=done, once=once)\n"}}︡{"done":true}︡
︠be880d0a-5ede-4d2f-8dd6-8a435b08bff0︠