Inlineswap

Seems like every programmer on earth wrote a static HTML generator ;). So here's mine: inlineswap, which is currently used by the website of ranger.

What's special about it? The main idea is that it will look for commands in your HTML files and put the result of those commands right back into the HTML file. This would be an example of the "run" command:

<!-- run echo '# Hello World' | markdown -->
<!-- /run -->

which will be substituted in-place to:

<!-- run echo '# Hello World' | markdown -->
<h1>Hello World</h1>
<!-- /run -->

As a result, the source file is also the output file, which is a nice property that I only found in inlineswap so far.

Other commands

There's 2 more commands, documented in the comments of the executable file.

  • With "get" you can automatically copy&paste parts from other HTML files, so you can e.g. change the website header in 1 file and auto-update it in the other files.
  • With the "relative" command you can fix relative links that would otherwise break if you "get" a part from a HTML file that is in another directory.

Real-life example

A real-life example is the changelog page of the ranger website. It contains the following commands:

<!-- get head from index.html -->
<!-- run markdown CHANGELOG | sed 's/h1>/h2>/g' -->
<!-- get foot from index.html -->

The index.html defines the "head" and "foot" parts with simple <!-- head --> and <!-- foot --> comments.

Should I use it?

Probably not. Learn something more useful.

— 2021-06-04, by hut, tags: #ranger