Skip to content

aminnairi/markdown-table-align

Repository files navigation

markdown-table-align

Align your markdown table

Requirements

  • Deno
  • Git (for local binary compilation)
  • Bash, or Zsh, or Fish, or any GNU/Linux shell (for usage with a binary)

Installation

With Deno

deno run jsr:@aminnairi/markdown-table-align example.md
cat example.md | deno run jsr:@aminnairi/markdown-table-align

With compilation

# Clone the repository
git clone https://github.com/aminnairi/markdown-table-align
# Change the current directory
cd markdown-table-align
# Compile the binary
deno compile --allow-read --output ~/.local/bin index.ts
# Run the compiled binary
markdown-table-align example.md

Where ~/.local/bin is the folder containing your binaries.

Usage

Command line interface

With argument

cat example.md
| ID | Name | Category ID |
| 11092 | Gorilla Fist | 27 |
| 11212 | Plate 3 x 3 | 14 |
| 11209 | Tyre 21 x 9.9 | 29 |
| 11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27 |
markdown-table-align example.md
ID          | Name                             | Category ID
----------- | -------------------------------- | -----------
11092       | Gorilla Fist                     | 27         
11212       | Plate 3 x 3                      | 14         
11209       | Tyre 21 x 9.9                    | 29         
11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27

With pipe

cat example.md
| ID | Name | Category ID |
| 11092 | Gorilla Fist | 27 |
| 11212 | Plate 3 x 3 | 14 |
| 11209 | Tyre 21 x 9.9 | 29 |
| 11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27 |
cat example.md | markdown-table-align
ID          | Name                             | Category ID
----------- | -------------------------------- | -----------
11092       | Gorilla Fist                     | 27         
11212       | Plate 3 x 3                      | 14         
11209       | Tyre 21 x 9.9                    | 29         
11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27

Library

deno add jsr:@aminnairi/markdown-table-align
import { alignMarkdownTable } from "@aminnairi/markdow-table-align"

const separator = "|"

const content = `
| ID | Name | Category ID |
| 11092 | Gorilla Fist | 27 |
| 11212 | Plate 3 x 3 | 14 |
| 11209 | Tyre 21 x 9.9 | 29 |
| 11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27 |
`

const aligned = alignMarkdownTable(separator, content)

console.log(aligned)
ID          | Name                             | Category ID
----------- | -------------------------------- | -----------
11092       | Gorilla Fist                     | 27         
11212       | Plate 3 x 3                      | 14         
11209       | Tyre 21 x 9.9                    | 29         
11640pr0003 | ELECTRIC GUITAR SHAFT Ø3.2 NO. 3 | 27

License

See LICENSE.

Contributing

See CONTRIBUTING.md.

Security Policy

See SECURITY.md.

Issue

See issues.