# markdown-it-pivot-table

> A markdown-it plugin to add pivot table support

Latest version **1.0.5** (published 2023-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdown-it-pivot-table
pnpm add markdown-it-pivot-table
yarn add markdown-it-pivot-table
bun add markdown-it-pivot-table
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-08-16 |
| First published | 2023-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | jaeseopark |
| Keywords | markdown-it, markdown-it-plugin |

## Links

- npm: https://www.npmjs.com/package/markdown-it-pivot-table
- Homepage: https://github.com/jaeseopark/markdown-it-pivot-table
- Issues: https://github.com/jaeseopark/markdown-it-pivot-table/issues
- npm.io page: https://npm.io/package/markdown-it-pivot-table

## Dependencies (3)

- [group-by](https://npm.io/package/group-by.md) ^0.0.1
- [nd-table](https://npm.io/package/nd-table.md) ^1.2.2
- [string-math](https://npm.io/package/string-math.md) ^1.2.2

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2023-08-16
- 1.0.4 — 2023-08-15
- 1.0.2 — 2023-08-15
- 1.0.1 — 2023-07-25
- 1.0.0 — 2023-07-15

## README

# markdown-it-pivot-table

A markdown-it plugin to add pivot table support.

## Operators

`CNT()`, `MIN()`, `MAX()`, `SUM()`, and `AVG()` work with numeric values.

`ANY()` works with strings.

## Usage

```js
const mdp = require('markdown-it-pivot-table');
const md = require('markdown-it')().use(mdp);

const source = `
|Group=Item|Cost=SUM()|
|---|---|
|Candies|1.00|
|Chips|3.00|
|Candies|1.00|
|Drinks|2.00|
`;

const result = md.render(source);
console.log(result);
```

Result:

|Item|Cost|
|---|---|
| Candies | 2.00 | 
| Chips   | 3.00 | 
| Drinks  | 2.00 | 

### Computed Cells

Reference column names with curly braces to compute numeric values on the fly:

```
|Group=Category|Group=Sub-category|Item|Unit Cost|Qty|Subtotal=SUM()|
|---|---|---|---|---|---|
|Electrical|Wires|14/2 (/m)|||150|
|Electrical|Wires|10/3 (/m)|||99.80|
|Electrical|Devices|Breakers|29.97|3|{Unit Cost}*{Qty}|
```

Result:

| Category   | Sub-category | Subtotal | 
|------------|--------------|----------| 
| Electrical | Wires        | 249.80   | 
| Electrical | Devices      | 89.91    | 

### In-header Equations

If all rows have the same value for a column, then specify the equation right in the header line and leave the cells blank:

```
|Group=Category|Group=Sub-category|Item|Unit Cost|Qty|Subtotal=SUM({Unit Cost}*{Qty})|
|---|---|---|---|---|---|
|Wall|Drywall|1/2" (/sheet)|17.35|25|
|Wall|Mud|Quickset|15|2|
|Wall|Mud|All Purpose|35|3|
```

Result:

| Category | Sub-category | Subtotal | 
|----------|--------------|----------| 
| Wall     | Drywall      | 433.75   | 
| Wall     | Mud          | 135.00   |

---
_Source: https://npm.io/package/markdown-it-pivot-table · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
