Apparently that way of detecting data on stdin is not really fool
proof. Instead of improving that let's just swap the order and look for a file
first. yolo.
By getting rid of the PHONY install and bundling the go get with its uses we
can prevent unnecessary go gets in `make build` - this speeds up development as
I run `make generate-fixtures` a lot and fetching dependencies takes
comparatively long.
We also add the `-d` flag to go get to get rid of the deprecation warning
```
go get: installing executables with 'go get' in module mode is deprecated.
To adjust and download dependencies of the current module, use 'go get -d'.
To install using requirements of the current module, use 'go install'.
To install ignoring the current module, use 'go install' with a version,
like 'go install example.com/cmd@latest'.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
```
org mode supports [1] setting the value attribute [2] of ordered list items to
change the numbering for the current and following items. Let's do the same. As
the attribute has no meaning for other types of lists [2] we'll just not
support it for those cases [3].
[1] https://orgmode.org/manual/Plain-Lists.html#Plain-Lists
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li#attributes
[3]
Org mode seems to instead set the id attribute for e.g. unordered lists
starting with `[@\d+]\s` - but I don't really see the value in that and will
skip that for now.
The actual parameter parsing logic in emacs org mode is quite complex [1]. All
we want for now is to handle parameter values containing spaces [2]. Splitting
on ` :` gets us close enough for now. As I'm very opposed to copying 100 lines
of parameter parsing logic just to get exports right let's wait for use cases -
no hurt in gathering requirements as we go.
[1] https://github.com/bzg/org-mode/blob/master/lisp/ob-core.el#L1481
[2] I never ran into such parameters before and wrongly assumed that splitting
on spaces would be enough. boy was i wrong - just look at that massive
function [1]! that's why we can't have nice things!
This reverts commit bf7f957af2.
We still have to manually install it for now but we don't have to fuck around
with env vars anymore. github actions still defaults to go 1.15 [1]. Whatever.
[1]
```
ls -lisah $(which go)
108022 0 lrwxrwxrwx 1 root root 42 Mar 18 22:15 /usr/bin/go ->
/opt/hostedtoolcache/go/1.15.10/x64/bin/go
```
org mode allows rendering the toc anywhere in the html document using the `TOC`
keyword [1]. There's more options but `#+TOC: headlines $n` should be enough
for starters. Note that org mode still requires setting `#+OPTIONS: toc:nil` to
disable the default toc
[1] https://orgmode.org/manual/Table-of-Contents.html
Instead of the bare bones default config we embedded as a string until now we
can use go 1.16 embed to embed the test blorg.org which makes a much better
starting config (if only to see what's possible).
Hugo defaults to serving files with pretty urls [1] - this means
`/posts/foo.org` is served at `/posts/foo/`. This works because servers
default to serving index.html when a directory is specified and hugo renders
the post to `/posts/foo/index.html` instead of `/posts/foo.html`. To make
relative links work we need to (1) remove the fake `foo/` subdirectory from
unrooted links and (2) replace any `.org` suffix with `/`.
[1] https://gohugo.io/content-management/urls/#pretty-urls
For hugo to pull in changes we need to create a pull request. Creating the
branch for that is repetitive and can be easily automated, so let's do
that. Creating the pull request itself is not as easily automated as it might
be necessary to provide a little context for the changes - so let's keep it
manual.
As headlines are always lvl (indent) 0 I thought it would be clever to abuse
the lvl field to store the headline lvl. Well, here we are - it wasn't clever.
List items only end when their parent ends or they run into something that's
not indented enough - everything else becomes part of the list item. Abusing
the token.lvl field (indent) for the headline lvl means headlines look indented
to the list item parsing logic - i.e. they become part of the list item if the
headline has a high enough lvl. That should never happen - so let's get rid of
the hack and (re-)calculate the headline lvl when we need it.
Turns out Org mode supports image links natively and we don't have to go out of
spec!
From https://orgmode.org/manual/Images-in-HTML-export.html:
[...] if the description part of the Org link is itself another link, such as
‘file:’ or ‘http:’ URL pointing to an image, the HTML export back-end in-lines
this image and links to [...]
html does not support table separator rows as Org mode does. Emacs org export
simulates rows as defined by separators by wrapping all the rows between 2
separators into a separate tbody. The html spec is fine with that [0] so we
follow.
[0] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
All tags are put on a line by themselves to help with visual
diffing. Apparently this extra cosmetic whitespace causes problems inside p
tags for ppl who want to use `white-space: pre`. Not much hurt for visual
diffing in removing cosmetic whitespace for just p tags and can't think of
anything that would break because of this right now. So let's do it and wait
for things to break.
hugo is nice - but it's huge. I've never built a static site generator before
and thought the world could use one more - it's not like there's already enough
choice out there!
No, but seriously. I love hugo and it has all the bells and whistles and you
should definitely use that and not this. I just like reinventing the wheel to
learn about stuff - and I like the 80/20 rule. This gives like 60% of what I
want already and is tiny fraction of hugo in terms of LOC (hugo without it's
bazillion dependencies is like 80k+ - this is like 500 and very likely won't
ever grow above let's say 5k).
Also org mode is awesome and why not use it as a configuration format as
well. Let's see where this goes. YOLO.