jgm/djot

[Proposal] Remove leading whitespace

Brixy opened this issue · 2 comments

This proposal removes leading whitespace from nestable block elements like lists, footnotes, divs etc.

Generally I prefer not to have to use white space for nesting, but honestly—I am not quite sure whether I like this proposal enough. (Feel free to just close this issue.)

Djot’s current syntax–also regarding white space—is a lot better than markdown’s.

These ideas work together:

  1. Use a nesting level marker.
  2. Use a continuation marker which keeps the nesting level (examples use + ).

Option 1: non-unique nesting level marker

* Level 1

** Level 2

+ Paragraph belongs
to level 2

New paragraph outside the list

1. Level 1

+ Paragraph belongs to level 1

1.. Level 2

{.my-class}
+ > Block quote belongs to level 2

:::
Level 1

::::
Level 2
::::
:::

Option 2: unique nesting level marker (>)

* Level 1

{.my-class}
+ Paragraph belongs to level 1

>* Level 2

>>* Level 3

+ > Block quote belongs to level 3

+ Paragraph belongs to level 3

>>>* Level 4

The unique nesting level marker would work with any kind of nestable items, e.g.

1. Level 1

>1. Level 2

:::
Level 1

* Level 1

>* Level 2

>:::
Level 2
>:::
::::

A clear disadvantage is that the proposed syntaxes look more like “code” which probably does not align with markdown’s original idea.

Advantage is the removal of whitespace. Think of all the whitespace needed for such a case:

* Level 1

…

***** Level 5

+ This is … a very long paragraph
and its continuation

+ Yet another … very long paragraph.

All in all this is not too different from the current syntax: The nesting level marker just replaces leading whitespace in a visible way. The “keep nesting level”/continuation marker is a short form of an arbitrary number of leading whitespace.

jgm commented

I like the whitespace because it makes the source more readable to a human, and less like a computer language.
So, closing. But thanks for the suggestion.

I like the whitespace because it makes the source more readable to a human, and less like a computer language.

Absolutely true. Thank you for looking into this.