From b47068ede538eddb8c72d65e62656cae4e497697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Eertmans?= Date: Thu, 1 Feb 2024 12:27:24 +0100 Subject: [PATCH] fix(rtd): remove flyout in iframes (#367) * fix(rtd): remove flyout in iframes * fix(rtd): remove dirhtml and default to html Because dirhtml seems to have issues with iframes * fix(html): correct css style --- .readthedocs.yaml | 2 +- manim_slides/convert.py | 1 + manim_slides/templates/revealjs.html | 48 ++++++++++++++++------------ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index db419ec..9921f8e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,7 +10,7 @@ build: post_install: - ipython kernel install --name "manim-slides" --user sphinx: - builder: dirhtml + builder: html configuration: docs/source/conf.py fail_on_warning: true python: diff --git a/manim_slides/convert.py b/manim_slides/convert.py index 0282b33..345f114 100644 --- a/manim_slides/convert.py +++ b/manim_slides/convert.py @@ -416,6 +416,7 @@ class RevealJS(Converter): file_to_data_uri=file_to_data_uri, get_duration_ms=get_duration_ms, has_notes=has_notes, + env=os.environ, **options, ) diff --git a/manim_slides/templates/revealjs.html b/manim_slides/templates/revealjs.html index 80d0ca7..0c66468 100644 --- a/manim_slides/templates/revealjs.html +++ b/manim_slides/templates/revealjs.html @@ -316,28 +316,36 @@ hideCursorTime: {{ hide_cursor_time }} }); - {% if data_uri %} - // Fix found by @t-fritsch on GitHub - // see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-6651475. - function fixBase64VideoBackground(event) { - // event.previousSlide, event.currentSlide, event.indexh, event.indexv - if (event.currentSlide.getAttribute('data-background-video')) { - const background = Reveal.getSlideBackground(event.indexh, event.indexv), - video = background.querySelector('video'), - sources = video.querySelectorAll('source'); + {% if data_uri -%} + // Fix found by @t-fritsch on GitHub + // see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-6651475. + function fixBase64VideoBackground(event) { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv + if (event.currentSlide.getAttribute('data-background-video')) { + const background = Reveal.getSlideBackground(event.indexh, event.indexv), + video = background.querySelector('video'), + sources = video.querySelectorAll('source'); - sources.forEach((source, i) => { - const src = source.getAttribute('src'); - if(src.match(/^data:video.*;base64$/)) { - const nextSrc = sources[i+1]?.getAttribute('src'); - video.setAttribute('src', `${src},${nextSrc}`); - } - }); - } + sources.forEach((source, i) => { + const src = source.getAttribute('src'); + if(src.match(/^data:video.*;base64$/)) { + const nextSrc = sources[i+1]?.getAttribute('src'); + video.setAttribute('src', `${src},${nextSrc}`); + } + }); } - Reveal.on( 'ready', fixBase64VideoBackground ); - Reveal.on( 'slidechanged', fixBase64VideoBackground ); - {% endif %} + } + Reveal.on( 'ready', fixBase64VideoBackground ); + Reveal.on( 'slidechanged', fixBase64VideoBackground ); + {%- endif %} + + {% if env['READTHEDOCS'] -%} + + {%- endif %}