Socket
Socket
Sign inDemoInstall

@lezer/xml

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lezer/xml

lezer-based XML grammar


Version published
Weekly downloads
225K
increased by6.1%
Maintainers
1
Weekly downloads
 
Created

What is @lezer/xml?

@lezer/xml is a parser for XML syntax built on the Lezer parser system. It provides tools to parse XML documents, create syntax trees, and perform syntax highlighting. This package is useful for applications that need to process or analyze XML data.

What are @lezer/xml's main functionalities?

Parsing XML

This feature allows you to parse an XML string and generate a syntax tree. The code sample demonstrates how to parse a simple XML string and print the resulting syntax tree.

const {parser} = require('@lezer/xml');
const input = '<root><child>Content</child></root>';
const tree = parser.parse(input);
console.log(tree.toString());

Syntax Highlighting

This feature allows you to perform syntax highlighting on an XML string. The code sample demonstrates how to parse an XML string and apply syntax highlighting using CodeMirror's highlighting utilities.

const {parser} = require('@lezer/xml');
const {highlightTree} = require('@codemirror/highlight');
const {defaultHighlighter} = require('@codemirror/highlight');
const input = '<root><child>Content</child></root>';
const tree = parser.parse(input);
let highlighted = '';
highlightTree(tree, defaultHighlighter, (from, to, classes) => {
  highlighted += input.slice(from, to);
  highlighted += ` [${classes}]`;
});
console.log(highlighted);

Other packages similar to @lezer/xml

FAQs

Package last updated on 04 Mar 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