dprint / dprint-plugin-markdown

Markdown code formatting plugin for dprint.
MIT License
25 stars 9 forks source link

additional indentation for task lists #55

Closed kevgo closed 2 years ago

kevgo commented 3 years ago

Thanks for dprint! It reduces the time to format my knowledge base consisting of ~1600 Markdown files from 87 seconds (Prettier) to 0.2 seconds! 💥

I noticed different indentation behavior for task lists when always wrapping text. Prettier formats them with 6 spaces of indentation. This separates the check boxes visually from the text (playground example):

- [x] an issue with a very very long title that flows into subsequent lines in
      order to demonstrate how Prettier uses six spaces of indentation for task
      lists
- [ ] another issue

Dprint indents task lists with only two spaces. This somewhat hides the checkboxes in the text (playground example):

- [x] an issue with a very very long title that flows into subsequent lines in
  order to demonstrate how dprint uses only two spaces of indentation for task
  lists
- [ ] another issue

Both styles work but I think the Prettier version looks nicer and is a bit more ergonomic. How do you feel about matching Prettier's formatting of task lists in dprint? If you agree and provide some guidance, I'm happy to take a stab at implementing this.

dsherret commented 3 years ago

How do you feel about matching Prettier's formatting of task lists in dprint? If you agree and provide some guidance, I'm happy to take a stab at implementing this.

Yes, it does look better and that would be great.

If you want to take a look at implementing this, I think something like what's done in parse_list would need to be done for when item.marker.is_some(). Using with_indent_times(sub_items, 4) should work along with increasing and decreasing context.indent_level += 4 and context.raw_indent_level += 4.

Also, there seems to be no tests for multi-line task lists, which is probably why I never noticed this before.

Thanks for dprint! It reduces the time to format my knowledge base consisting of ~1600 Markdown files from 87 seconds (Prettier) to 0.2 seconds! 💥

Awesome! That is probably mostly the "increment": true feature, but probably even without it it would be super fast.