Closed hyrious closed 2 years ago
Hey!
In fact I'm still not fully understand how the plugin system works.
This is explained in-depth in the micromark readme, in the chapter on Extensions.
However, GitHub itself adds special classes to these tags to help styling:
Customization like this is not really what micromark is for. The AST provided by mdast/remark/unified/etc is a great place to do these things.
I wonder what you mean with “helps styling”: CSS can access these checkboxes with CSS selectors such as input:checked
.
The HTML extension here is pretty simple. You should be able to read the code and figure out how to change it to match your preference.
I am somewhat maybe open to a PR that introduces options to match github.com
instead of what they have in their spec. However, I there is already a whole ecosystem that does all of that: unified/remark/rehype/mdast/hast/etc.
Thank you for the reply!
Working on the AST does make sense. I just wondering if micromark could do this task (let events in list item (<li>
) affect the whole list (<ul>
), since the html extension only outputs the list item.
I may have to dig it for a while.
Yes styling the current output won't be hard in CSS4 when we have :has()
. GitHub does this just for removing the list-style/padding of the <ul>
. Besides, I have a github-markdown-css and I want to reuse it, so I want to be like github as much as possible.
Did you check the source btw? https://github.com/micromark/micromark-extension-gfm-task-list-item/blob/38ce420db9504bd3c14a13f68b95a7fc6db1454a/dev/lib/html.js#L6 Because it's tiny!
Yep, that's why I said
since the html extension only outputs the list item.
It took me some time to find out the correct event name for <ul>
is listUnordered
:
I'm still seeking the way to
enter.listUnordered
, so that I can just append tag('class="contains-task-list" ')
;Thanks again for the assistance.
Ah. Yeah, that is exactly what you need an AST for.
- call the default handler in a custom enter.listUnordered, so that I can just append tag('class="contains-task-list" ');
I might be slightly open to exporting default handlers. However, the compiler is very tightly coupled. Hard to externalize something like that.
- store some data in the syntax extension to let the html extension know when to append that tag.
getData
and setData
are that
I’m going to close this. I get what you want, but this project is intentionally really low level. We support everything you want at a higher level: mdast. Or remark.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
Initial checklist
Problem
It is true that the GFM spec said to generate task list in this way:
However, GitHub itself adds special classes to these tags to help styling:
I wonder how to accomplish this kind of output. In fact I'm still not fully understand how the plugin system works.
Solution
N/A
Alternatives
N/A