-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add task-list-item
class to task list items
#468
base: main
Are you sure you want to change the base?
Conversation
Nice addition @nicoburns. I like the idea of having that class added, have thought about adding it myself - would save me from having to do it in post-processing. Though it might need to be behind a render option since it would change what the default GFM output is. Having a class on the
I like the class |
bad9c9f
to
52b693b
Compare
One suggestion - it looks like you're making a specific choice between ordered, unordered, and task list. However, a task list can be either ordered or unordered. GH makes the distinction but doesn't display the numbers, while GitLab makes the distinction and does display the numbers. So I would keep making the list either ordered or unordered, and then they either contain tasks or not. |
Yep! I thought I was being clever combining it into the type enum. Then realised the tests weren't passing 🤦 . Will rework this to use a separate property. |
2c22915
to
c2ecee7
Compare
Ok, done! And I've squashed it all down into one commit because the history was getting messy :) |
|
ListType::Bullet => { | ||
self.output.write_all(b"<ul")?; | ||
if nl.is_task_list { | ||
self.output.write_all(b" class=\"contains-task-list\"")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to advocate again for task-list
. This doesn't "contain" a task list, it "is" a task list. I don't think we need to follow GH on this. https://github.com/jgm/commonmark-hs also uses task-list
.
I am trying to render tasklists similar to how Github renders them. Unfortunately it is currently very difficult to differentiate between a tasklist and a regular list generated by comrak using CSS, which is leading to my renderer rendering both the checkboxes and the regular list bullets for tasklists.
Github works around this issue by adding a special class to the
<ul>
and the<li>
elements, which allowslist-style-type: none
to be specified for tasklist list items (causing the regular bullets to be hidden). I have implemented this for the<li>
element of task lists in this PR. Doing it for the<ul>
as well is more difficult as it doesn't have a special AST node. And it is also not required to set thelist-style-type
style for the list items.Illustration of the problem:
Testing mixed lists:
Numbered
Item
Numbered
Bullet
Bullet