@markuplint/html-spec 4.14.2 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.15.0](https://github.com/markuplint/markuplint/compare/@markuplint/html-spec@4.14.2...@markuplint/html-spec@4.15.0) (2025-08-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **html-spec:** format attribute value types with proper spacing ([b726ab9](https://github.com/markuplint/markuplint/commit/b726ab97faeee186e0f05f6690de338d7182a060))
11
+ - **html-spec:** update img src/srcset attributes to be mutually required ([1a9a611](https://github.com/markuplint/markuplint/commit/1a9a61102468407ef254e970c2903a69d9ec6465))
12
+
13
+ ### Features
14
+
15
+ - **html-spec:** add compact attribute to dl element ([936aa24](https://github.com/markuplint/markuplint/commit/936aa24ebc4f1e6122a167466ccd4c63025e8ca2))
16
+ - **html-spec:** add compact attribute to menu element ([d4c16f8](https://github.com/markuplint/markuplint/commit/d4c16f89fe1f3a8acb08e3e83cb23e260c017ec6))
17
+ - **html-spec:** add compact attribute to ol element ([a19785b](https://github.com/markuplint/markuplint/commit/a19785b2af45b6ceb65a66b8ef1162b385b15684))
18
+ - **html-spec:** add fetchpriority attribute to SVG script element ([2669d23](https://github.com/markuplint/markuplint/commit/2669d238e0496c5c57b2ca9182685db420312103))
19
+ - **html-spec:** add mask-type attribute to SVG mask element ([9e27e27](https://github.com/markuplint/markuplint/commit/9e27e27eae2166e99cb124725a299c317a1736d9))
20
+ - **html-spec:** remove form attribute from meter element ([1cee2cb](https://github.com/markuplint/markuplint/commit/1cee2cb54f18e38c8ec652ddfd5f382e757eb1b4))
21
+ - **html-spec:** remove the `cursor` SVG element ([43d224f](https://github.com/markuplint/markuplint/commit/43d224f598a0735da95f5754bb1c5577eb091b2a))
22
+ - **html-spec:** remove the `khern` SVG element ([4c05a01](https://github.com/markuplint/markuplint/commit/4c05a010f33100d912d851731eb689b938b0be99))
23
+ - **html-spec:** remove the `missing` SVG element ([c66f316](https://github.com/markuplint/markuplint/commit/c66f316210e0fc185be8c1fe3d33798ed0492b4d))
24
+ - **html-spec:** remove the `tref` SVG element ([520c81f](https://github.com/markuplint/markuplint/commit/520c81f4e391486feea574e99e163faf3b129601))
25
+ - **html-spec:** remove the `vkern` SVG element ([aadd4cc](https://github.com/markuplint/markuplint/commit/aadd4cc91bb6622c64bcb1b1d5beff9759bdbbb6))
26
+ - **html-spec:** update accessibleNameRequired for specific roles ([4e79515](https://github.com/markuplint/markuplint/commit/4e79515a86bd488cb2a8156ad11fcb9a9967453e))
27
+ - **html-spec:** update descriptions for specific roles ([f018270](https://github.com/markuplint/markuplint/commit/f018270b0d3a301899a7a66c22d4c7ed9c1199fe))
28
+ - **html-spec:** update tree role required owned elements based on ARIA spec change ([0e681bb](https://github.com/markuplint/markuplint/commit/0e681bb686869c01e33a67dd65445ff4dc0c1b1c))
29
+
6
30
  ## [4.14.2](https://github.com/markuplint/markuplint/compare/@markuplint/html-spec@4.14.1...@markuplint/html-spec@4.14.2) (2025-04-13)
7
31
 
8
32
  **Note:** Version bump only for package @markuplint/html-spec
package/README.md CHANGED
@@ -2,6 +2,162 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40markuplint%2Fhtml-spec.svg)](https://www.npmjs.com/package/@markuplint/html-spec)
4
4
 
5
+ This package is the canonical dataset of the HTML Schema for markuplint — HTML element specifications
6
+ (structure, attributes, ARIA, and content models).
7
+
8
+ ### What’s in this package
9
+
10
+ - Built output consumed by markuplint:
11
+ - `index.json`
12
+ - Sources (do not edit generated files):
13
+ - `src/spec-*.json` (element specs and common data)
14
+ - Build script: `build.mjs` (invokes `@markuplint/spec-generator`)
15
+
16
+ For the common schema shapes (JSON Schema), generation workflow, and spec-merging behavior, see
17
+ `@markuplint/ml-spec` README.
18
+
19
+ ### Editing workflow (HTML spec data)
20
+
21
+ 1. Edit sources
22
+
23
+ - Element specs: add or edit files under `src/spec-*.json` (e.g. `src/spec.a.json`)
24
+ - Common data shared across elements:
25
+ - Attributes: `src/spec-common.attributes.json`
26
+ - Content models: `src/spec-common.contents.json`
27
+
28
+ 2. Regenerate the built dataset
29
+
30
+ From the repository root (recommended):
31
+
32
+ ```bash
33
+ yarn up:gen
34
+ ```
35
+
36
+ or only for this package:
37
+
38
+ ```bash
39
+ yarn workspace @markuplint/html-spec run gen
40
+ ```
41
+
42
+ This runs the local build script (`build.mjs`) which invokes `@markuplint/spec-generator` and writes
43
+ `index.json`, then formats it with Prettier.
44
+
45
+ #### What `yarn up:gen` does exactly
46
+
47
+ From the repository root, it executes:
48
+
49
+ 1. Change directory into this package
50
+ - `cd packages/@markuplint/html-spec/`
51
+ 2. Run the local `gen` script, which is an alias of:
52
+ - `node build.mjs` (generate `index.json`)
53
+ - `npx prettier --write index.json` (format the output)
54
+
55
+ Inside `build.mjs`, the generator is called with the following inputs:
56
+
57
+ - Output: `index.json`
58
+ - HTML spec sources: `src/spec.*.json`
59
+ - Common attributes: `src/spec-common.attributes.json`
60
+ - Common content models: `src/spec-common.contents.json`
61
+
62
+ No other files are modified. This command does not publish anything.
63
+
64
+ ### What the generator actually does
65
+
66
+ The builder (`@markuplint/spec-generator`) produces a single Extended Spec JSON (`index.json`) by:
67
+
68
+ - Reading every `src/spec.*.json` and inferring the element name from the filename
69
+ - Example: `src/spec.a.json` → name `a`
70
+ - Scraping MDN for each element to enrich missing metadata
71
+ - Fills/updates: `cite` (MDN URL), `description`, `categories`, `omission` (tag omission hints),
72
+ and known attribute metadata (deprecated/obsolete/experimental/nonStandard)
73
+ - Your fields in `src/spec.*.json` take precedence when both exist (manual beats scraped)
74
+ - Injecting obsolete elements not present in sources (WHATWG obsolete list + deprecated SVG)
75
+ - Loading shared data
76
+ - Global attribute sets: `src/spec-common.attributes.json`
77
+ - Content model macros: `src/spec-common.contents.json` (its `models`)
78
+ - Building ARIA definitions by scraping WAI-ARIA and HTML-ARIA
79
+ - Populates `def['#aria']` with roles, properties and graphics-ARIA per version (1.1/1.2/1.3)
80
+ - Emitting the Extended Spec object `{ cites, def: { #globalAttrs, #aria, #contentModels }, specs: [...] }`
81
+ and formatting to `index.json`
82
+
83
+ The output is consumed by markuplint and can be merged with other framework specs.
84
+
85
+ ### How to edit `src/spec.*.json`
86
+
87
+ Each file describes one HTML element. Only specify what differs from the defaults or what you want
88
+ to override from MDN. Recognized top-level keys include:
89
+
90
+ - `contentModel`: allowed children pattern; see `@markuplint/ml-spec` content-model schema
91
+ - `globalAttrs`: enable global attribute sets or list specific ones per category
92
+ - `attributes`: element-specific attributes and their types/options
93
+ - `aria`: implicit role, permitted roles, and ARIA property constraints for this element
94
+ - `omission`: start/end tag omission rules (when applicable)
95
+
96
+ Minimal example (anchor element):
97
+
98
+ ```json
99
+ {
100
+ "contentModel": {
101
+ "contents": [{ "transparent": ":not(:model(interactive), a, [tabindex])" }]
102
+ },
103
+ "globalAttrs": {
104
+ "#HTMLGlobalAttrs": true,
105
+ "#GlobalEventAttrs": true,
106
+ "#ARIAAttrs": true,
107
+ "#HTMLLinkAndFetchingAttrs": ["href", "target", "rel"]
108
+ },
109
+ "attributes": {
110
+ "download": { "type": "Any" }
111
+ },
112
+ "aria": {
113
+ "implicitRole": "link",
114
+ "permittedRoles": ["button", "menuitem"],
115
+ "conditions": {
116
+ ":not([href])": { "implicitRole": "generic", "namingProhibited": true }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ Attribute entries follow the shape from `@markuplint/ml-spec` (`attributes.schema.json`):
123
+
124
+ - Common fields: `type`, `defaultValue`, `required`, `requiredEither`, `noUse`, `condition`,
125
+ `ineffective`, `animatable`, `experimental`, `deprecated`, `obsolete`, `nonStandard`
126
+ - Types come from `@markuplint/types` (`types.schema.json`)
127
+
128
+ When to change shared files:
129
+
130
+ - Add/edit global attribute categories or items → `src/spec-common.attributes.json`
131
+ - Add/edit reusable content model macros → `src/spec-common.contents.json`
132
+
133
+ #### File naming conventions
134
+
135
+ - HTML elements: `src/spec.<tag>.json` (lowercase), e.g. `spec.a.json`, `spec.dialog.json`
136
+ - SVG elements: `src/spec.svg_<local>.json`, e.g. `spec.svg_text.json` → element name `svg:text`
137
+ - The generator infers the element name from the filename; do not add a `name` field manually
138
+
139
+ #### Common editing recipes
140
+
141
+ - Add a new element
142
+ - Create `src/spec.<tag>.json` (or `src/spec.svg_<local>.json`)
143
+ - Define `contentModel`, `globalAttrs`, minimal `attributes`, and `aria`
144
+ - Run `yarn up:gen` and verify `index.json`
145
+
146
+ - Tighten an attribute type
147
+ - Update the attribute entry under `attributes` with the desired `type`
148
+ - If a new value type is needed, extend `@markuplint/types` first, then regenerate this package
149
+
150
+ - Mark an attribute unstable
151
+ - Set `experimental: true`, `deprecated: true`, or `obsolete: true`
152
+ - Manual flags override MDN if the scraper disagrees
153
+
154
+ - Restrict ARIA usage for an element
155
+ - Use `aria.properties`/`aria.permittedRoles` or add `aria.conditions` for context-specific rules
156
+
157
+ 3. Do not edit generated files
158
+
159
+ - Do not modify `index.json` directly. Always update the files under `src/` and regenerate.
160
+
5
161
  ## Install
6
162
 
7
163
  [`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package.
package/index.d.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  import type { Cites, ElementSpec, SpecDefs } from '@markuplint/ml-spec';
2
2
 
3
- export { Attribute } from '@markuplint/ml-spec';
3
+ declare namespace json {
4
+ export { Attribute } from '@markuplint/ml-spec';
5
+ }
4
6
 
5
- export const cites: Cites;
6
- export const def: SpecDefs;
7
- export const specs: ElementSpec[];
7
+ declare const json: {
8
+ cites: Cites;
9
+ def: SpecDefs;
10
+ specs: ElementSpec[];
11
+ };
12
+
13
+ export = json;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-restricted-globals, unicorn/prefer-module */
1
+ /* eslint-disable @typescript-eslint/no-require-imports, no-restricted-globals, unicorn/prefer-module */
2
2
 
3
3
  const json = require('./index.json');
4
4
  module.exports = json;