jgm/djot.js

Heading attributes disappear from hierachical sections

hellux opened this issue · 3 comments

hellux commented
{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

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

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

OK, I've done it that way.