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

@codemirror/lang-markdown

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-markdown

Markdown language support for the CodeMirror code editor

  • 6.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @codemirror/lang-markdown?

@codemirror/lang-markdown is a language support package for CodeMirror 6 that provides syntax highlighting, parsing, and other language features for Markdown. It allows developers to integrate Markdown editing capabilities into their CodeMirror-based editors.

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

Syntax Highlighting

This feature provides syntax highlighting for Markdown content. The code sample demonstrates how to set up a CodeMirror editor with Markdown syntax highlighting.

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

const state = EditorState.create({
  doc: '# Hello, Markdown!',
  extensions: [basicSetup, markdown()]
});

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

Markdown Parsing

This feature allows for parsing Markdown content within the editor. The code sample shows how to set up the editor and access the parsed Markdown document.

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

const state = EditorState.create({
  doc: '# Hello, Markdown!',
  extensions: [basicSetup, markdown()]
});

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

// Accessing the parsed Markdown document
const parsedDoc = state.doc.toString();
console.log(parsedDoc);

Custom Markdown Extensions

This feature allows for the creation of custom Markdown extensions. The code sample demonstrates how to configure and use a custom Markdown language extension in the CodeMirror editor.

import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from 'codemirror';
import { LRLanguage, LanguageSupport } from '@codemirror/language';

const customMarkdown = markdownLanguage.configure({
  defineNodes: [{ name: 'CustomNode', style: 'custom-style' }],
  parseInline: [{ name: 'CustomInline', style: 'custom-inline-style' }]
});

const state = EditorState.create({
  doc: '# Hello, Custom Markdown!',
  extensions: [basicSetup, markdown({ base: customMarkdown })]
});

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

Other packages similar to @codemirror/lang-markdown

Keywords

FAQs

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