Gathering detailed insights and metrics for markdown-table
Gathering detailed insights and metrics for markdown-table
Gathering detailed insights and metrics for markdown-table
Gathering detailed insights and metrics for markdown-table
npm install markdown-table
99.3
Supply Chain
99.5
Quality
79.4
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
270 Stars
148 Commits
24 Forks
7 Watching
1 Branches
5 Contributors
Updated on 15 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-21.9%
809,261
Compared to previous day
Last week
-2.4%
5,418,963
Compared to previous week
Last month
8.9%
22,802,189
Compared to previous month
Last year
50.3%
218,878,740
Compared to previous year
Generate a markdown (GFM) table.
This is a simple package that takes table data and generates a GitHub flavored markdown (GFM) table.
You can use this package when you want to generate the source code of a GFM table from some data.
This is a simple solution in that it doesn’t handle escapes or HTML or any of
that.
For a complete but heavier solution, build an AST and serialize it with
mdast-util-to-markdown
(with
mdast-util-gfm
).
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
1npm install markdown-table
In Deno with esm.sh
:
1import {markdownTable} from 'https://esm.sh/markdown-table@3'
In browsers with esm.sh
:
1<script type="module"> 2 import {markdownTable} from 'https://esm.sh/markdown-table@3?bundle' 3</script>
Typical usage (defaults to align left):
1import {markdownTable} from 'markdown-table' 2 3markdownTable([ 4 ['Branch', 'Commit'], 5 ['main', '0123456789abcdef'], 6 ['staging', 'fedcba9876543210'] 7])
Yields:
1| Branch | Commit | 2| ------- | ---------------- | 3| main | 0123456789abcdef | 4| staging | fedcba9876543210 |
With align:
1markdownTable( 2 [ 3 ['Beep', 'No.', 'Boop'], 4 ['beep', '1024', 'xyz'], 5 ['boop', '3388450', 'tuv'], 6 ['foo', '10106', 'qrstuv'], 7 ['bar', '45', 'lmno'] 8 ], 9 {align: ['l', 'c', 'r']} 10)
Yields:
1| Beep | No. | Boop | 2| :--- | :-----: | -----: | 3| beep | 1024 | xyz | 4| boop | 3388450 | tuv | 5| foo | 10106 | qrstuv | 6| bar | 45 | lmno |
This package exports the identifier markdownTable
.
There is no default export.
markdownTable(table[, options])
Generate a markdown table from table data (matrix of strings).
options
Configuration (optional).
options.align
One style for all columns, or styles for their respective columns (string
or
Array<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:
1| Alpha | B | 2| ----- | ----- | 3| C | Delta |
When false
, there is no padding:
1|Alpha|B | 2|-----|-----| 3|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:
1| Alpha | B | 2| ----- | ----- | 3| C | Delta |
When false
, there are no starting delimiters:
1Alpha | B | 2----- | ----- | 3C | 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:
1| Alpha | B | 2| ----- | ----- | 3| C | Delta |
When false
, there are no ending delimiters:
1| Alpha | B 2| ----- | ----- 3| C | Delta
options.alignDelimiters
Whether to align the delimiters (boolean
, default: true
).
By default, they are aligned:
1| Alpha | B | 2| ----- | ----- | 3| C | Delta |
Pass false
to make them staggered:
1| Alpha | B | 2| - | - | 3| C | Delta |
options.stringLength
Function to detect the length of table cell content (Function
, default:
s => s.length
).
This is used when aligning the delimiters (|
) between table cells.
Full-width characters and emoji mess up delimiter alignment when viewing the
markdown source.
To fix this, you can pass this function, which receives the cell content and
returns its “visible” size.
Note that what is and isn’t visible depends on where the text is displayed.
Without such a function, the following:
1markdownTable([ 2 ['Alpha', 'Bravo'], 3 ['中文', 'Charlie'], 4 ['👩❤️👩', 'Delta'] 5])
Yields:
1| Alpha | Bravo | 2| - | - | 3| 中文 | Charlie | 4| 👩❤️👩 | Delta |
With string-width
:
1import stringWidth from 'string-width' 2 3markdownTable( 4 [ 5 ['Alpha', 'Bravo'], 6 ['中文', 'Charlie'], 7 ['👩❤️👩', 'Delta'] 8 ], 9 {stringLength: stringWidth} 10)
Yields:
1| Alpha | Bravo | 2| ----- | ------- | 3| 中文 | Charlie | 4| 👩❤️👩 | Delta |
This package is fully typed with TypeScript.
It exports the additional type Options
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
This package is safe.
The original idea and basic implementation was inspired by James Halliday’s
text-table
library.
Yes please! See How to Contribute to Open Source.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More