jgm / djot

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

Syntax for block attributes for list elements (`<li>`) #185

Open tmke8 opened 1 year ago

tmke8 commented 1 year ago

As discussed in https://github.com/jgm/djot/discussions/183 there is currently no way to attach attributes to a list element.

This

{#foo .bar .baz key="my value"}
- list element

attaches the attribute to the list container (<ul>) but not the list element.

To solve this problem, I'm suggesting the following syntax:

- item 1
- {#foo .bar .baz key="my value"} item 2
- item 3

The output should look like this:

<ul>
<li>item 1</li>
<li class="bar baz" id="foo" key="my value">item 2</li>
<li>item 3</li>
</ul>

The same should work for other list markers:

- {#foo .bar .baz key="my value"} list item
+ {#foo .bar .baz key="my value"} list item
* {#foo .bar .baz key="my value"} list item
1. {#foo .bar .baz key="my value"} list item
1) {#foo .bar .baz key="my value"} list item
(1) {#foo .bar .baz key="my value"} list item
a. {#foo .bar .baz key="my value"} list item
a) {#foo .bar .baz key="my value"} list item
(a) {#foo .bar .baz key="my value"} list item
A. {#foo .bar .baz key="my value"} list item
A) {#foo .bar .baz key="my value"} list item
(A) {#foo .bar .baz key="my value"} list item
i. {#foo .bar .baz key="my value"} list item
i) {#foo .bar .baz key="my value"} list item
(i) {#foo .bar .baz key="my value"} list item
I. {#foo .bar .baz key="my value"} list item
I) {#foo .bar .baz key="my value"} list item
(I) {#foo .bar .baz key="my value"} list item
: {#foo .bar .baz key="my value"} list item
- [ ] {#foo .bar .baz key="my value"} list item