npm package: @imtheaman/lang-yaml
Description: Enhanced YAML language support for CodeMirror with Boolean, Null, and Number type recognition
Author: Aman Kumar
Latest version: 1.0.0

<!-- NOTE: README.md is generated from src/README.md -->

# @imtheaman/lang-yaml [![NPM version](https://img.shields.io/npm/v/@imtheaman/lang-yaml.svg)](https://www.npmjs.org/package/@imtheaman/lang-yaml)

[ [**ISSUES**](https://github.com/imtheaman/lang-yaml/issues) | [**CHANGELOG**](https://github.com/imtheaman/lang-yaml/blob/main/CHANGELOG.md) ]

This package implements enhanced YAML language support for the
[CodeMirror](https://codemirror.net/) code editor with proper recognition of Boolean, Null, and Number types.

## Features

This enhanced version provides:

- **Boolean type recognition**: Properly highlights `true`, `false`, `yes`, `no`, `on`, `off` (in various cases)
- **Null type recognition**: Properly highlights `null`, `~`, `nil` (in various cases)
- **Number type recognition**: Properly highlights:
  - Integers: `42`, `-17`
  - Hexadecimal: `0x2A`
  - Octal: `0o52`
  - Binary: `0b101010`
  - Floating point: `3.14`, `-2.5`, `.5`, `10.`
  - Scientific notation: `6.022e23`, `-1.5e-10`
  - Special float values: `.inf`, `-.inf`, `+.inf`, `.nan` (and uppercase variants)
  - Base 60 (time values): `1:30`, `12:30:45`, `1:30:45.5`

This package is based on the original [@codemirror/lang-yaml](https://github.com/codemirror/lang-yaml) and uses the enhanced [@imtheaman/yaml](https://www.npmjs.org/package/@imtheaman/yaml) parser.

This code is released under an
[MIT license](https://github.com/imtheaman/lang-yaml/tree/main/LICENSE).

## Usage

```javascript
import {EditorView, basicSetup} from "codemirror"
import {yaml} from "@imtheaman/lang-yaml"

const view = new EditorView({
  parent: document.body,
  doc: `name: Ferdinand
age: 93
active: true
score: null
rate: 3.14`,
  extensions: [basicSetup, yaml()]
})
```

## API Reference

<dl>
<dt id="user-content-yaml">
  <code><strong><a href="#user-content-yaml">yaml</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>

<dd><p>Language support for YAML.</p>
</dd>
<dt id="user-content-yamllanguage">
  <code><strong><a href="#user-content-yamllanguage">yamlLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>

<dd><p>A language provider based on the enhanced <a href="https://github.com/imtheaman/yaml">@imtheaman/yaml
parser</a>, extended with
highlighting and indentation information.</p>
</dd>
<dt id="user-content-yamlfrontmatter">
  <code><strong><a href="#user-content-yamlfrontmatter">yamlFrontmatter</a></strong>(<a id="user-content-yamlfrontmatter^config" href="#user-content-yamlfrontmatter^config">config</a>: {content: <a href="https://codemirror.net/docs/ref#language.Language">Language</a> | <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a>) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>

<dd><p>Returns language support for a document parsed as <code>config.content</code>
with an optional YAML &quot;frontmatter&quot; delimited by lines that
contain three dashes.</p>
</dd>
</dl>