Socket
Socket
Sign inDemoInstall

markdown-tables-to-json

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    markdown-tables-to-json

Extracts tables from Markdown documents and converts to JSON objects.


Version published
Weekly downloads
1.1K
decreased by-13.82%
Maintainers
1
Install size
36.0 MB
Created
Weekly downloads
 

Readme

Source

markdown-tables-to-json

This is a module for extracting tables from Markdown documents and converting them to string arrays or JSON objects.

Example

The following code snippet demonstrates the basic usage of the module and the difference between 'rows' and 'columns' modes. Take a look at src/index.ts for additional static methods available.

Code

// import the table extractor
var { Extractor } = require('markdown-tables-to-json');

// markdown string with a row-oriented table
var md_rows = `
| name     | head  | body  | tail  | paws  |
|----------|-------|-------|-------|-------|
| mittens  | black | black | black | white |
| dipstick | white | white | black | white |
| snow     | white | white | white | white |
`

// markdown string with a column-oriented table
var md_cols = `
| name | mittens | dipstick | snow  |
|------|---------|----------|-------|
| head | black   | white    | white |
| body | black   | white    | white |
| tail | black   | black    | white |
| paws | white   | white    | white |
`

console.log(Extractor.extractObject(md_rows));
console.log(Extractor.extractObject(md_cols, 'columns'));

Output

{
  mittens: { head: 'black', body: 'black', tail: 'black', paws: 'white' },
  dipstick: { head: 'white', body: 'white', tail: 'black', paws: 'white' },
  snow: { head: 'white', body: 'white', tail: 'white', paws: 'white' }
}
{
  mittens: { head: 'black', body: 'black', tail: 'black', paws: 'white' },
  dipstick: { head: 'white', body: 'white', tail: 'black', paws: 'white' },
  snow: { head: 'white', body: 'white', tail: 'white', paws: 'white' }
}

Keywords

FAQs

Last updated on 31 Dec 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc