Empty block elements in Ducktype

Shaun McCance <shaunm at gnome.org>
Thu Jan 1 16:15:10 EST 2015

I have a ducktype syntax problem I'd like input on. With the current
parser, you can have non-indented child elements, according to roughly
the following rules:

A) When not indenting, blank lines always end leaf block elements, i.e.
elements that take a mix of text and inline content.

B) Most block container elements consume only one unindented block
element. Unless they get a title first, in which case they'll gobble
just one more.

C) Elements that take <item> children (list, steps, terms, tree) just
keep taking unindented elements as long as they're item elements.

D) Tables keep taking elements as long as they're thead, tfoot, tbody,
or tr.

E) tr keeps taking elements as long as they're td or th.

Remember, all of this is convenience to keep you from having to indent
in the simplest cases. It lets you write this:

[note]
This is the note.

Instead of this:

[note]
  This is the note.

If you want a two-paragraph note body, you have to indent. These rules
are also what let you use the "* " shorthand for list items and table
cells without having to add weird indentation before them.

Fine. All of this works great as long as block elements always either
contain more block elements, or are leaf elements with actual text. When
you add empty block elements into the mix, the whole thing falls apart.

By these rules, I can't make an empty block media element.

  [media src=somefile.webm]

  Oh noes, this is a child of the media element.

And most distressingly, I can't use the links element at all.

  [links type=topic]

  This is a child of the links element, which is just dumb.

What's worse, this isn't just a case of the default behavior not being
what you expect, there is just absolutely no way to get around this.
Empty block elements are impossible.

So:

1) Decide that blank lines close off non-indented blocks. You won't be
happy with long lists if we do this.

2) Decide that a blank line right after a block declaration makes that
block empty. But then what about a links element with a title but no
children?

3) Do as in (2), but also a blank line right after the title closes the
unindented block. I think you won't be happy with long lists with this
option either.

4) Do as in (3), but instead adopt the one-liner title shorthand that I
proposed on Dec 11. Will probably be a touch more palatable, but I
suspect people will get bitten by it.

5) Decide that links and media elements are really super special, and
that a blank line closes them. I don't like special elements, because it
makes extensions hard.

6) Decide that lists and tables are special, and that they're the only
things you can keep open with blank lines. They're already special with
rules C, D, and E.

7) Come up with an empty block element syntax?

   [links type=topic /]

   Gross.

8) Give up on non-indented shorthand. You don't want to do this. All the
list and table shorthands rely on it.

9) Something else.

[Shaun /]