# @markuplint/ml-spec

> Types and schema that specs of the Markup languages for markuplint

Latest version **5.3.0** (published 2026-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @markuplint/ml-spec
pnpm add @markuplint/ml-spec
yarn add @markuplint/ml-spec
bun add @markuplint/ml-spec
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.3.0 |
| Published | 2026-10-21 |
| First published | 2019-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 4 |
| Unpacked size | 282.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 623 |
| Author | Yusuke Hirao |
| Maintainers | yusukehirao |

## Links

- npm: https://www.npmjs.com/package/@markuplint/ml-spec
- Repository: https://github.com/markuplint/markuplint
- Homepage: https://github.com/markuplint/markuplint#readme
- Issues: https://github.com/markuplint/markuplint/issues
- npm.io page: https://npm.io/package/@markuplint/ml-spec

## Dependencies (4)

- [type-fest](https://npm.io/package/type-fest.md) ^5.10.0
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^5.1.0
- [@markuplint/types](https://npm.io/package/@markuplint/types.md) 5.3.0
- [@markuplint/ml-ast](https://npm.io/package/@markuplint/ml-ast.md) 5.3.0

## Recent versions

- 5.3.0 (latest) — 2026-10-21
- 5.0.0-rc.7 (rc) — 2026-08-31
- 5.0.0-rc.1 (next) — 2026-03-27
- 5.0.0-dev.5 (canary) — 2026-02-27
- 3.0.0-alpha.27 (dev) — 2022-12-20
- 5.2.0 — 2026-10-13
- 5.1.1 — 2026-10-09
- 5.1.0 — 2026-10-08
- 5.0.1 — 2026-09-22
- 5.0.0 — 2026-09-11
- 5.0.0-rc.6 — 2026-08-30
- 5.0.0-rc.5 — 2026-08-29
- 4.18.0 — 2026-04-22
- 5.0.0-rc.4 — 2026-04-19
- 5.0.0-rc.2 — 2026-04-15
- … 160 more at https://npm.io/package/@markuplint/ml-spec/versions

## README

# @markuplint/ml-spec

[![npm version](https://badge.fury.io/js/%40markuplint%2Fml-spec.svg)](https://www.npmjs.com/package/@markuplint/ml-spec)

**Foundation package providing type definitions, W3C specification algorithms, and unified API for markup language specifications.**

This package serves as the foundational layer for markuplint's specification system, providing:

- **Type definitions** for markup language specifications (HTML, ARIA, SVG, MathML)
- **W3C specification algorithms** (HTML Standard, WAI-ARIA 1.1/1.2/1.3 compliance)
- **JSON schemas** that define the structure of element specifications
- **Runtime utilities** for specification resolution, attribute validation, and content model checking
- **Unified API** for consuming specification data from various sources

The canonical HTML element specification data is provided by `@markuplint/html-spec`, which depends on this package for type definitions and algorithmic processing.

## Package Architecture

This package serves as the foundation layer in markuplint's specification system:

```
@markuplint/ml-spec (Foundation Layer)
  ↓ provides types, algorithms, schemas
@markuplint/html-spec (Data Layer)
  ↓ provides HTML specification data
Framework-specific specs (Extension Layer)
  ↓ provide framework extensions
Core packages (Application Layer)
  ↓ consume specifications for validation
```

## Package Contents

### Type Definitions

- **Core Types**: `ElementSpec`, `ExtendedSpec`, `MLMLSpec`, `ARIAVersion`
- **ARIA Types**: Complete WAI-ARIA 1.1/1.2/1.3 type definitions
- **Attribute Types**: HTML attribute definitions with validation rules
- **Content Model Types**: Permitted content structure definitions

Generated TypeScript types (do not edit directly):

- `src/types/attributes.ts` - Attribute specification types
- `src/types/aria.ts` - ARIA specification types
- `src/types/permitted-structures.ts` - Content model types

### W3C Specification Algorithms

**HTML Standard Algorithms**:

- Focusable Area Algorithm (`src/algorithm/html/may-be-focusable.ts`)
- Interactive Content classification
- Content Model validation (`src/algorithm/html/get-content-model.ts`)

**WAI-ARIA Specification Algorithms**:

- **Accessible Name Computation** - W3C AccName 1.2 / HTML-AAM §4.1 compliant (`src/algorithm/aria/accname/`)
- **Role Computation** - Explicit/implicit role resolution with conflict handling (`src/algorithm/aria/get-computed-role.ts`)
- **Accessibility Tree Computation** - Element inclusion/exclusion logic (`src/algorithm/aria/is-exposed.ts`)
- **ARIA Property Computation** - Attribute value resolution with HTML equivalents (`src/algorithm/aria/get-computed-aria-props.ts`)
- **Required Context Validation** - Composite role validation (`src/algorithm/aria/has-required-owned-elements.ts`)

**Specification Integration**:

- Cross-specification utilities (`src/utils/get-spec-by-tag-name.ts`)
- Version-aware specification resolution (`src/utils/resolve-version.ts`)
- Schema-to-runtime conversion (`src/utils/schema-to-spec.ts`)

### JSON Schemas (Structure Definitions)

- `schemas/element.schema.json` - Element specification schema
- `schemas/aria.schema.json` - ARIA specification schema
- `schemas/content-models.schema.json` - Content model schema
- `schemas/global-attributes.schema.json` (generated) - Global attribute categories
- `schemas/attributes.schema.json` (generated) - Attribute definition schema

### Schema Generators

- `gen/gen.ts` - Builds generated schema files from data
- `gen/global-attribute.data.*` - Source data for global attribute categories

### Runtime Utilities

- **Spec Resolution**: `getSpecByTagName`, `getAttrSpecs`, `getRoleSpec`
- **Content Model Utilities**: `getContentModel`, `isPalpableElements`, `isVoidElement`
- **ARIA Utilities**: `getAria`, `getPermittedRoles`, `hasRequiredOwnedElements`
- **Accessibility Utilities**: `getAccname`, `isExposed`, `mayBeFocusable`
- **Schema Utilities**: `schemaToSpec`, `resolveNamespace`, `validateAriaVersion`
- **Framework Extension**: Merges base HTML specs with framework-specific extensions

**Note**: Attribute value types are defined in `@markuplint/types`. The schemas here reference `@markuplint/types/types.schema.json`.

## Relationship to @markuplint/html-spec

**@markuplint/html-spec** provides the canonical HTML element specification data:

- **Built output**: `index.json` (48K+ lines, consolidated specification data)
- **Sources**: `src/spec-*.json` (individual element specifications)
- **Build process**: `build.ts` → `generator/` scripts → enriched with MDN/W3C data

**@markuplint/ml-spec** (this package) provides:

- **Type definitions** that `@markuplint/html-spec` uses to structure its data
- **JSON schemas** that validate the specification format
- **Algorithms** that process and compute values from the specification data
- **Runtime utilities** that consume the consolidated specification data

This separation enables:

- **Data updates** (`@markuplint/html-spec`) without affecting type definitions
- **Algorithm improvements** (`@markuplint/ml-spec`) without regenerating data
- **Framework extensions** that can reuse both type definitions and base HTML data

### Install

`markuplint` already bundles this package. If you need to install it explicitly:

```bash
npm install @markuplint/ml-spec
# or
yarn add @markuplint/ml-spec
```

### Terminology

- "HTML Schema" and "Specs" are used interchangeably in markuplint to mean the JSON Schema that
  describes HTML element specs (attributes, ARIA, content models, etc) and their TypeScript types.

### License

MIT

---
_Source: https://npm.io/package/@markuplint/ml-spec · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
