Skip to content

Mathics3/Mathics3-notebook-frontends

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathics3 notebook frontends

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

Jupyter(Lite)

See the Mathics3 live project for a live demo.

%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.

marimo

from mathics3_kernel.frontend.marimo import mathics3

Then run Mathics3 code like so:

mathics3("ArcCos[0]")

See the examples directory for a sample notebook:

marimo edit --sandbox examples/marimo_notebook.py

Observable

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

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:

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;
  }
}

About

Pyodide front-end interface to Mathics3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages