All Projects → wooorm → Markdown Table

wooorm / Markdown Table

Licence: mit
Markdown tables, with alignment

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Markdown Table

Ascii Tables
Quickly format table in ASCII. Great for code comments, or Github Markdown!
Stars: ✭ 416 (+153.66%)
Mutual labels:  markdown, ascii, table
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (+15.24%)
Mutual labels:  markdown, ascii
termtable
Simple and highly customizable library to display tables in the terminal.
Stars: ✭ 41 (-75%)
Mutual labels:  ascii, table
table
Produces a string that represents slice data in a text table, inspired by gajus/table.
Stars: ✭ 130 (-20.73%)
Mutual labels:  ascii, table
ctable
C library to print nicely formatted tables
Stars: ✭ 13 (-92.07%)
Mutual labels:  ascii, table
Terminaltables
Generate simple tables in terminals from a nested list of strings.
Stars: ✭ 685 (+317.68%)
Mutual labels:  ascii, table
outfancy
Python3 library to print tables in Terminal.
Stars: ✭ 47 (-71.34%)
Mutual labels:  ascii, table
Simpletable
Simple tables in terminal with Go
Stars: ✭ 288 (+75.61%)
Mutual labels:  ascii, table
Libfort
C/C++ library to create formatted ASCII tables for console applications
Stars: ✭ 255 (+55.49%)
Mutual labels:  ascii, table
Pytablewriter
pytablewriter is a Python library to write a table in various formats: CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
Stars: ✭ 422 (+157.32%)
Mutual labels:  markdown, table
Go Pretty
Pretty print tables and more in golang!
Stars: ✭ 777 (+373.78%)
Mutual labels:  ascii, table
Ink
A fast and flexible Markdown parser written in Swift.
Stars: ✭ 2,049 (+1149.39%)
Mutual labels:  markdown
Vscode Markdown
Markdown All in One
Stars: ✭ 2,113 (+1188.41%)
Mutual labels:  markdown
Rich Markdown Editor
The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
Stars: ✭ 2,468 (+1404.88%)
Mutual labels:  markdown
Html To Markdown
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.
Stars: ✭ 155 (-5.49%)
Mutual labels:  markdown
Tty Table
A flexible and intuitive table generator
Stars: ✭ 161 (-1.83%)
Mutual labels:  table
Window Table
Windowing Table for React based on React Window
Stars: ✭ 160 (-2.44%)
Mutual labels:  table
Ginrpc
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具
Stars: ✭ 157 (-4.27%)
Mutual labels:  markdown
Comfy Table
🔶 Build beautiful terminal tables with automatic content wrapping
Stars: ✭ 156 (-4.88%)
Mutual labels:  table
Feedparser
feedparser gem - (universal) web feed parser and normalizer (XML w/ Atom or RSS, JSON Feed, HTML w/ Microformats e.g. h-entry/h-feed or Feed.HTML, Feed.TXT w/ YAML, JSON or INI & Markdown, etc.)
Stars: ✭ 156 (-4.88%)
Mutual labels:  markdown

markdown-table

Build Coverage Downloads Size

Generate fancy Markdown tables.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install markdown-table

Use

Typical usage (defaults to align left):

import {markdownTable} from 'markdown-table'

markdownTable([
  ['Branch', 'Commit'],
  ['main', '0123456789abcdef'],
  ['staging', 'fedcba9876543210']
])

Yields:

| Branch  | Commit           |
| ------- | ---------------- |
| main    | 0123456789abcdef |
| staging | fedcba9876543210 |

With align:

markdownTable(
  [
    ['Beep', 'No.', 'Boop'],
    ['beep', '1024', 'xyz'],
    ['boop', '3388450', 'tuv'],
    ['foo', '10106', 'qrstuv'],
    ['bar', '45', 'lmno']
  ],
  {align: ['l', 'c', 'r']}
)

Yields:

| Beep |   No.   |   Boop |
| :--- | :-----: | -----: |
| beep |   1024  |    xyz |
| boop | 3388450 |    tuv |
| foo  |  10106  | qrstuv |
| bar  |    45   |   lmno |

API

This package exports the following identifiers: markdownTable. There is no default export.

markdownTable(table[, options])

Turns a given matrix of strings (an array of arrays of strings) into a table.

options
options.align

One style for all columns, or styles for their respective columns (string or string[]). Each style is either 'l' (left), 'r' (right), or 'c' (center). Other values are treated as '', which doesn’t place the colon in the alignment row but does align left. Only the lowercased first character is used, so Right is fine.

options.padding

Whether to add a space of padding between delimiters and cells (boolean, default: true).

When true, there is padding:

| Alpha | B     |
| ----- | ----- |
| C     | Delta |

When false, there is no padding:

|Alpha|B    |
|-----|-----|
|C    |Delta|
options.delimiterStart

Whether to begin each row with the delimiter (boolean, default: true).

Note: please don’t use this: it could create fragile structures that aren’t understandable to some Markdown parsers.

When true, there are starting delimiters:

| Alpha | B     |
| ----- | ----- |
| C     | Delta |

When false, there are no starting delimiters:

Alpha | B     |
----- | ----- |
C     | Delta |
options.delimiterEnd

Whether to end each row with the delimiter (boolean, default: true).

Note: please don’t use this: it could create fragile structures that aren’t understandable to some Markdown parsers.

When true, there are ending delimiters:

| Alpha | B     |
| ----- | ----- |
| C     | Delta |

When false, there are no ending delimiters:

| Alpha | B
| ----- | -----
| C     | Delta
options.alignDelimiters

Whether to align the delimiters (boolean, default: true). By default, they are aligned:

| Alpha | B     |
| ----- | ----- |
| C     | Delta |

Pass false to make them staggered:

| Alpha | B |
| - | - |
| C | Delta |
options.stringLength

Method to detect the length of a cell (Function, default: s => s.length).

Full-width characters and ANSI-sequences all mess up delimiter alignment when viewing the Markdown source. To fix this, you have to pass in a stringLength option to detect the “visible” length of a cell (note that what is and isn’t visible depends on your editor).

Without such a function, the following:

markdownTable([
  ['Alpha', 'Bravo'],
  ['中文', 'Charlie'],
  ['👩‍❤️‍👩', 'Delta']
])

Yields:

| Alpha | Bravo |
| - | - |
| 中文 | Charlie |
| 👩‍❤️‍👩 | Delta |

With string-width:

import stringWidth from 'string-width'

markdownTable(
  [
    ['Alpha', 'Bravo'],
    ['中文', 'Charlie'],
    ['👩‍❤️‍👩', 'Delta']
  ],
  {stringLength: width}
)

Yields:

| Alpha | Bravo   |
| ----- | ------- |
| 中文  | Charlie |
| 👩‍❤️‍👩    | Delta   |

Inspiration

The original idea and basic implementation was inspired by James Halliday’s text-table library.

License

MIT © Titus Wormer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].