# markdown-table-loader

> Given a markdown source representing a table, returns an array containing said table data.

Latest version **1.0.3** (published 2020-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdown-table-loader
pnpm add markdown-table-loader
yarn add markdown-table-loader
bun add markdown-table-loader
```

## 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.3 |
| Published | 2020-09-24 |
| First published | 2020-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 259.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Julien Verneaut |
| Maintainers | jverneaut |

## Links

- npm: https://www.npmjs.com/package/markdown-table-loader
- Repository: https://github.com/jverneaut/markdown-table-loader
- Homepage: https://github.com/jverneaut/markdown-table-loader#readme
- Issues: https://github.com/jverneaut/markdown-table-loader/issues
- npm.io page: https://npm.io/package/markdown-table-loader

## Recent versions

- 1.0.3 (latest) — 2020-09-24
- 1.0.2 — 2020-09-24
- 1.0.1 — 2020-09-24
- 1.0.0 — 2020-09-24

## README

# markdown-table-loader

Given a markdown source representing a table, returns an array containing said table data.

## Setup

```bash
npm install markdown-table-loader
```

```javascript
// webpack.config.js
module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.table\.md$/,
        use: 'markdown-table-loader',
      },
    ],
  },
  // ...
};
```

```markdown
<!-- data.table.md -->

| foo | bar |
| --- | --- |
| baz | bim |
```

```javascript
// index.js
import table from './data.table.md';

console.log(table);
// [
//   {
//     foo: 'baz',
//     bar: 'bim',
//   },
// ]
```

## Examples

Implementing specifications from [github.com Tables](https://github.github.com/gfm/#tables-extension-).

```javascript
// test/fixtures/tables.md.js
const table1 = {
  value: `
| foo | bar |
| --- | --- |
| baz | bim |
`,
  expected: [
    {
      foo: 'baz',
      bar: 'bim',
    },
  ],
};

const table2 = {
  value: `
| abc | defghi |
:-: | -----------:
bar | baz
`,
  expected: [
    {
      abc: 'bar',
      defghi: 'baz',
    },
  ],
};

const table3 = {
  value: `
| f|oo  |
| ------ |
| b|az |
| b|im |
`,
  expected: [
    {
      'f|oo': 'b|az',
    },
    {
      'f|oo': 'b|im',
    },
  ],
};

const table4 = {
  value: `
| abc | def |
| --- | --- |
| bar | baz |
> bar
`,
  expected: [
    {
      abc: 'bar',
      def: 'baz',
    },
  ],
};

const table5 = {
  value: `
| abc | def |
| --- | --- |
| bar | baz |
bar

bar
`,
  expected: [
    {
      abc: 'bar',
      def: 'baz',
    },
    {
      abc: 'bar',
      def: null,
    },
  ],
};

const table6 = {
  value: `
| abc | def |
| --- |
| bar |
`,
  expected: [],
};

const table7 = {
  value: `
| abc | def |
| --- | --- |
| bar |
| bar | baz | boo |
`,
  expected: [
    {
      abc: 'bar',
      def: null,
    },
    {
      abc: 'bar',
      def: 'baz',
    },
  ],
};
```

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