manim icon indicating copy to clipboard operation
manim copied to clipboard

Manim directive duplicates code

Open F4bbi opened this issue 1 year ago • 1 comments

Description of bug / unexpected behavior

When using manim_directive for including Manim videos in a Sphinx document, the code snippet is duplicated in the rendered output. For example, given this .rst file:

My Plugin Documentation
=======================

Test
----

TODO

.. manim:: MyScene

    class MyScene(Scene):
        def construct(self):
            circle = Circle()
            self.play(Create(circle))
            self.wait()

This is the result:

image

Expected behavior

The second code snippet should not be there. A workaround is removing the relative HTML code, that is:

<pre data-manim-binder data-manim-classname="MyScene">
class MyScene(Scene):
    def construct(self):
        circle = Circle()
        self.play(Create(circle))
        self.wait()

</pre>

This is the result:

image

How to reproduce the issue

  1. Use manim_directive with a simple scene, as shown in the example below.
  2. Render the scene.

System specifications

System Details
  • OS: macOS 12.7.5 (Monterey)
  • RAM: 8GB
  • Python version (python/py/python3 --version): 3.12.6

F4bbi avatar Nov 02 '24 23:11 F4bbi

I am not sure I would qualify this as a bug -- but you are right, we are using the directive to generate both the default output in the admonition, as well as an extra block for the interactive embed. We need to keep this block for the documentation, but perhaps there should be some sort of configuration option that toggles whether these additional blocks are written.

PRs are welcome!

behackl avatar Nov 02 '24 23:11 behackl