rajgoel / reveal.js-plugins

Plugins for reveal.js
MIT License
739 stars 248 forks source link

[Question]: Adding plugins to revealjs slides generated via Pandoc #138

Closed SkepticMystic closed 2 years ago

SkepticMystic commented 3 years ago

Hello everybody! I am having some trouble, and hopefully someone can asisst. I write my revealjs slides in markdown, and then convert them to html using pandoc:

pandoc -t revealjs -V theme=night --slide-level=2 -s "slides.md" -o "slides.html"

This has been working fine for a while, but I want to try adding a plugin. So, I wrote a small html file with the necessary links and scripts:

<link rel="stylesheet" href="../Plugins/customcontrols/style.css">
<script src="../Plugins/customcontrols/plugin.js"></script>

<script>
    Reveal.initialize({
        // ...
        plugins: [RevealCustomControls],
        // ...
    });
</script>

Such that when I add this to the head of the revealjs html output (-H "path/to/file.html"), the file paths do indeed point to the right files on my system. However, the plugin never actually enables. I'm not sure what else I should try.

Even appending the final script to the end of the body (to make sure Reveal is defined) doesn't help:

image

Any help would be greatly appreciated :)

Industry-Standard commented 2 years ago

So, I'm playing around with this too, and best as I can tell, if you reinitialize Reveal, you lose the other plugins. What I've found does work is to pandoc generate the content, pandoc -s --slide-level 2 -V revealjs-url=./reveal.js -t revealjs markdown.md -o index.html -H ./reveal-header.html

Then, in the built index.html file, you have to add the reference to the plugin, and any initialization for the plugin:

   // reveal.js plugins
        plugins: [
          RevealNotes,
          RevealSearch,
          RevealZoom,
          RevealMenu
        ],

        menu : { side : 'left' }

      });
    </script>
    </body>
</html>

I think this might be more of an issue with Pandoc; it looks like pandoc reverts parts of the index.html within the reveal.js directory back to a default state and throws away any local changes in the directory.

If we are able to specify the directory to the reveal.js files with the pandoc parameter, I'm not sure why pandoc would do anything other than just make a copy of the provided index.html file, insert the converted markdown in the reveal section of the html body, and call it a day.

rajgoel commented 2 years ago

Sorry, cannot help you here. May be this is better asked at stackoverflow or some similar site.