JupyterLab extension for animated slideshow.
Project description
sliveshow
A JupyterLab extension that turns Jupyter notebooks into live, animated Reveal.js slideshows — with scrollable slides, SVG and math (MathJax 4) animations that also play in the normal notebook view, and MyST directive support for Jupyter Book 2.
Install:
pip install sliveshow
PyPI: https://pypi.org/project/sliveshow/
Demo: https://alyanaamirahmedani.github.io/sliveshow/lab/index.html?path=sliveshow_demo.ipynb
(Run all cells before starting the slideshow to display animations correctly.)
Requirements
- JupyterLab >= 4.0.0
Install
pip install sliveshow
Uninstall
pip uninstall sliveshow
Usage
Slideshow
The slideshow uses the Reveal.js framework. Set the slide type of each cell via COMMON TOOLS > Slide Type. Available types: Slide, Sub-Slide, Fragment, Skip.
Transition type and duration are set per-cell in SLIDESHOW TOOLS. Available types: Slide, Fade, Zoom. The default can be changed in Settings.
For Slide transitions, direction is Horizontal (Slides) or Vertical (Sub-Slides) by default.
Code cell input can be hidden via Hide Code Cell, showing only the output.
To start a slideshow, use the Slideshow menu → Start from first cell or Start from current cell. To exit, press Escape or use Exit slideshow.
SVG Animation
SVG animations use the Reveal.js Animate plugin by Asvin Goel. Animations load after the slideshow starts.
Method A — Raw HTML in a markdown cell
Add a <div data-animate> block containing your SVG and a JSON config comment directly in a markdown cell:
<div data-animate>
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300">
<circle id="c1" cx="150" cy="150" r="60" style="fill:steelblue"/>
</svg>
<!--
{
"setup": [{
"element": "#c1",
"modifier": "attr",
"parameters": [{ "r": 100 }],
"duration": 1500,
"begin": 0
}]
}
-->
</div>
Method B — {svg-animate} MyST directive (recommended)
Use the {svg-animate} directive in a markdown cell. The same cell works in both the live Reveal.js slideshow and a static Jupyter Book 2 / mystmd export:
:::{svg-animate} Circle animation
:height: 320px
:background: white
<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'>
<circle id='c1' cx='150' cy='150' r='60' style='fill:steelblue'/>
</svg>
<!--
{
"setup": [{ "element": "#c1", "modifier": "attr", "parameters": [{ "r": 100 }], "duration": 1500, "begin": 0 }]
}
-->
:::
To enable {svg-animate} in a mystmd/Jupyter Book 2 build, add the plugin to your myst.yml:
project:
plugins:
- svg-animate.mjs
The svg-animate.mjs plugin file is included in the Demo/ folder.
The JSON config controls the animation. setup runs on load; animation runs per fragment. See the Animate plugin README for full options.
Animations in the notebook view
Since 0.1.8, the same data-animate / {svg-animate} cells also animate in the normal notebook view — no slideshow required. One source, works in both.
- Animations autoplay when the cell scrolls into view, and double-click replays them.
"loop": truein the config makes the animation cycle continuously (notebook and slideshow).- In the notebook, Reveal fragments don't exist, so all
animationstages play back-to-back on one timeline. - Tip: keep one animation block per markdown cell. Text before/after the block in the same cell is preserved.
Animating math (MathJax 4)
sliveshow replaces JupyterLab's default math renderer with MathJax 4 SVG output, so every formula in a markdown cell is an SVG that can be animated like any other — in the slideshow and in the notebook view.
Select formula parts either by their TeX source via g[data-latex='x'] (shortened to mj['x']), or tag them explicitly with \class{name}{...} / \cssId{id}{...} and select with .name / #id:
## The Gaussian integral
<div data-animate>
$$\class{lhs}{\int_{0}^{\infty} e^{-x^2}\,dx} = \class{rhs}{\frac{\sqrt{\pi}}{2}}$$
<!--
{
"animation": [
{ "element": ".lhs", "modifier": "opacity", "parameters": [0.15], "duration": 600 },
{ "element": ".lhs", "modifier": "opacity", "parameters": [1], "duration": 600 },
{ "element": ".rhs", "modifier": "opacity", "parameters": [0.15], "duration": 600 },
{ "element": ".rhs", "modifier": "opacity", "parameters": [1], "duration": 600 }
],
"loop": true
}
-->
</div>
Math inside a data-animate block is typeset by MathJax 4 when the block is injected (both in the notebook and when the slideshow starts).
Note: sliveshow disables the built-in
@jupyterlab/mathjax-extension(MathJax 3) while installed, so its MathJax 4 SVG typesetter is the one JupyterLab uses. Uninstalling sliveshow restores the default renderer.
Contributing
Development install
You will need Node.js and JupyterLab installed.
# Clone the repo
git clone https://github.com/AlyanAamirAhmedani/sliveshow
cd sliveshow
# Install in development mode
pip install -e "."
# Link with JupyterLab
jupyter labextension develop . --overwrite
# Build TypeScript
jlpm build
Watch mode (auto-rebuild on save):
# Terminal 1
jlpm watch
# Terminal 2
jupyter lab
Development uninstall
pip uninstall sliveshow
Remove the symlink created by jupyter labextension develop:
jupyter labextension list # find labextensions folder
# remove the sliveshow symlink from that folder
Packaging
See RELEASE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sliveshow-0.1.10.tar.gz.
File metadata
- Download URL: sliveshow-0.1.10.tar.gz
- Upload date:
- Size: 873.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b8c4bcac2a82d836e0add95f60f6d946737782f96bcaba73f365fb0edb9b18
|
|
| MD5 |
f33d4216c829425fb8273260e822194d
|
|
| BLAKE2b-256 |
d667343eed5520ca1489de83c133d45c8a507e2db79b41a44e3411228b4e02f0
|
File details
Details for the file sliveshow-0.1.10-py3-none-any.whl.
File metadata
- Download URL: sliveshow-0.1.10-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d71a6c2a9bca921a0d646c1cb286c020f699f7adef317c75364d77fe02af23
|
|
| MD5 |
f0942357621cf64cadec33a54dcd0c23
|
|
| BLAKE2b-256 |
8516ec9b49668435c2aae3ad9161ad135fba8cf926c0acca73c1a97d90c205b5
|