Socket
Socket
Sign inDemoInstall

mdast-util-to-markdown

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-to-markdown

mdast utility to serialize markdown


Version published
Weekly downloads
6.5M
decreased by-2.38%
Maintainers
2
Weekly downloads
 
Created

What is mdast-util-to-markdown?

The mdast-util-to-markdown package is a utility to serialize Markdown Abstract Syntax Tree (MDAST) nodes to markdown text. It is part of the unified ecosystem and is typically used to convert MDAST, which is an abstract representation of markdown documents, back into markdown format.

What are mdast-util-to-markdown's main functionalities?

Serialize MDAST to Markdown

Converts an MDAST node into a markdown string. This is the core functionality of the package.

const toMarkdown = require('mdast-util-to-markdown');
const mdast = {
  type: 'paragraph',
  children: [{ type: 'text', value: 'Hello, world!' }]
};
const markdown = toMarkdown(mdast);
console.log(markdown); // Outputs: 'Hello, world!'

Customize Handlers

Allows the user to define custom handlers for different types of MDAST nodes, enabling serialization of custom or extended MDAST nodes.

const toMarkdown = require('mdast-util-to-markdown');
const mdast = {
  type: 'customNode',
  value: 'This is custom'
};
const handlers = {
  customNode(node) {
    return `Custom: ${node.value}`;
  }
};
const markdown = toMarkdown(mdast, { handlers });
console.log(markdown); // Outputs: 'Custom: This is custom'

Extensions

Supports extensions to handle syntax from GitHub Flavored Markdown (GFM) and other markdown variants.

const toMarkdown = require('mdast-util-to-markdown');
const gfm = require('mdast-util-gfm');
const mdast = {
  type: 'paragraph',
  children: [{ type: 'text', value: 'Hello, world!' }]
};
const markdown = toMarkdown(mdast, { extensions: [gfm.toMarkdown] });
console.log(markdown); // Outputs: 'Hello, world!' with GFM-specific serialization

Other packages similar to mdast-util-to-markdown

Keywords

FAQs

Package last updated on 05 Feb 2021

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