I think Einar said that if you want to blog you should write blog posts, not write blog engine. At least sometimes people say something like that.
Einar uses WordPress.
So when Einar writes about weird DSL for writing HTML it is typically not a description of how his blog works.
Anyway it’s a thing that makes sense. So here’s a new home-made markup language for my home-made blog engine.
I’ve played around with making my own language for this a few times. I like the idea of having something where it’s so easy to implement tooling for it that, if I ever need or want to reimplement it, maybe in a different language/environment, then that won’t be a big deal. Preferably not even much of a factor in deciding if I’m going to move to a different language or something. And also simple enough so that I can write (and read) posts in that format correctly without much help from specialized tools or something.
I tend to mess up and things tend to get too complicated.
I ran into Gemtext the other day. Gemtext takes a pretty straightforward approach to some things.
You get one kind of list and you can't nest them
Which goes for most things. Like generally you can’t have <thing> within <other thing>. No quote within a list, or link within a heading, or whatever. Or, it’s very line-oriented, and you can’t like, nest lines.
It’s not too hard to build a Gemtext-parser. It’s also really easy to write Gemtext in any text editor.
Also it tends to look kind of like my plaintext-notes would look anyway. E.g. I tend to end up with stuff like paragraphs being long lines and use separate lines for links.
(Also also I like how using a full line for a link tricks me into writing more self-contained link texts (instead of stuff like the link text being “here”). Which I’m told people using screen readers sometimes appreciate.)
So I decided to steal ideas from Gemtext and make something with a lot less functionality than what I have attempted previously:
A Glorpdown editor.
This post in Glorpdown.
Some basics:
=>
) has two arguments, link type and path. A blockquote has no arguments, just a >
-start followed by the text that goes in the quote._
-characters is emphasized. Text between `
-characters is code
. You can’t nest/combine those things.\
-character. Necessary for escaping formatting characters or for having regular text lines start with the <start> of another line type.Most of the things:
More or less like in Gemtext. The <start> of a regular text line is the empty string. Or: If the start of a line does not match the <start> of any of the other line types, it is a regular text. Should be empty lines between paragraphs. Line breaks within paragraphs are preserved when translating to HTML and such.
Same as in Gemtext, three levels: Lines that start with #
, ##
or ###
. E.g. I do this for the following heading:
Same as in Gemtext: Lines that start with >
Hello.
Same as in Gemtext: Lines that start with *
are list items.
Regular links are similar to the ones in Gemtext, but with a “type” argument before the path/url:
Unlike in Gemtext there’s a different line type for stuff that should be included in, or viewed in context of, the document. Typically images:
(In my mind the way this makes sense is that the =>
-arrow points to some thing that you can go to, while the <=
-arrow is more like, the thing is moving into the current document.)
Same as in Gemtext, preformatted text is turned on by a line that starts with ```
. Not like in Gemtext, any non-whitespace characters directly after the ```
are considered part of the <start> and must be matched by the start of a later line to turn it off again (so you can e.g. do four backticks for the <start> if you want to have a line of preformatted text start with three backticks without that being a “turn off the preformatted text”-line). No line types or text formatting or escaping characters within preformatted text.
So:
Becomes:
In Gemtext you can write some stuff after the <start> of a line that turns preformatted text on and have that be “alt text.” In Glorpdown this text is instead potentially used when rendering. E.g. for marking some preformatted text as a “repl,” so that later code can turn it into a editable textare or something.
If there’s text after the <start> of a line that turns preformatted text off, then that’s used as a caption for the preformatted text.
A section of preformatted text where the text after the <start> if the line that turns it on goes like lines <w h>
.
More lines-stuff, including an editor.
Not in gemtext. This it “toggled,” kind of like with the preformatted text. Lines that start with +++
. The text after the first +++
becomes the summary. The content between a first and second +++
-line is details (the stuff you see if you click to expand or something).
Not at all in Gemtext. Mostly for metadata. Lines that start with :
are key-value lines. If a line goes :<argument> <text>
then <argument> is the key and <text> is the value. E.g. this post has a line that goes:
And then I have some blogging machinery that uses that date for displaying list of posts with their dates.
Not in Gemtext. Lines that start with ----
Blah blah. That’s mostly it.