Skip to content

Commit

Permalink
Make mistletoe a standard dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Dec 31, 2024
1 parent 2d710ab commit 056ab66
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions execnb/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
try: from matplotlib_inline.backend_inline import set_matplotlib_formats
except ImportError: set_matplotlib_formats = None

from mistletoe import markdown, HTMLRenderer
from mistletoe.contrib.pygments_renderer import PygmentsRenderer

from .nbio import *
from .nbio import _dict2obj
Expand Down Expand Up @@ -162,10 +164,6 @@ def _pre(s, xtra=''): return f"<pre {xtra}><code>{escape(s)}</code></pre>"
def _strip(s): return strip_ansi(escape(s))

def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=False):
try:
from mistletoe import markdown, HTMLRenderer
from mistletoe.contrib.pygments_renderer import PygmentsRenderer
except ImportError: return print('mistletoe not found -- please install it')
renderer = PygmentsRenderer if pygments else HTMLRenderer
def render_output(out):
otype = out['output_type']
Expand Down
4 changes: 3 additions & 1 deletion nbs/01_nbio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
" 'execution_count': 0,\n",
" 'idx_': 0,\n",
" 'metadata': {},\n",
" 'outputs': [],\n",
" 'source': 'print(1)'}\n",
"```"
],
Expand All @@ -423,6 +424,7 @@
" 'directives_': {},\n",
" 'execution_count': 0,\n",
" 'metadata': {},\n",
" 'outputs': [],\n",
" 'idx_': 0}"
]
},
Expand Down Expand Up @@ -570,7 +572,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[{'cell_type': 'code', 'metadata': {}, 'source': 'print(1)', 'idx_': 0}]\n"
"[{'cell_type': 'code', 'execution_count': 0, 'metadata': {}, 'outputs': [], 'source': 'print(1)', 'idx_': 0}]\n"
]
}
],
Expand Down
6 changes: 2 additions & 4 deletions nbs/02_shell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"try: from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
"except ImportError: set_matplotlib_formats = None\n",
"\n",
"from mistletoe import markdown, HTMLRenderer\n",
"from mistletoe.contrib.pygments_renderer import PygmentsRenderer\n",
"\n",
"from execnb.nbio import *\n",
"from execnb.nbio import _dict2obj"
Expand Down Expand Up @@ -978,10 +980,6 @@
"def _strip(s): return strip_ansi(escape(s))\n",
"\n",
"def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=False):\n",
" try:\n",
" from mistletoe import markdown, HTMLRenderer\n",
" from mistletoe.contrib.pygments_renderer import PygmentsRenderer\n",
" except ImportError: return print('mistletoe not found -- please install it')\n",
" renderer = PygmentsRenderer if pygments else HTMLRenderer\n",
" def render_output(out):\n",
" otype = out['output_type']\n",
Expand Down
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ author_email = [email protected]
branch = master
version = 0.1.12
min_python = 3.7
requirements = fastcore>=1.5.5 ipython
dev_requirements = matplotlib Pillow mistletoe
requirements = fastcore>=1.5.5 ipython mistletoe
dev_requirements = matplotlib Pillow
console_scripts = exec_nb=execnb.shell:exec_nb
audience = Developers
language = English
Expand Down

0 comments on commit 056ab66

Please sign in to comment.