Skip to content

Instantly share code, notes, and snippets.

@takluyver
Created February 27, 2017 15:46
Show Gist options
  • Save takluyver/fb43b4cb6d7a44eadcdd08b024268f23 to your computer and use it in GitHub Desktop.
Save takluyver/fb43b4cb6d7a44eadcdd08b024268f23 to your computer and use it in GitHub Desktop.
Test Jupyter mathjax in tables issue
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from IPython.display import HTML"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def table(lol):\n",
" s = '<table>'\n",
" for row in lol:\n",
" s += '<tr>'\n",
" for cell in row:\n",
" s += '<td>%s</td>' % cell\n",
" s+= '</tr>'\n",
" s += '</table>'\n",
" return HTML(s)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table([[1, 2, 3], [4, 5, 6]])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table><tr><td>$A(0,0)$</td><td>$A(1,0)$</td><td>$A(2,0)$</td><td>$A(3,0)$</td></tr><tr><td>$A(0,1)$</td><td>$A(1,1)$</td><td>$A(2,1)$</td><td>$A(3,1)$</td></tr><tr><td>$A(0,2)$</td><td>$A(1,2)$</td><td>$A(2,2)$</td><td>$A(3,2)$</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table([['$A(%d,%d)$' %(i, j) for i in range(4)] for j in range(3)])"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table><tr><td>A(0,0)</td><td>A(1,0)</td><td>A(2,0)</td><td>A(3,0)</td></tr><tr><td>A(0,1)</td><td>A(1,1)</td><td>A(2,1)</td><td>A(3,1)</td></tr><tr><td>A(0,2)</td><td>A(1,2)</td><td>A(2,2)</td><td>A(3,2)</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table([['A(%d,%d)' %(i, j) for i in range(4)] for j in range(3)])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment