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

@lezer/markdown

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lezer/markdown

Incremental Markdown parser that consumes and emits Lezer trees

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
273K
increased by7.62%
Maintainers
1
Weekly downloads
 
Created

What is @lezer/markdown?

@lezer/markdown is a parser for Markdown that is part of the Lezer parser system. It is designed to be fast, modular, and customizable, making it suitable for use in editors and other applications that need to process Markdown text.

What are @lezer/markdown's main functionalities?

Parsing Markdown

This feature allows you to parse a string of Markdown text into a syntax tree. The code sample demonstrates how to parse a simple Markdown string and output the resulting syntax tree.

const {parser} = require('@lezer/markdown');
const input = '# Hello World\nThis is a paragraph.';
const tree = parser.parse(input);
console.log(tree.toString());

Customizing the Parser

This feature allows you to customize the Markdown parser by defining custom nodes and inline styles. The code sample shows how to create a custom parser and parse a string with custom nodes.

const {parser} = require('@lezer/markdown');
const {MarkdownParser} = require('@lezer/markdown');
const customParser = new MarkdownParser({
  defineNodes: [{name: 'CustomNode', style: 'custom-style'}],
  parseInline: [{name: 'CustomInline', style: 'custom-inline-style'}]
});
const input = 'This is a custom node.';
const tree = customParser.parse(input);
console.log(tree.toString());

Syntax Highlighting

This feature allows you to apply syntax highlighting to the parsed Markdown text. The code sample demonstrates how to highlight headings and paragraphs in the parsed syntax tree.

const {parser} = require('@lezer/markdown');
const {highlightTree} = require('@lezer/highlight');
const {styleTags, tags} = require('@lezer/highlight');
const input = '# Hello World\nThis is a paragraph.';
const tree = parser.parse(input);
const highlight = highlightTree(tree, styleTags({Heading: tags.heading, Paragraph: tags.content}));
console.log(highlight);

Other packages similar to @lezer/markdown

FAQs

Package last updated on 29 Oct 2024

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