google / keep-sorted

keep-sorted is a language-agnostic formatter that sorts lines between two markers in a larger file.
Apache License 2.0
132 stars 15 forks source link

Allow string-valued options to contain spaces #28

Closed JeffFaer closed 1 month ago

JeffFaer commented 8 months ago

For example, if I want to sort markdown lists:

  * foo
  * bar
  * [baz](./path/to/baz)

I would want that to be sorted as

  * bar
  * [baz](./path/to/baz)
  * foo

But the [ in front of baz interferes with that. One workaround would be to use ignore_prefixes, but there currently isn't any way to include a space in the ignored prefix. In this situation we would need something likeignore_prefixes="* ","* ["

This function needs to be updated so that string-valued options can accept values with spaces: https://github.com/google/keep-sorted/blob/15e6c2f2cd560d0d2d850d1e0e11a73d6da18573/keepsorted/options.go#L141-L153