.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / markdown-table / readme.md
1 # markdown-table
2
3 [![Build][build-badge]][build]
4 [![Coverage][coverage-badge]][coverage]
5 [![Downloads][downloads-badge]][downloads]
6 [![Size][size-badge]][size]
7
8 Generate fancy [Markdown][fancy]/ASCII tables.
9
10 ## Installation
11
12 [npm][]:
13
14 ```bash
15 npm install markdown-table
16 ```
17
18 ## Usage
19
20 Normal usage (defaults to left-alignment):
21
22 ```javascript
23 var table = require('markdown-table')
24
25 table([
26   ['Branch', 'Commit'],
27   ['master', '0123456789abcdef'],
28   ['staging', 'fedcba9876543210']
29 ])
30 ```
31
32 Yields:
33
34 ```markdown
35 | Branch  | Commit           |
36 | ------- | ---------------- |
37 | master  | 0123456789abcdef |
38 | staging | fedcba9876543210 |
39 ```
40
41 With alignment:
42
43 ```javascript
44 table(
45   [
46     ['Beep', 'No.', 'Boop'],
47     ['beep', '1024', 'xyz'],
48     ['boop', '3388450', 'tuv'],
49     ['foo', '10106', 'qrstuv'],
50     ['bar', '45', 'lmno']
51   ],
52   {
53     align: ['l', 'c', 'r']
54   }
55 )
56 ```
57
58 Yields:
59
60 ```markdown
61 | Beep |   No.   |   Boop |
62 | :--- | :-----: | -----: |
63 | beep |   1024  |    xyz |
64 | boop | 3388450 |    tuv |
65 | foo  |  10106  | qrstuv |
66 | bar  |    45   |   lmno |
67 ```
68
69 Alignment on dots:
70
71 ```javascript
72 table([['No.'], ['0.1.2'], ['11.22.33'], ['5.6.'], ['1.22222']], {
73   align: '.'
74 })
75 ```
76
77 Yields:
78
79 ```markdown
80 |    No.      |
81 | :---------: |
82 |   0.1.2     |
83 | 11.22.33    |
84 |   5.6.      |
85 |     1.22222 |
86 ```
87
88 ## API
89
90 ### `markdownTable(table[, options])`
91
92 Turns a given matrix of strings (an array of arrays of strings) into a table.
93
94 ##### `options`
95
96 ###### `options.align`
97
98 One style for all columns, or styles for their respective columns (`string` or
99 `Array.<string>`).  Each style is either `'l'` (left), `'r'` (right), `'c'`
100 (centre), or `'.'` (dot).  Other values are treated as `''`, which doesn’t place
101 the colon but does left align.  _Only the lowercased first character is used,
102 so `Right` is fine._
103
104 ###### `options.delimiter`
105
106 Value to insert between cells (`string`, default: `' | '`).  Careful, setting
107 this to a non-pipe breaks GitHub Flavoured Markdown.
108
109 ###### `options.start`
110
111 Value to insert at the beginning of every row (`string`, default: `'| '`).
112
113 ###### `options.end`
114
115 Value to insert at the end of every row (`string`, default: `' |'`).
116
117 ###### `options.rule`
118
119 Whether to display a rule between the header and the body of the table
120 (`boolean`, default: `true`).  Careful, will break GitHub Flavoured Markdown
121 when `false`.
122
123 ###### `options.stringLength`
124
125 Method to detect the length of a cell (`Function`, default: `s => s.length`).
126
127 ANSI-sequences mess up tables on terminals.  To fix this, you have to
128 pass in a `stringLength` option to detect the “visible” length of a
129 cell.
130
131 ```javascript
132 var strip = require('strip-ansi')
133
134 function stringLength(cell) {
135   return strip(cell).length
136 }
137 ```
138
139 ###### `options.pad`
140
141 Whether to pad the markdown for table cells to make them the same width
142 (`boolean`, default: `true`).  Setting this to false will cause the table
143 rows to remain staggered.
144
145 ## Inspiration
146
147 The original idea and basic implementation was inspired by James
148 Halliday’s [text-table][] library.
149
150 ## License
151
152 [MIT][license] © [Titus Wormer][author]
153
154 <!-- Definitions -->
155
156 [build-badge]: https://img.shields.io/travis/wooorm/markdown-table.svg
157
158 [build]: https://travis-ci.org/wooorm/markdown-table
159
160 [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/markdown-table.svg
161
162 [coverage]: https://codecov.io/github/wooorm/markdown-table
163
164 [downloads-badge]: https://img.shields.io/npm/dm/markdown-table.svg
165
166 [downloads]: https://www.npmjs.com/package/markdown-table
167
168 [size-badge]: https://img.shields.io/bundlephobia/minzip/markdown-table.svg
169
170 [size]: https://bundlephobia.com/result?p=markdown-table
171
172 [npm]: https://docs.npmjs.com/cli/install
173
174 [license]: license
175
176 [author]: https://wooorm.com
177
178 [fancy]: https://help.github.com/articles/github-flavored-markdown/#tables
179
180 [text-table]: https://github.com/substack/text-table