Package Exports
- @thi.ng/markdown-table
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/markdown-table) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
This project is part of the @thi.ng/umbrella monorepo.
About
Markdown table formatter/generator with support for column alignments.
See related packages below for alternative solutions / approaches...
Status
STABLE - used in production
Search or submit any issues for this package
Related packages
- @thi.ng/hiccup-markdown - Markdown parser & serializer from/to Hiccup format
- @thi.ng/text-canvas - Text based canvas, drawing, tables with arbitrary formatting (incl. ANSI/HTML)
Installation
yarn add @thi.ng/markdown-table// ES module
<script type="module" src="https://unpkg.com/@thi.ng/markdown-table?module" crossorigin></script>
// UMD
<script src="https://unpkg.com/@thi.ng/markdown-table/lib/index.umd.js" crossorigin></script>Package sizes (gzipped, pre-treeshake): ESM: 536 bytes / CJS: 582 bytes / UMD: 688 bytes
Dependencies
API
import { table, tableKeys } from "@thi.ng/markdown-table";
table(
["ID", "Actor", "Comment"],
[
[1, "Alice"],
[201, "Bob", "(foe)"],
[3003, "Charlie", null],
[44, "Dora", "(recipient)"],
],
{ align: ["r", "c", "l"] }
);
// | **ID** | **Actor** | **Comment** |
// |-------:|:---------:|:------------|
// | 1 | Alice | |
// | 201 | Bob | (foe) |
// | 3003 | Charlie | |
// | 44 | Dora | (recipient) |
// ...alternatively, this produces the same:
tableKeys(
// column headers
["ID", "Actor", "Comment"],
// lookup keys
["id", "name", "hint"],
// rows as objects
[
{ id: 1, name: "Alice" },
{ id: 201, name: "Bob", hint: "(foe)" },
{ id: 3003, name: "Charlie" },
{ id: 44, name: "Dora", hint: "(recipient)" },
],
// table options
{ bold: true, align: ["r", "c", "l"] }
)Result as Markdown:
| ID | Actor | Comment |
|---|---|---|
| 1 | Alice | |
| 201 | Bob | (foe) |
| 3003 | Charlie | |
| 44 | Dora | (recipient) |
Authors
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-markdown-table,
title = "@thi.ng/markdown-table",
author = "Karsten Schmidt",
note = "https://thi.ng/markdown-table",
year = 2021
}License
© 2021 Karsten Schmidt // Apache Software License 2.0