# pseudocode.js

Beautiful pseudocode for the Web

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:

• Intuitive grammar: pseudocode.js takes a LaTeX-style input that supports the algorithmic constructs from LaTeX's algorithm packages. With or without LaTeX experience, a user should find the grammar fairly intuitive.
• Print quality: The HTML output produced by pseudocode.js is (almost) identical with the pretty algorithms printed on publications that are typeset by LaTeX.
• Math formula support: Inserting math formulas in pseudocode.js is as easy as LaTeX. Just enclose math expression in $...$ or $$...$$.

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.

<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.