Prettier plugin that sorts markdown tables according to their first column.
This version of the plugin only works with Prettier 3. For Prettier 2, please use 1.x.
Install
npm i -D prettier-plugin-sort-markdown-table
Add the plugin to your Prettier configuration file:
{
"plugins": ["prettier-plugin-sort-markdown-table"]
}Usage
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 |
License
MIT © Doma