pseudocode.js

Beautiful pseudocode for the Web

View the Project on GitHub SaswatPadhi/pseudocode.js

pseudocode.js enables JavaScript to typeset algorithms as beautifully as LaTeX does:

The demo above is editable. Feel free to experiment with it by clicking on the edit button.

Features

pseudocode.js is a JavaScript library that typesets pseudocode beautifully to HTML:

It supports all modern browsers, including Chrome, Safari, Firefox, Opera, and IE 8 - IE 11.

Usage

Pseudocode.js supports multiple backends to render math formulas. If you want to include any math formulas in your pseudocode, please make sure that either KaTeX or MathJax is properly setup in your document.

Download pseudocode.js, and host the files on your server. And then include the js and css files in your HTML files:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pseudocode@latest/build/pseudocode.min.css">
<script src="https://cdn.jsdelivr.net/npm/pseudocode@latest/build/pseudocode.min.js"></script>

Place the pseudocode to be rendered in a <pre> element:

<pre id="hello-world-code" style="display:hidden;">
    \begin{algorithmic}
    \PRINT \texttt{'hello world'}
    \end{algorithmic}
</pre>

Finally, call pseudocode.render by placing the following Javascript snippet at the end of your document body:

<script>
    pseudocode.renderElement(document.getElementById("hello-world-code"));
</script>

For more details on available options and backends, please see the usage section of README.

Author

pseudocode.js was originally written by Tate Tian (@tatetian). Together with @ZJUGuoShuai, I (@SaswatPadhi) added the MathJax support, and I am the current maintainer of this project. Suggestions, bug reports and pull requests are most welcome.

Acknowledgement

Pseudocode.js is partially inspired by KaTeX and relies on it to render math formulas. Thanks Emily Eisenberg(@xymostech) and other contributers for building such a wonderful project.