Skip to content

Commit

Permalink
Cleanup code and added support for 2D graphics again.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseCarlosGarcia95 committed Feb 20, 2018
1 parent e61e8d8 commit ea02263
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 27 deletions.
75 changes: 73 additions & 2 deletions .ipynb_checkpoints/Untitled-checkpoint.ipynb

Large diffs are not rendered by default.

Binary file modified dist/mathicsnotebook-0.1-py2.7.egg
Binary file not shown.
12 changes: 10 additions & 2 deletions mathicsnotebook/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class MathicsNotebookKernel(Kernel):

name = 'MathicsNotebook'

"""
Preprocess output for better support for graphics.
"""
def preprocess_output(self, data):
data = re.sub(r"<math><mglyph width=\"(.*)\" height=\"(.*)\" src=\"(.*)\"/></math>", "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" />", data, 0)

return data

"""
Handle jupyter connections.
"""
Expand Down Expand Up @@ -49,13 +57,13 @@ def do_execute(self, code, silent, store_history=True,
for result in results:
result_data = result.get_data()

result_html = result_data['result']
result_html = self.preprocess_output(result_data['result'])

display_data = {
'data' : {'text/html' : result_html},
'metadata' : {},
}

self.send_response(self.iopub_socket, 'display_data', display_data)

return {
Expand Down
32 changes: 9 additions & 23 deletions Untitled.ipynb → tests/Untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,32 @@
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<math><mn>2</mn></math>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"1+1"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
"name": "stdout",
"output_type": "stream",
"text": [
"<math><mrow><mo>{</mo> <mrow><mo>{</mo> <mrow><mi>x</mi> <mo>-&gt;</mo> <mn>0</mn></mrow> <mo>}</mo></mrow> <mo>}</mo></mrow></math>"
]
},
{
"data": {
"text/html": [
"<math><mi>Plot</mi></math>"
"<math><mrow><mo>{</mo> <mrow><mo>{</mo> <mrow><mi>x</mi> <mo>-&gt;</mo> <mn>0</mn></mrow> <mo>}</mo></mrow> <mo>}</mo></mrow></math>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"Plot"
"Solve[x^2==0, x]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Sol"
]
"source": []
}
],
"metadata": {
Expand Down
10 changes: 10 additions & 0 deletions tests/mathicsnotebook.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: mathicsnotebook
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
Empty file.
1 change: 1 addition & 0 deletions tests/mathicsnotebook.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions tests/mathicsnotebook.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ipykernel
ipython
mathics>=1.0.dev0
1 change: 1 addition & 0 deletions tests/mathicsnotebook.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mathicsnotebook

0 comments on commit ea02263

Please sign in to comment.