Socket
Socket
Sign inDemoInstall

mdast-util-gfm-footnote

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-gfm-footnote

mdast extension to parse and serialize GFM footnotes


Version published
Weekly downloads
2.3M
decreased by-19%
Maintainers
1
Weekly downloads
 
Created

What is mdast-util-gfm-footnote?

The mdast-util-gfm-footnote npm package is a utility to support GitHub Flavored Markdown (GFM) footnotes in mdast, which is a Markdown Abstract Syntax Tree format. It allows for parsing and serializing footnote syntax as specified in GFM, making it easier to handle footnotes in Markdown files programmatically.

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

Parsing GFM footnotes

This feature allows the parsing of GFM footnotes in Markdown text. The code sample demonstrates how to set up a processor with unified, using the remark-parse and remark-gfm plugins along with mdast-util-gfm-footnote to parse a Markdown string containing a footnote.

import { unified } from 'unified';
import markdown from 'remark-parse';
import gfm from 'remark-gfm';
import gfmFootnote from 'mdast-util-gfm-footnote';

const processor = unified()
  .use(markdown)
  .use(gfm)
  .use(gfmFootnote);

const ast = processor.parse('[^1]: This is a footnote.');
console.log(ast);

Serializing GFM footnotes

This feature supports the serialization of GFM footnotes back into Markdown format. The code sample shows how to configure a unified processor to convert an AST with a footnote definition back into a Markdown string.

import { unified } from 'unified';
import markdown from 'remark-parse';
import gfm from 'remark-gfm';
import gfmFootnote from 'mdast-util-gfm-footnote';
import stringify from 'remark-stringify';

const processor = unified()
  .use(markdown)
  .use(gfm)
  .use(gfmFootnote)
  .use(stringify);

const ast = { type: 'footnoteDefinition', identifier: '1', children: [{ type: 'paragraph', children: [{ type: 'text', value: 'This is a footnote.' }] }] };
const markdownText = processor.stringify(ast);
console.log(markdownText);

Other packages similar to mdast-util-gfm-footnote

Keywords

FAQs

Package last updated on 03 Oct 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