jgm / djot

A light markup language
https://djot.net
MIT License
1.67k stars 43 forks source link

Line blocks #29

Open jgm opened 2 years ago

jgm commented 2 years ago

Pandoc offers a line block format which is useful for addresses and such things as poetry. In this format, newlines are hard breaks, and all spaces are significant, even leading spaces.

| The limerick packs laughs anatomical
| Into space that is quite economical.
|   But the good ones I've seen
|   So seldom are clean
| And the clean ones so seldom are comical.

Note that the same effect can be achieved with backslash-newline and backslash-space, but it arguably looks less natural.

The limerick packs laughs anatomical\
Into space that is quite economical\
\ \ But the good ones I've seen\
\ \ So seldom are clean\
And the clean ones so seldom are comical.

In addition, the pipes may create confusion with pipe tables. So, not sure this feature is worth it.

uvtc commented 2 years ago

I didn't realize you could use backslash-space to make consecutive spaces that would not be condensed down to a single space. (I've previously used something like \hspace{0.5cm} for that (when targetting pdf)).

matklad commented 1 year ago

I think this can be generalized to a block, which applies only inline formatting, ignores block formatting and keeps whitespace. That is, verbatim + inlines.

This potentially could be useful for https://github.com/jgm/djot/discussions/49.

Omikhleia commented 1 year ago

Note that the same effect can be achieved with backslash-newline and backslash-space, but it arguably looks less natural.

Just my two cents regarding the semantics: what does that backlash-space really means here actually?

In regular justified content, it's usually a non-breaking space, so typically a U+00A0... But in proper typography those are stretchable and shrinkable as any interword-space, i.e. have a variable width. See Unicode TR14 §3.

In regular poetry, I'd say that the initial "indent" of a verse is (usually) a fixed-width space. It could be, for instance an em-quad (U+2001)... Whatever, it's usually not adjustable.

To work around this, a rendering engine could say, well, that \ may be seen as stretchable except when it's initial in a paragraph or after a forced line break, but that seems a bit contrived, perhaps?[^1]

I am not saying that Djot shall necessarily have Pandoc-like Line Blocks --- just that the suggested "same effect" using existing syntax might not be fully equivalent, and might impose a mixed interpretation of backslash-space depending on context.

[^1]: For the record, that's how I interpret the initial space in Pandoc-like Line Blocks in markdown.sile in the context of poetry typesetting.