Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.61 KB

File metadata and controls

51 lines (37 loc) · 1.61 KB

prettier-plugin-sort-markdown-table

npm version npm downloads codecov

Prettier plugin that sorts markdown tables according to their first column.

Install

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.

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