jgm / djot

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

Attribute references #259

Open panglesd opened 7 months ago

panglesd commented 7 months ago

I'd like to use the djot syntax for writing presentations, that may require quite a lot of attributes.

However, inline attributes in the middle of the text harm the readability, which was the initial goal of markdown (from which djot is clearly inspired!)

I'd like to propose some idea to improve that: references to a set of attributes.

This [text][a] is an [example][a] of [factorisation][a] of a lot of [attributes][b].

[a]: { pause emph-at-unpause}
[b]: { step top-at-unpause } 

So:

In particular the above would be equivalent to:

This [text]{pause emph-at-unpause} is an [example]{pause emph-at-unpause} of [factorisation]{step top-at-unpause} of a lot of [attributes][b].

What do you think of this syntax?

jgm commented 7 months ago

You can already add attributes to a link reference, using the syntax that is always used for adding attributes to blocks:

% djot
[text][a]

{.foo #bar}
[a]:
^D
<p><a href="" class="foo" id="bar">text</a></p>

Currently link references only work for links. It could be interesting to think about letting them work for spans, so that when a URL is missing, as in the above example, we'd get

<span class="foo" id="bar">text</span>
panglesd commented 7 months ago

Thanks for your answer! I just though that

{.foo #bar}
[a]:

is not very self-explanatory, and less readable than a "first class support":

[a]: {.foo #bar}

But maybe that's not worth "first class support".

jgm commented 7 months ago

I kind of agree with you about intuitive readability. But it's good to have a consistent system for adding attributes that works the same for every type of block. Otherwise people have to remember where attributes can go in each case. There's a high bar for making an exception, I think.

jgm commented 7 months ago

However, one could argue that there's a conceptual difference between adding an attribute to a reference definition block, and making the attribute part of the content of the reference (which is what we're doing here).