executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
737 stars 196 forks source link

proposal for a html_video extension #651

Open parmentelat opened 1 year ago

parmentelat commented 1 year ago

Context

this is a follow-up to https://github.com/executablebooks/jupyter-book/issues/1249

Proposal

in essence, the proposal is to create a new html_video extension that would behave much like html_image and would let users insert raw video html tags the main effect being - as far as I am concerned - for the referred media file to be copied over in the jb build area

Tasks and updates

chrisjsewell commented 1 year ago

Heya, have you seen https://github.com/sphinx-contrib/video

jedbrown commented 9 months ago

In my use case, I teach using live interactive notebooks with embedded <video> elements, so regular Jupyter/RISE needs to understand it. Then I use Jupyter Book to publish the rendered content as a reference for students (with Thebe and Binder in case they want to interact, or they clone the repo locally). html_image has been essential to be able to render/position within Jupyter/RISE while getting correct output on the class website. But <video> path handling is currently broken and I've been hacking my _build outputs with sed to repair the paths. I would love to see html_video even if only to avoid this manual path hacking.

parmentelat commented 9 months ago

FWIW the way I do it on my end is to

this turns out to render in both jlab and jupyter book, without the need for messing with paths (except of course for the constraint to store the video in _static which I agree is a moderate pain)

parmentelat commented 9 months ago

@chrisjsewell the reference to sphinx-contrib/video is interesting but IIUC the example relies on ReST rather than MyST

.. video:: _static/video.mp4

are you suggesting that we can use

```{video} _static/thevideo.mp4

instead ? and if yes, would that work even if the video is not under `_static`, like we can do with `{image}` ?
chrisjsewell commented 9 months ago

are you suggesting that we can use

yep exactly; there should be no reason it does not work exactly like for RST (the same as for every other directive)

I haven't had a chance to try out though, maybe you can report back

parmentelat commented 9 months ago

so it feels like I must be doing something very wrong, because:

I create a notebook and add this in a cell

this one is under `_static/`

```{video} _static/under-static.mp4

this one is under media/

so first in JupyterLab with jupyterlab-myst it renders like this

image

then in the output of jupyter book I see this

image

parmentelat commented 9 months ago

correction: once I add sphinxcontrib.video to sphinx's extra_extensions, I am getting this in the jupyter book output: the video under _static gets properly packaged in the html output but not the one under another folder, specifically here ./media/

is there something else I need to do to improve these results ?

image
parmentelat commented 8 months ago

to be exhaustive, here's the versions that I have installed

pip list | grep -Ei 'myst|sphinx'
jupyterlab_myst               2.1.0
myst-nb                       0.17.2
myst-parser                   0.18.1
pydata-sphinx-theme           0.14.4
Sphinx                        5.0.2
sphinx-book-theme             1.0.1
sphinx-comments               0.0.3
sphinx-copybutton             0.5.2
sphinx_design                 0.3.0
sphinx-exercise               0.4.1
sphinx_external_toc           0.3.1
sphinx-jupyterbook-latex      0.5.2
sphinx-multitoc-numbering     0.1.3
sphinx-rtd-theme              2.0.0
sphinx-thebe                  0.2.1
sphinx-togglebutton           0.3.2
sphinxcontrib-applehelp       1.0.7
sphinxcontrib-bibtex          2.5.0
sphinxcontrib-devhelp         1.0.5
sphinxcontrib-htmlhelp        2.0.4
sphinxcontrib-jquery          4.1
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-mermaid         0.9.2
sphinxcontrib-qthelp          1.0.6
sphinxcontrib-serializinghtml 1.1.9
sphinxcontrib-video           0.2.0
parmentelat commented 8 months ago

finally I just noticed that with the one combo that does work (within jupyter book output, referring to a video stored under _static) I can't seem to change the size of the rendered