A MkDocs plugin to render beautiful pseudocode with LaTeX-inspired syntax.
Project description
MkDocs Pseudocode Plugin
This MkDocs plugin allows you to write beautiful pseudocode in your MkDocs documentation using a simplified syntax inspired by LaTeX.
Features
- Render pseudocode blocks with LaTeX-inspired syntax
- Support for common control structures (
if,for,while,repeat,foreach) - Math expressions rendered using MathJax
- Nested procedures and calls
- Automatic indentation and keyword highlighting
Installation
-
Install the plugin locally:
pip install mkdocs-pseudocode
-
Add the plugin to your
mkdocs.ymlconfiguration file:plugins: - search - pseudocode
-
Copy CSS file into your
extra.cssfile of your Mkdocs projectPlace the
pseudo-code.cssfile in thedocs/css/directory of your MkDocs project.Add the following lines to your
mkdocs.ymlfile:extra_css: - css/pseudo-code.css
Usage
Write your pseudocode in fenced code blocks with the pseudocode language identifier:
```pseudocode
% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
\begin{algorithm}
\caption{Quicksort}
\begin{algorithmic}
\PROCEDURE{Quicksort}{$A, p, r$}
\IF{$p < r$}
\STATE $q = $ \CALL{Partition}{$A, p, r$}
\STATE \CALL{Quicksort}{$A, p, q - 1$}
\STATE \CALL{Quicksort}{$A, q + 1, r$}
\ENDIF
\ENDPROCEDURE
\PROCEDURE{Partition}{$A, p, r$}
\STATE $x = A[r]$
\STATE $i = p - 1$
\FOR{$j = p$ \TO $r - 1$}
\IF{$A[j] < x$}
\STATE $i = i + 1$
\STATE exchange $A[i]$ with $A[j]$
\ENDIF
\ENDFOR
\STATE exchange $A[i]$ with $A[r]$
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}
Customization
CSS
You can customize the appearance of the pseudocode by adding your own CSS rules. The default CSS classes used are:
.ps-root.ps-algorithm.ps-algorithmic.ps-caption.ps-keyword.ps-procedure.ps-if.ps-for.ps-while.ps-repeat.ps-foreach.ps-state.ps-call.ps-funcname.ps-indent-{level}
JavaScript
To ensure MathJax expressions are rendered correctly, you may need to add the following JavaScript snippet to your MkDocs theme:
<script>
document.addEventListener("DOMContentLoaded", function() {
if (typeof MathJax !== 'undefined') {
MathJax.typesetPromise();
}
});
</script>
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.
Author
Jules TOPART
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_pseudocode-0.1.4.tar.gz.
File metadata
- Download URL: mkdocs_pseudocode-0.1.4.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6ed30fa8b0057946267e6f85f59fc8dac6fb4fb7178f8e806ca43f96fa70aa2
|
|
| MD5 |
5e05591c234d95fbc3f7c669a2189ba7
|
|
| BLAKE2b-256 |
fb1f7f17f3322eccf374e0e24ce057abdc328b9935fad6fbbf026db58d48c94e
|
File details
Details for the file mkdocs_pseudocode-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mkdocs_pseudocode-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fe168cc91ccf0ddf037249ea49c986a14f82a8efa292a79650f0c3f457d7393
|
|
| MD5 |
bfde5ef151a31b1b99299fc199770057
|
|
| BLAKE2b-256 |
c28c5dda5359bac712c01113e664deffd382fd3e95f209b6914580900b5ddc9e
|