-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
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 :) |
|
@digitalmoksha Right, an option it is! You reckon it ought to be added to this RenderOptions struct? Given that we're doing a configuration option anyway, do you think it might make sense to make the actual class names configurable? So then the API would be something like: struct RenderOptions {
tasklist_classnames: TaskListClassNames, // Could also be Option<TaskListClassNames> ?
...
}
struct TaskListClassNames {
list: Option<String>,
list_item: Option<String>,
checkbox: Option<String>,
} Then we don't have to agree on the best class names to use! |
@nicoburns yes, I think it should go in Concerning the class names. I'll withdraw my naming suggestion. I think allowing the class names to be specified would add unnecessary complexity. So I would leave it as you have it, and if it ever became a real requirement, could be considered then. But I'm all for simplicity. |
c2ecee7
to
9524a97
Compare
@digitalmoksha I've updated to gate outputting of classes behind an |
@nicoburns looks really good! wdyt about adding the option in I approved to let the all the tests run. Looks like there is a small clippy error, but otherwise everything passes. I would say if we can fix that, add the option for the command line, then we can pass this to @kivikakk for final approval. |
9524a97
to
f0d3a3b
Compare
@digitalmoksha Formatting error fixed. And option added to the CLI in |
@nicoburns sorry, I missed the fact that we need to add the option to the diff --git a/fuzz/fuzz_targets/all_options.rs b/fuzz/fuzz_targets/all_options.rs
index 131c932..2af39c8 100644
--- a/fuzz/fuzz_targets/all_options.rs
+++ b/fuzz/fuzz_targets/all_options.rs
@@ -57,6 +57,7 @@ fuzz_target!(|s: &str| {
render.ignore_empty_links = true;
render.gfm_quirks = true;
render.prefer_fenced = true;
+ render.tasklist_classes = true;
markdown_to_html(
s, I'm running fuzzing now, @kivikakk mind giving this a final review when you have time? |
e362f3e
to
975d3bf
Compare
This looks excellent. Thanks so much for your work, @nicoburns, and for reviewing and providing feedback, @digitalmoksha! |
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