Skip to main content

Ralsina.Me — Roberto Alsina's website

Some New Stuff in Nikola

I did some quick work on Niko­la (a stat­ic web­site/blog gen­er­a­tor) late­ly, af­ter a long time, and here's what it was:

Multilingual Sitemaps

So, sitemaps are used by Google to in­dex your site. It turns out that they can de­scribe when there are sets of pages that are trans­la­tions of each oth­er. So the next re­lease will do that (Is­sue #1610)

Matplotlib Plots

Mat­plotlib comes with a sphinx ex­ten­sion to do plots So I went and im­ple­ment­ed it, this was Is­sue #1242 and it's a plug­in called py­plot­s, which will be soon at http://­plu­g­in­s.get­niko­la.­com#py­plots

I hat­ed the orig­i­nal code. It felt con­vo­lut­ed, and just weird (it's prob­a­bly just me) so I wrote it from scratch and it has some mi­nor dif­fer­ences, but it's fair­ly com­pat­i­ble.

Classy Images

The do­cu­tils im­age di­rec­tive, for what­ev­er rea­son, does­n't sup­port a class op­tion, so you need to do things like this:

.. class:: foo

.. image:: blah.png

Which is ... not pret­ty. So I did a hacky plug­in that mon­key­patch­es the im­age di­rec­tive to add that op­tion. The plug­in is at http://­plu­g­in­s.get­niko­la.­com/#­classy-im­ages and this fix­es Is­sue 1538

Mediawiki Markup

djbclark point­ed out that there is a li­brary to parse Me­di­aWi­ki from python called sm­c.mw so I im­ple­ment­ed a plug­in to use it, so now you can use Me­di­aWi­ki markup. The plug­in is at http://­plu­g­in­s.get­niko­la.­com/#­me­di­awi­ki

Removed Default Swatch from Bootswatch

This was Is­sue #1656 and now you have to spec­i­fy the swatch. This is a us­abil­i­ty fix, be­cause de­faults mat­ter.

Played with KaTeX

Niko­la sup­ports math us­ing Math­Jax. Math­Jax has some in­ter­est­ing qual­i­ties:

  • It's 160MB of code or so

  • It's not prac­ti­­cal to use with­­out a CDN

  • It's not prac­ti­­cal to use we­bas­set bun­­dles with it

Then, klingt­net men­tioned some­thing called Ka­TeX I had nev­er heard about. I did a quick hacky con­ver­sion to see how it work­s. Not done yet, to­tal­ly ex­per­i­men­tal, but it may be pos­si­ble to bun­dle it, and maybe even have it turned on by de­fault, re­mov­ing the need for the math­jax la­bel which is aw­ful us­abil­i­ty-­wise.

Some of these things are merged, some are still PRs, some are in core, some are plug­ins. They were all pret­ty fun to do :-)

cHagHi / 2015-05-05 20:10:

I'm a bit lost with the purpose of the Classy Images plugin.

This seems to be valid reST for the docutils parser:


.. image:: blah.png
:class: foo

At least rst2html doesn't complain, and generates the expected result. So I don't understand what use case Classy Images is trying to solve/fix...

Roberto Alsina / 2015-05-05 20:14:

I wonder what I was drinking? I could swear this used to fail.

Roberto Alsina / 2015-05-05 20:18:

Looks like I misunderstood the bug. The problem is that when you have a target and a class, the class is applied to the img tag, and that made the islink hack fail. So this was never necessary, and I will delete it now :-)

cHagHi / 2015-05-05 20:33:

I had just started to add the :class: option to dozens of posts that link to Flickr (aka apply the islink hack), and then read this, and found the bug #1538, and the comment that having a :class: option inside an image directive was not standard reST, and panicked :P, because even if "Classy Images" seemed clean and small enough I didn't want to use non-standard reST. At first I thought "ok, this works because of this particular monkey-patching", but then I saw the plugin was commited just a few days ago, so I don't have it yet. And that's when I asked :-)

Good to confirm that mi reST is still standard then! Now I can go on with the (boring!) task of adding the damned class option...

Roberto Alsina / 2015-05-05 20:45:

You could tweak the template and make it be the other way around :-)

So then only links with a specific class get colorbox

re:fi.64 / 2015-10-13 18:34:

It's actually quite possible to already use KaTeX with Nikola, although it's kind of suckish:

http://kirbyfan64.github.io... (the page)
https://raw.githubuserconte... (source code)


Contents © 2000-2020 Roberto Alsina