A Reveal.js plugin for opening code snippets in Compiler Explorer by clicking on them.
Check out the live demo.
For testing presentation code, see reveal-test package.
-
Download and install the package in your project:
npm install --save reveal-compiler-explorer
or
yarn add reveal-compiler-explorer
or just download dist/reveal-compiler-explorer.js into the plugin folder of your reveal.js presentation, e.g..
plugins/reveal-compiler-explorer
. -
Add the plugins to the dependencies in your presentation
<script src="node_modules/reveal-compiler-explorer/dist/reveal-compiler-explorer.js"></script>
// ... Reveal.initialize({ // ... plugins: [ RevealMarkdown, RevealCompilerExplorer, RevealHighlight, ] });
Note that the plugin should come before the highlight plugin.
If you're using reveal-md you can add a script to load the plugin:
options.plugins.splice(options.plugins.indexOf(RevealHighlight), 0, RevealCompilerExplorer);
and then add a reference to this script along with
node_modules/reveal-compiler-explorer/dist/reveal-compiler-explorer.js
to thescripts
object insidereveal-md.json
config file.
For reference, take a look at the demo package in this repo.
To configure the plugin pass a compilerExplorer
object to Reveal.initialize
with any of the options from here.
For example
// ...
Reveal.initialize({
// ...
plugins: [
// ...
RevealCompilerExplorer
// ...
],
// ...
compilerExplorer: {
compiler: "g83",
runMain: false
}
});
In addition to the directives mentioned here, the following directives are supported:
Hides the following code, until the next ///unhide
or end of the snippet, from presentation.
Revert code hiding.
The directives will not be shown on the presentation.