These are pieces of code that I use with Nikola. I use Nikola but haven’t really studied it so there are probably better ways to do most of these things, but this seems to work well enough. I’m converting this to a web-site with the built html here: https://necromuralist.github.io/Beach-Pig-Thigh/.
The templates are all mako templates for now. I have at least one repository that uses jinja (because why not? actually I think I just forgot which one I normally use) but I’m not updating it right at the moment. Templates go in the themes/custom/templates/
folder, assuming the theme’s name is custom
, as set in the conf.py
file.
This an update of the built-in template for handling math in nikola. It’s what gets called when you set the has_math
metadata flag with pseudocode.js added to it. It checks for a has_pseudocode
entry in the metadata to decide whether to inject it or not. It doesn’t check what the value is set with has_pseudocode
, as long as something is set it will put it in (so “False” is still True
).
If you just want math put this in the metadata:
.. has_math: True
But if you want pseudocode use:
.. has_pseudocode: True
**Warning:**
I made the has_math
flag take precedence over the has_pseudocode
flag so if you put both in only the math will get set. Maybe I’ll re-think that later. For now don’t put both in.
The math_helpers.tmpl
puts the javascript in the footer, which means that pseudocode.js
doesn’t load before it gets called in the body of the HTML (although MathJax does, somehow) so you need to wait for the page to load or it won’t render.
<script>
window.addEventListener('load', function () {
pseudocode.renderElement(document.getElementById("bubblesort"));
});
</script>
Where “bubblesort” is the ID set in the LaTeX algorithm block.
This is a shortcode plugin that is basically the same as the doc
shortcode but lets me pass in alternate text to use, even though I’m using org-mode, not RST.
- Foresman PS. English: Pig Butcher Diagram (PSF) [Internet]. 2019 [cited 2023 May 2]. Available from: https://commons.wikimedia.org/wiki/File:Pig_Butcher_Diagram_(PSF).png