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

@codemirror/lang-python

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-python

Python language support for the CodeMirror code editor

  • 6.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @codemirror/lang-python?

@codemirror/lang-python is a language support package for CodeMirror 6 that provides syntax highlighting, code folding, and other language-specific features for Python.

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

Syntax Highlighting

This code sets up a CodeMirror editor with Python syntax highlighting. The `python` function from `@codemirror/lang-python` is used as an extension in the editor state.

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

const state = EditorState.create({
  doc: 'print("Hello, World!")',
  extensions: [basicSetup, python()]
});

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

Code Folding

This code sets up a CodeMirror editor with Python syntax highlighting and code folding. The `foldGutter` extension is used to enable code folding in the editor.

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

const state = EditorState.create({
  doc: 'def foo():\n    print("Hello, World!")\n\nfoo()',
  extensions: [basicSetup, python(), foldGutter()]
});

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

Autocomplete

This code sets up a CodeMirror editor with Python syntax highlighting and autocomplete functionality. The `autocompletion` extension is used to provide autocomplete suggestions.

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

const state = EditorState.create({
  doc: 'pri',
  extensions: [basicSetup, python(), autocompletion()]
});

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

Other packages similar to @codemirror/lang-python

Keywords

FAQs

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