Metadata-Version: 2.4
Name: mathics3_notebook_frontends
Version: 1.0.0
Summary: Jupyter, JupyterLite, marimo, Observable Notebook integration for Mathics3
Maintainer-email: Mathics3 Group <mathics-devel@googlegroups.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://mathics.org/
Project-URL: Downloads, https://github.com/Mathics3/Mathics3-notebook-frontends/releases
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Software Development :: Interpreters
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: COPYING.txt
Requires-Dist: Mathics3>=10.0.0
Requires-Dist: setuptools
Requires-Dist: requests>=2.32.3
Requires-Dist: urllib3<3,>=1.21.1
Requires-Dist: chardet<6.0.0,>=3.0.2
Requires-Dist: charset-normalizer<4.0.0,>=2.0.0
Dynamic: license-file

# Mathics3 Module for notebook frontends

This library provides helper functions for integrating Mathics3 into notebook environments.
Currently, it supports Jupyter(Lite), marimo, and Observable.

## JupyterLite

See [Mathics3 live](https://github.com/Mathics3/Mathics3-live) project a project that
uses this Python module in a live demo running under pyodidie.

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
```
%load_ext mathics3_kernel.frontend.jupyter
```

Usage is as simple as executing the above code in a notebook cell,
and then Mathics3 code can be directly run in all subsequent cells.
Here is a [sample notebook](examples/jupyter-notebook.ipynb)
that can be used with a local Jupyter installation.

## marimo

```py
from mathics3_kernel.frontend.marimo import mathics3
```

Then run Mathics3 code like so:

```py
mathics3("ArcCos[0]")
```

See the examples directory for a sample notebook:

```sh
marimo edit --sandbox examples/marimo_notebook.py
```

It also works in marimo's pyodide-powered online environment, see https://marimo.io/p/@davidar/mathics for an example.

## Observable

For other notebook environments, this library provides a generic interface:

```py
from mathics3_kernel.frontend.generic import mathics3
```

See https://observablehq.com/@davidar/mathics for an example of how this can be used with Observable notebooks.
This notebook loads the library with pyodide, then implements a simple interface in JavaScript:

```js
async function mathics3(strings) {
  const [type, result] = await py`${mathics3_kernel}(${strings[0]})`
  if (type === "code") {
    return md`\`\`\`\n${result}\n\`\`\``;
  } else if (type === "math") {
    return tex.block`${result}`;
  } else if (type === "json") {
    return JSON.parse(result);
  } else if (type === "html") {
    return html`${result}`;
  } else {
    return result;
  }
}
```
