jgm / djot.js

JavaScript implementation of djot
MIT License
146 stars 16 forks source link

Heading attributes disappear from hierachical sections #43

Closed hellux closed 1 year ago

hellux commented 1 year ago
{a=b}
# abc

results in

<section id="abc">
<h1>abc</h1>
</section>

instead of

<section a="b" id="abc">
<h1>abc</h1>
</section>

or

<section id="abc">
<h1 a="b">abc</h1>
</section>

The only attribute that does not disappear is the id, if provided it overwrites the id on the section as expected.

Headings within block containers are working as expected:

:::
{a=b}
# abc
:::
<div>
<h1 a="b" id="abc">abc</h1>
</div>
jgm commented 1 year ago

I've made a change which restores intended behavior, which is that the id attribute migrates the the section but other attributes stay on the heading.

I don't know if that's the best solution, though. Another approach would be to put all the attributes on the section.

hellux commented 1 year ago

Hmm, I would prefer to move all of the attributes to the section. I don't see why the id would be considered special in this case.

It would be kind of similar to how lists and list items are handled, attributes get applied to the list instead of the list item. If we want to let one apply attributes to the heading or list item, it could perhaps be solved similarly in both cases.

jgm commented 1 year ago

OK, I've done it that way.