Skip to content

Commit 6d2c7c3

Browse files
authored
Merge pull request #58 from ncoop57/markdown_rendering
Replace markdown with mistletoe for rendering markdown output
2 parents 3fc8853 + 5bd6a6b commit 6d2c7c3

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

execnb/shell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from fastcore.script import call_parse
1010
from fastcore.ansi import ansi2html
1111

12-
import multiprocessing,types,traceback
12+
import mistletoe,multiprocessing,types,traceback
1313
try:
1414
if sys.platform == 'darwin': multiprocessing.set_start_method("fork")
1515
except RuntimeError: pass # if re-running cell
@@ -29,6 +29,7 @@
2929
try: from matplotlib_inline.backend_inline import set_matplotlib_formats
3030
except ImportError: set_matplotlib_formats = None
3131

32+
3233
from .nbio import *
3334
from .nbio import _dict2obj
3435

@@ -137,7 +138,7 @@ def render_output(out):
137138
_g = lambda t: ''.join(data[t]) if t in data else None
138139
if d := _g('text/html'): return d
139140
if d := _g('application/javascript'): return f'<script>{d}</script>'
140-
if d := _g('text/markdown'): return markdown.markdown(d)
141+
if d := _g('text/markdown'): return mistletoe.markdown(d)
141142
if d := _g('image/svg+xml'): return d
142143
if d := _g('image/jpeg'): return f'<img src="data:image/jpeg;base64,{d}"/>'
143144
if d := _g('image/png'): return f'<img src="data:image/png;base64,{d}"/>'

nbs/02_shell.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"from fastcore.script import call_parse\n",
3333
"from fastcore.ansi import ansi2html\n",
3434
"\n",
35-
"import multiprocessing,types,traceback\n",
35+
"import mistletoe,multiprocessing,types,traceback\n",
3636
"try:\n",
3737
" if sys.platform == 'darwin': multiprocessing.set_start_method(\"fork\")\n",
3838
"except RuntimeError: pass # if re-running cell\n",
@@ -52,6 +52,7 @@
5252
"try: from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
5353
"except ImportError: set_matplotlib_formats = None\n",
5454
"\n",
55+
"\n",
5556
"from execnb.nbio import *\n",
5657
"from execnb.nbio import _dict2obj"
5758
]
@@ -775,7 +776,7 @@
775776
" _g = lambda t: ''.join(data[t]) if t in data else None\n",
776777
" if d := _g('text/html'): return d\n",
777778
" if d := _g('application/javascript'): return f'<script>{d}</script>'\n",
778-
" if d := _g('text/markdown'): return markdown.markdown(d)\n",
779+
" if d := _g('text/markdown'): return mistletoe.markdown(d)\n",
779780
" if d := _g('image/svg+xml'): return d\n",
780781
" if d := _g('image/jpeg'): return f'<img src=\"data:image/jpeg;base64,{d}\"/>'\n",
781782
" if d := _g('image/png'): return f'<img src=\"data:image/png;base64,{d}\"/>'\n",

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ author_email = [email protected]
1111
branch = master
1212
version = 0.1.6
1313
min_python = 3.7
14-
requirements = fastcore>=1.5.5 ipython
14+
requirements = fastcore>=1.5.5 ipython mistletoe
1515
dev_requirements = matplotlib Pillow
1616
console_scripts = exec_nb=execnb.shell:exec_nb
1717
audience = Developers

0 commit comments

Comments
 (0)