diff --git a/README.md b/README.md index ddf2b77..f41df83 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # ipython-markdown-inspector -[![tests](https://github.com/krassowski/ipython-markdown-inspector/workflows/tests/badge.svg)](https://github.com/krassowski/ipython-markdown-inspector/actions?query=workflow%3A%22tests%22) +[![tests](https://github.com/krassowski/ipython-markdown-inspector/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/krassowski/ipython-markdown-inspector/actions/workflows/tests.yml) ![CodeQL](https://github.com/krassowski/ipython-markdown-inspector/workflows/CodeQL/badge.svg) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/krassowski/ipython-markdown-inspector/main?urlpath=lab) [![pypi-version](https://img.shields.io/pypi/v/ipython-markdown-inspector.svg)](https://python.org/pypi/ipython-markdown-inspector) IPython extension providing inspection results as Markdown, enabling better integration with Jupyter Notebook and JupyterLab. diff --git a/binder/environment.yml b/binder/environment.yml new file mode 100644 index 0000000..2750753 --- /dev/null +++ b/binder/environment.yml @@ -0,0 +1,17 @@ +name: ipython-markdown-inspector + +channels: + - conda-forge + - nodefaults + +dependencies: + - python =3.11 + - pip + - jupyterlab >=4.1 + - hatchling >=1.5.0 + - ipykernel >=6.29 + - notebook >=7.1 + - wheel + - build + - pip: + - ipython >=8.22 diff --git a/binder/ipython_config.py b/binder/ipython_config.py new file mode 100644 index 0000000..a475a0e --- /dev/null +++ b/binder/ipython_config.py @@ -0,0 +1 @@ +c.InteractiveShellApp.extensions = ["ipython_markdown_inspector"] # noqa: F821 diff --git a/binder/postBuild b/binder/postBuild new file mode 100644 index 0000000..c89d3b7 --- /dev/null +++ b/binder/postBuild @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +source activate ${NB_PYTHON_PREFIX} + +pip install -v -e . --no-build-isolation + +mkdir -p ~/.ipython/profile_default/ +cp binder/ipython_config.py ~/.ipython/profile_default/ diff --git a/ipython_markdown_inspector/__init__.py b/ipython_markdown_inspector/__init__.py index ac6a15b..2f23eda 100644 --- a/ipython_markdown_inspector/__init__.py +++ b/ipython_markdown_inspector/__init__.py @@ -1,27 +1,17 @@ -from functools import partial from typing import List from IPython.core.interactiveshell import InteractiveShell -from IPython.core.oinspect import InspectorHookData from .formatter import as_markdown -def hook( - data: InspectorHookData, - *_, - ipython: InteractiveShell, -) -> str: - return as_markdown(data) - - ORIGINAL_HOOK = None def load_ipython_extension(ipython: InteractiveShell): global ORIGINAL_HOOK ORIGINAL_HOOK = ipython.inspector.mime_hooks.get("text/markdown", None) - ipython.inspector.mime_hooks["text/markdown"] = partial(hook, ipython=ipython) + ipython.inspector.mime_hooks["text/markdown"] = as_markdown def unload_ipython_extension(ipython: InteractiveShell):