Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load RevealHighlight plugin async? #2911

Closed
jschildgen opened this issue Mar 1, 2021 · 1 comment · May be fixed by xhad/reveal.js#7 or javifelices/reveal.js#6
Closed

Load RevealHighlight plugin async? #2911

jschildgen opened this issue Mar 1, 2021 · 1 comment · May be fixed by xhad/reveal.js#7 or javifelices/reveal.js#6

Comments

@jschildgen
Copy link

I just upgraded my slides from reveal.js 3.x to 4.1

In the slides, code is included from code files using the sampler plugin. https://github.com/ldionne/reveal-sampler

<pre><code class="java" data-sample='path/to/source.java'></code></pre>

The problem is that the code on the slide is not highlighted anymore. I guess this is because the highlight plugin needs to be loaded asynchronously?

Does anybody have a solution for how to support code highlighting for code that is not hard-coded within the slides?

@jschildgen
Copy link
Author

jschildgen commented Mar 1, 2021

I found a solution. I added the following in the end of the sampler plugin code:

        if (typeof hljs !== 'undefined') {
            hljs.highlightBlock(element);
        }
        // this is new:
        if (typeof RevealHighlight !== 'undefined') {
            RevealHighlight().highlightBlock(element);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant