Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nicktomlin/codemirror-lang-yaml-lite

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nicktomlin/codemirror-lang-yaml-lite

Lightweight YAML support for CodeMirror 6

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Codemirror YAML Lite

This package provides CodeMirror language support for a partial version of the YAML 1.2 spec, and also contains the Lezer grammar that powers it.

Usage

In your project:

npm i @nicktomlin/codemirror-lang-yaml-lite
import {yaml} from "@nicktomlin/codemirror-lang-yaml-lite"

// TODO:... more here
new EditorView({
    extensions: [
        yaml
    ]
})

Contributing

Pull requests welcome; feature requests are DIY

I'll try to do what I can to fix bugs, but I'm satisfied with a subset of YAML behavior at the moment. If you'd like the parser augmented for your use case, please open a PR.

Development

Working with the parser:

# launch tests and parser in --watch mode
npm run dev

# run the UI (useful for previewing changes in CodeMirror)
npm run ui

FAQ

Why lite?

YAML is a notoriously complicated (or -- to put a positive spin on it -- flexible) data serialization language. As such, it's difficult to parse.

Why not use CM legacy-modes?

CodeMirror 6 supports basic yaml syntax highlighting through legacy streaming mode and you should use it if your use case is simple! But, it is not fully compatible with all of the features a "real" lezer parser provides. For example, that means it is not able to support mixed language parsing which prompted this package's development.

Prior art / References

Right now I think we sort of need a full loop that helps us generate the grammar and then preview in the editor all at once...

Playgrounds

FAQs

Package last updated on 02 Sep 2023

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