Description
Description
I'm writing my own extension that makes use of the capabilities of the baked-in attributes extension. However, upon testing, I found that it is currently not possible to add an attribute without a value on an element.
I would like to be able to add an attribute without any value to prevent me (and the eventual users of my own extension) from having to add an arbitrary value every time like so:
{my-attribute=true}
Example
Consider parsing the following Markdown with CommonMark, with the Attributes extension loaded:
{my-attribute}
I would expect the following HTML to be rendered:
<p><img src="/assets/image.jpg" alt="image" my-attribute /></p>
However, I'm seeing the following:
<p><img src="/assets/image.jpg" alt="image" />{my-attribute}</p>
I believe this has to do with the League\CommonMark\Util\RegexHelper::PARTIAL_ATTRIBUTEVALUESPEC
constant enforcing the presence of an equals character (=
) and a subsequent value.
If this were to be changed, the way we extract the attribute name and value would also have to be changed in League\CommonMark\Extension\Attributes\Util\AttributesHelper
.
I'll try to whip up a quick PR to get this going, but would love some input if this is even something you want to consider for this project before I dive in fully 🙂
Did this project help you today? Did it make you happy in any way?
I'm exceptionally happy with the way this project is set up. It was super easy to dig and start working on my own extension because of the outstanding documentation and the easy-to-follow code when I needed to dig deeper and do some source-diving. So thank you ❤️