Support attributes following a block element
Opened this issue · 6 comments
Clear and concise description of the problem
Currently this plugin cannot handle when attributes are on a separate line.
Example use case, where expected result is
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
* List item
* List item
{.cool-list}
Suggested solution
Plugin markdown-it-attrs supports this syntax, so currently markdown-it-mdc simply errors when encountering this syntax. At a minimum should probably mention in the readme that these two plugins are incompatible.
Alternative
No response
Additional context
No response
Validations
Does this work? If so, this is the clearest syntax IMO
::ul{.cool-list}
- List item
- List item
::
It will be compiled to this
<ul class="cool-list">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</ul>
I guess we might need a bit of special handling for it.
It seems the behavior is a bit unpredictable/confusing to read. I am not very sure if we should support in. Even if we do, I think we'd need to update the MDC spec first before landing the implementation.
That's a valid concern. I would either:
a) apply newline attributes based on indentation
b) always apply newline attributes to closest block
Your new solution is neat and in line with general approach, but doesn't solve my use case where the plugin simply dies when trying to parse markdown that uses newline-attributes (for lack of a better term) 😅
Is there a way to make this plugin ignore newline-attributes so that markdown-it-attrs could handle parsing them?
You can disable it with: https://github.com/antfu/markdown-it-mdc/blob/5e34c911d279c04be192199d6cca1367dbd6cbc6/src/index.ts#L19C1-L25C26
Let me know if it doesn't work
Disabling inline attributes did not help. Newline attributes in my source material continue to trip up the parsing :/