I’m gradually migrating posts from Markdown to Org.
I’ve been writing posts in Markdown for a while now, but lately I’ve been pondering whether to use Org instead.
Now, it’s finally happening! I’ve started an experiment where new posts, starting from this one, will be written in Org.
There’s really no strong reason other than I feel slightly more comfortable with Emacs + org-mode.
Additionally – and perhaps crucially? – I profit from Babel to evaluate inline code within the comfort of Emacs directly in the buffer containing the post. With discipline, it should help me ensure all the code actually compiles and (maybe) produces the expected outcome, which is generally hard to achieve otherwise due to copy-paste deviations.
Example: Python snippet evaluated with
ob-python
from collections.abc import Iterator
import itertools
def nats() -> Iterator[int]:
n = 0
while True:
yield n
n += 1
for n in itertools.takewhile(lambda n: n < 10, nats()):
print(f"n = {n}")
Now, with my cursor in the code, I type C-c C-c
(Emacs for Ctrl+c
Ctrl+c
) and I see the output of running it.
That’s good, because I don’t feel much need to frequently switch from buffer with the text to another place to test code and then copy it back to original buffer, with all the perils of a deviation between the code I tested and the code I published.
I haven’t taken the time to clean things up yet and may never do so.
Thus, for now I’m lazily shelling out to pandoc
in the GitHub Action
to convert Org to
Markdown
before deploying the site. Lastly, to lower the friction of blogging, I
wrote an Emacs Lisp
function
to start a new post with all the boilerplate.
This is all part of a larger refactoring, in which I’ve changed the style of this blog and intend to focus more on shorter essays from now on.
Anyway, more focus, more fun! Or so one hopes.