Repository navigation
docusaurus-plugin-onlinecompiler: runnable code blocks in 46 languages #13008
ashwin31
started this conversation in
Plugins, Themes, Presets and Libs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This plugin turns fenced code blocks into editors that readers can run in the page. Add
runnableafter the language, and the block gets a Run button and a box for the program's input. It works for Python, C++, Java, Go, Rust, SQL and the other languages OnlineCompiler.io runs, 46 in all.@docusaurus/theme-live-codeblockcovers JSX; this is for everything else.The code runs on OnlineCompiler.io, a hosted code execution service (I build it), in a sandbox with no network access, not in the reader's browser or on your server. You need a widget key from its dashboard: keys are free, the free plan includes 100,000 runs a month, and you can restrict a key to your docs domain. The code stays in the page's HTML as text, so search engines index it and readers still see it if the service can't be reached. The widget script loads only on pages that have a runnable block.
Like
theme-live-codeblock, it replaces the classic theme's code block component, so a site uses one or the other. It needs Docusaurus 3 with the classic theme and is tested with 3.10 on both Rspack and webpack. MIT licensed.Repository: https://github.com/onlinecompiler-io/docusaurus-plugin-onlinecompiler
npm: https://www.npmjs.com/package/docusaurus-plugin-onlinecompiler
Guide with examples: https://onlinecompiler.io/guides/add-runnable-code-examples-to-docusaurus
Questions are welcome here or as an issue on the repository.
All reactions