Prettier plugin that sorts markdown tables according to their first column.
npm i -D prettier-plugin-sort-markdown-table
Prettier should automatically load this plugin once it's installed, you don't have to do manual configuration.
Annotate tables you want to sort with <!-- prettier-sort-markdown-table -->
comment.
For example:
<!-- prettier-sort-markdown-table -->
| name | email | description |
| -- | -- | --- |
| zhang | zhang@a.com | zhang |
| wang | wang@a.com | wang |
| li | li@a.com | li |
| amity | amity@a.com | amity |
| batman | batman@a.com | batman |
Becomes:
<!-- prettier-sort-markdown-table -->
| name | email | description |
| ------ | ------------ | ----------- |
| amity | amity@a.com | amity |
| batman | batman@a.com | batman |
| li | li@a.com | li |
| wang | wang@a.com | wang |
| zhang | zhang@a.com | zhang |
MIT © Doma