Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@codemirror/lang-yaml
Advanced tools
@codemirror/lang-yaml is a language support package for CodeMirror 6 that provides syntax highlighting, parsing, and other language-specific features for YAML files.
Syntax Highlighting
This code sets up a CodeMirror editor with YAML syntax highlighting. The `yaml` function from `@codemirror/lang-yaml` is used as an extension in the editor state.
import { yaml } from '@codemirror/lang-yaml';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'key: value\nlist:\n - item1\n - item2',
extensions: [basicSetup, yaml()]
});
const view = new EditorView({
state,
parent: document.body
});
Parsing
This code demonstrates how to parse a YAML document using the `@codemirror/lang-yaml` package. The `syntaxTree` function is used to get the syntax tree of the document.
import { yaml } from '@codemirror/lang-yaml';
import { syntaxTree } from '@codemirror/language';
import { EditorState } from '@codemirror/state';
const state = EditorState.create({
doc: 'key: value\nlist:\n - item1\n - item2',
extensions: [yaml()]
});
const tree = syntaxTree(state);
console.log(tree);
yaml-language-server is a language server for YAML that provides features like validation, autocompletion, and hover information. It is more focused on providing language server protocol (LSP) support for editors like VSCode, whereas @codemirror/lang-yaml is specifically for CodeMirror.
js-yaml is a JavaScript library for parsing and dumping YAML. It is not an editor-specific package but can be used in conjunction with various editors to provide YAML parsing and serialization capabilities. Unlike @codemirror/lang-yaml, it does not provide syntax highlighting or editor integration out of the box.
yaml is another JavaScript library for parsing and stringifying YAML. Similar to js-yaml, it focuses on YAML data manipulation rather than editor-specific features like syntax highlighting. It can be used alongside editor packages to provide YAML support.
[ WEBSITE | ISSUES | FORUM | CHANGELOG ]
This package implements YAML language support for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
The initial implementation of this package was funded by Braintrust Data.
yaml() → LanguageSupport
Language support for YAML.
yamlLanguage: LRLanguage
A language provider based on the Lezer YAML parser, extended with highlighting and indentation information.
yamlFrontmatter(config: {content: Language | LanguageSupport}) → LanguageSupport
Returns language support for a document parsed as config.content
with an optional YAML "frontmatter" delimited by lines that
contain three dashes.
6.1.1 (2024-04-12)
Make block mapping entries, rather than the entire mapping, foldable.
FAQs
YAML language support for the CodeMirror code editor
The npm package @codemirror/lang-yaml receives a total of 108,578 weekly downloads. As such, @codemirror/lang-yaml popularity was classified as popular.
We found that @codemirror/lang-yaml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.