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

@codemirror/lang-xml

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-xml

XML language support for the CodeMirror code editor

  • 6.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @codemirror/lang-xml?

@codemirror/lang-xml is a language support package for CodeMirror 6 that provides syntax highlighting, parsing, and other language-related features for XML. It is designed to be used with the CodeMirror 6 editor to enhance the editing experience for XML documents.

What are @codemirror/lang-xml's main functionalities?

Syntax Highlighting

This code sets up a CodeMirror editor with XML syntax highlighting. The `xml` function from `@codemirror/lang-xml` is used as an extension to provide the necessary syntax highlighting for XML content.

import { xml } from '@codemirror/lang-xml';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: '<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>',
  extensions: [basicSetup, xml()]
});

const view = new EditorView({
  state,
  parent: document.body
});

XML Parsing

This code demonstrates how to parse an XML document using the `@codemirror/lang-xml` package. The `syntaxTree` function is used to get the syntax tree of the XML document, which can be used for further analysis or manipulation.

import { xml } from '@codemirror/lang-xml';
import { syntaxTree } from '@codemirror/language';
import { EditorState } from '@codemirror/state';

const state = EditorState.create({
  doc: '<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>',
  extensions: [xml()]
});

const tree = syntaxTree(state);
console.log(tree);

Other packages similar to @codemirror/lang-xml

Keywords

FAQs

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