Closed benrbray closed 3 years ago
Why are you adding commas in there, they aren’t supposed to be there: the stuff between curly braces are HTML attributes, with the addition that shortcuts for ID and class exist: https://github.com/micromark/micromark-extension-directive#syntax
I find no reference of commas, and do find many references w/o them, in the proposal: https://talk.commonmark.org/t/generic-directives-plugins-syntax/444
Sorry, you're absolutely right about the commas, I was confused. The suggestion about returning the list of class names as an array still makes sense, though, I think. It would be a breaking change, so maybe it's not worth it when a .split(" ")
will do.
The downside of that is that I think it would be confusing to explain:
class
is split in cases such as class="a b"
for="c d"
There are also a couple of other things that could be “smarter”, such as “boolean” attributes (download
), so without a value, or style as an object. However, I think that would make it all a bit hard to explain. I’d say sticking as close to HTML is the most reasonable solution
I don’t think it’s a wise idea to treat class
differently, as stated in my previous comment, so I’ll close this.
Initial checklist
Subject
Markdown:
Mdast:
Problem
Currently directive class names like
{.one, .two, .three}
are returned as a string:This is a bit weird, since the class name have been transformed, just not into a useful format. There's also a pesky trailing comma to remember when parsing the string manually. I would expect any of the following instead:
".one, .two, .three"
"one two three"
["one", "two", "three"]
I also noticed that the
id
field keeps the trailing comma if something appears after it, which is a bug.If this is something you're willing to change, I would be willing to work on the PR. Thanks!
Solution
Proposed changes:
:foo{.one, .two, .three}
should have{ class : ["one","two","three"] }
instead of{ class : "one, two, three," }
:foo{#id, .one}
should have{ id : "id" }
instead of{ id: "id," }
Alternatives
see above