-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fenced div class parser is too strict #76
Comments
@jgm |
Can you link to documentation proving that
|
@jgm While it is true that the CSS spec prevents use of these characters ... why should the commonmark parser assume that it is to always generate strict CSS classes? Because, there are legitimate use cases where one would want to have it accept non-standard CSS classes, to be in turn run through CSS preprocessors (that do use these characters, with special semantics, 'compiling' them to valid CSS classes in the final HTML) like Tailwind. I use commonmark-hs with the fenced_divs extension in Emanote, to apply Tailwind-based styling to arbitrary blocks in Markdown. For eg., see here https://note.ema.srid.ca/demo/custom-style#advanced-styling - where multiple embedded notes (themselves divs) are arranged in grid fashion using Tailwind's classes. Their source Markdown contains, :::{.grid .grid-cols-2 .grid-flow-row .gap-0 .p-3 .bg-gray-500}
![[examples]]
![[start]]
![[file-links]]
::: The problem here is that I'm unable to use the responsive variant classes like As an aside, Tailwind is an interesting library to consider here because it enables "composition" of CSS styles via nothing but CSS classes ... which lends quite well to the fenced_divs extension inasmuch as it allows providing a list of classes (that are composed by way of concatenation, which is how Tailwind composes). |
Tailwind has the following example:
Is the idea that tailwind compiles this HTML down to HTML that contains only valid class names? Note: you can already do this:
|
So, there are more than one compiler actually. The answer is "no" to case 1, and "yes" to case 2.
(There is also JS shim, which is what Emanote currently uses; but it will be moving towards the model 2 above).
Ah, I didn't know about this syntax. That actually would work in our case, though it would be nice to be able to do things like this (using #75):
But given that there is an alternative (slightly more verbose) syntax that does work, it now becomes super less important, I guess. |
Using alternate syntax: jgm/commonmark-hs#76 (comment)
Using alternate syntax: jgm/commonmark-hs#76 (comment)
In TailwindCSS, we have CSS class names like
w-1/2
which trip up the fenced div parser.Example,
A potential fix is to add
/
to the list here (any reason not to do that?)commonmark-hs/commonmark-extensions/src/Commonmark/Extensions/Attributes.hs
Line 273 in 3d545d7
Tailwind classes can also contain a hyphen (eg:
md:w-auto
), so we might as well add:
.The text was updated successfully, but these errors were encountered: