Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-gfm-table

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-gfm-table

mdast extension to parse and serialize GFM tables

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8M
increased by2.27%
Maintainers
2
Weekly downloads
 
Created

What is mdast-util-gfm-table?

The mdast-util-gfm-table package is a utility to support GitHub Flavored Markdown (GFM) tables in mdast, which is a syntax tree format for Markdown. It allows users to parse and serialize tables in Markdown files following the GFM specification.

What are mdast-util-gfm-table's main functionalities?

Parsing GFM tables

This feature allows you to parse GFM tables from a Markdown string and convert them into an mdast syntax tree. The code sample demonstrates how to use the package in combination with 'mdast-util-from-markdown' to parse a simple table.

import { fromMarkdown } from 'mdast-util-from-markdown';
import { gfmTable } from 'mdast-util-gfm-table';

const markdown = '| Header 1 | Header 2 |\n| -------- | -------- |\n| Cell 1   | Cell 2   |';

const mdastTree = fromMarkdown(markdown, {
extensions: [gfmTable]
});

console.log(mdastTree);

Serializing GFM tables

This feature allows you to serialize an mdast syntax tree containing a GFM table back into a Markdown string. The code sample shows how to use the package with 'mdast-util-to-markdown' to serialize a simple mdast table structure.

import { toMarkdown } from 'mdast-util-to-markdown';
import { gfmTable } from 'mdast-util-gfm-table';

const mdastTree = {
type: 'table',
align: ['left', 'right'],
children: [
  {
type: 'tableRow',
children: [
    {type: 'tableCell', children: [{type: 'text', value: 'Header 1'}]},
    {type: 'tableCell', children: [{type: 'text', value: 'Header 2'}]}
  ]
},
  {
type: 'tableRow',
children: [
    {type: 'tableCell', children: [{type: 'text', value: 'Cell 1'}]},
    {type: 'tableCell', children: [{type: 'text', value: 'Cell 2'}]}
  ]
}
]
};

const markdown = toMarkdown(mdastTree, {
extensions: [gfmTable]
});

console.log(markdown);

Other packages similar to mdast-util-gfm-table

Keywords

FAQs

Package last updated on 10 Jul 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc