@markuplint/html-spec 4.17.0 → 5.0.0-alpha.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.
@@ -9,23 +9,23 @@ the shared common files.
9
9
 
10
10
  ### HTML Elements
11
11
 
12
- Pattern: `src/spec.<tag>.json` (e.g., `spec.div.json`, `spec.table.json`, `spec.input.json`)
12
+ Pattern: `src/spec.<tag>.jsonc` (e.g., `spec.div.jsonc`, `spec.table.jsonc`, `spec.input.jsonc`)
13
13
 
14
14
  ### SVG Elements
15
15
 
16
- Pattern: `src/spec.svg_<local>.json` (e.g., `spec.svg_text.json`, `spec.svg_circle.json`)
16
+ Pattern: `src/spec.svg_<local>.jsonc` (e.g., `spec.svg_text.jsonc`, `spec.svg_circle.jsonc`)
17
17
 
18
- The local name preserves case (`svg_animateMotion.json`). The element name is inferred
18
+ The local name preserves case (`svg_animateMotion.jsonc`). The element name is inferred
19
19
  at runtime as `svg:<local>` (e.g., `svg:text`, `svg:clipPath`).
20
20
 
21
21
  ### Common Files
22
22
 
23
- - `spec-common.attributes.json` -- Global attribute category definitions (19 categories)
24
- - `spec-common.contents.json` -- Content model category macros
23
+ - `spec-common.attributes.jsonc` -- Global attribute category definitions (19 categories)
24
+ - `spec-common.contents.jsonc` -- Content model category macros
25
25
 
26
26
  ### JSON with Comments
27
27
 
28
- All spec files support JavaScript-style comments (`//` and `/* */`) via `strip-json-comments`.
28
+ All spec files use the JSONC format (`.jsonc`) and support JavaScript-style comments (`//` and `/* */`) via `jsonc-parser`.
29
29
  Use comments to link to specification URLs at the top of each file:
30
30
 
31
31
  ```json
@@ -87,7 +87,7 @@ The content model definitions in these JSON files are part of a larger ecosystem
87
87
 
88
88
  - **Schema validation** -- `@markuplint/ml-spec` provides `content-models.schema.json` which defines the valid structure of content model patterns (`require`, `optional`, `oneOrMore`, `zeroOrMore`, `choice`, `transparent`). Source JSON files are validated against this schema in tests.
89
89
  - **TypeScript types** -- `@markuplint/ml-spec` auto-generates `ContentModel`, `PermittedContentPattern`, and `Category` types from the schema (in `types/permitted-structures.ts`), enabling type-safe access throughout the codebase.
90
- - **Runtime algorithms** -- `@markuplint/ml-spec` provides `getContentModel()` which evaluates conditional content models at runtime, and `contentModelCategoryToTagNames()` which resolves category names (e.g., `#flow`) to concrete element lists using `def["#contentModels"]` from this package's `spec-common.contents.json`.
90
+ - **Runtime algorithms** -- `@markuplint/ml-spec` provides `getContentModel()` which evaluates conditional content models at runtime, and `contentModelCategoryToTagNames()` which resolves category names (e.g., `#flow`) to concrete element lists using `def["#contentModels"]` from this package's `spec-common.contents.jsonc`.
91
91
  - **Lint rules** -- `@markuplint/rules` uses these definitions in the `permitted-contents` rule (validates element children against content model patterns) and the `no-empty-palpable-content` rule (uses `#palpable` category data to detect empty palpable elements).
92
92
 
93
93
  ## Content Model Patterns
@@ -207,7 +207,7 @@ elements that have been fully obsoleted). In practice, `deprecated` attributes u
207
207
  still work in browsers, while `obsolete` attributes may not.
208
208
 
209
209
  **Flag precedence (spec > MDN):** When a flag is set in the manual spec file
210
- (`src/spec.*.json`), it takes precedence over the MDN-scraped value. This allows you to
210
+ (`src/spec.*.jsonc`), it takes precedence over the MDN-scraped value. This allows you to
211
211
  correct cases where MDN data is inaccurate or lagging behind the specification. Flags
212
212
  from MDN are used only when the manual spec does not define the attribute or does not
213
213
  set that particular flag.
@@ -354,12 +354,12 @@ spec versions. Version overrides can contain their own `conditions` object:
354
354
 
355
355
  ## Common Files
356
356
 
357
- ### spec-common.attributes.json
357
+ ### spec-common.attributes.jsonc
358
358
 
359
359
  Defines the 19 global attribute categories. Each category maps attribute names to
360
360
  definitions using the same format described in the attributes section.
361
361
 
362
- ### spec-common.contents.json
362
+ ### spec-common.contents.jsonc
363
363
 
364
364
  Defines content model category macros referenced via `:model()`. Structure:
365
365
 
@@ -15,15 +15,15 @@
15
15
 
16
16
  ### 1. 新しいHTML要素の追加
17
17
 
18
- 1. `src/spec.<element>.json` を作成(例: `src/spec.dialog.json`)
18
+ 1. `src/spec.<element>.jsonc` を作成(例: `src/spec.dialog.jsonc`)
19
19
  2. 最低限以下を定義:
20
20
  - `contentModel` と `contents`
21
21
  - `globalAttrs`(通常 `#HTMLGlobalAttrs`, `#GlobalEventAttrs`, `#ARIAAttrs` を `true` に設定)
22
22
  - `attributes`(要素固有属性、空 `{}` でも可)
23
23
  - `aria` と `implicitRole`, `permittedRoles`
24
- 3. ファイル先頭に関連仕様URLのコメントを追加(`//` 形式、`strip-json-comments` で処理される)
24
+ 3. ファイル先頭に関連仕様URLのコメントを追加(`//` 形式、`jsonc-parser` で処理される)
25
25
  4. 要素がいずれかのコンテンツカテゴリ(flow、phrasing 等)に属する場合、
26
- `src/spec-common.contents.json` の該当カテゴリに追加する。追加しないと
26
+ `src/spec-common.contents.jsonc` の該当カテゴリに追加する。追加しないと
27
27
  `@markuplint/rules` の `permitted-contents` ルールがそのカテゴリを許可する
28
28
  親要素の中で不正な子要素として検出してしまう
29
29
  5. `yarn workspace @markuplint/html-spec run gen` を実行
@@ -53,7 +53,7 @@
53
53
 
54
54
  ### 2. 既存要素の属性変更
55
55
 
56
- 1. 該当する `src/spec.<element>.json` を開く
56
+ 1. 該当する `src/spec.<element>.jsonc` を開く
57
57
  2. `attributes` オブジェクトにエントリを追加・変更
58
58
  3. 条件付き属性の場合、CSSセレクタで `condition` フィールドを追加
59
59
  4. `yarn workspace @markuplint/html-spec run gen` を実行
@@ -61,7 +61,7 @@
61
61
 
62
62
  ### 3. SVG要素の追加
63
63
 
64
- 1. `src/spec.svg_<localname>.json` を作成(例: `src/spec.svg_circle.json`)
64
+ 1. `src/spec.svg_<localname>.jsonc` を作成(例: `src/spec.svg_circle.jsonc`)
65
65
  2. ファイル名の `svg_` プレフィックスから、要素名は `svg:<localname>` として自動推論される
66
66
  3. SVG固有のグローバル属性カテゴリ(`#SVGCoreAttrs`, `#SVGPresentationAttrs` 等)を使用
67
67
  4. ARIAの `permittedRoles` にはAAM参照オブジェクト(`{ "core-aam": true, "graphics-aam": true }`)を使用
@@ -70,7 +70,7 @@
70
70
 
71
71
  ### 4. グローバル属性カテゴリの変更
72
72
 
73
- 1. `src/spec-common.attributes.json` を編集
73
+ 1. `src/spec-common.attributes.jsonc` を編集
74
74
  2. 各トップレベルキーがカテゴリ(例: `#HTMLGlobalAttrs`, `#SVGCoreAttrs`)
75
75
  3. カテゴリ内の属性定義を追加・削除・変更
76
76
  4. `yarn workspace @markuplint/html-spec run gen` を実行
@@ -78,7 +78,7 @@
78
78
 
79
79
  ### 5. コンテンツモデルカテゴリの追加・更新
80
80
 
81
- 1. `src/spec-common.contents.json` を編集
81
+ 1. `src/spec-common.contents.jsonc` を編集
82
82
  2. `models` オブジェクトに新しいエントリを追加、または既存カテゴリに要素を追加
83
83
  3. SVG要素には `svg|<name>` プレフィックスを使用
84
84
  4. 要素仕様で `:model(newCategory)` として参照
@@ -97,7 +97,7 @@
97
97
 
98
98
  ### 6. ARIAマッピングの更新
99
99
 
100
- 1. 該当する `src/spec.<element>.json` を開く
100
+ 1. 該当する `src/spec.<element>.jsonc` を開く
101
101
  2. `aria` オブジェクトを変更:
102
102
  - `implicitRole` でデフォルトロールを変更
103
103
  - `permittedRoles` 配列を更新
@@ -158,7 +158,7 @@ description の表現変更などの表面的な変更は、更新された `ind
158
158
  場合、手動仕様ファイルの更新が必要になることがある:
159
159
 
160
160
  1. 影響を受ける要素を特定する
161
- 2. 該当する `src/spec.*.json` または `src/spec-common.*.json` を新しい仕様に合わせて
161
+ 2. 該当する `src/spec.*.jsonc` または `src/spec-common.*.jsonc` を新しい仕様に合わせて
162
162
  更新する。まれに `@markuplint/ml-spec` のスキーマや型定義の更新が必要になる
163
163
  こともある
164
164
  3. 手動仕様の変更を反映するために再生成する:
@@ -168,7 +168,7 @@ description の表現変更などの表面的な変更は、更新された `ind
168
168
  4. **冪等性の検証** -- 仕様ファイルの変更が安定した出力を生成することをコミット前に確認する:
169
169
  ```bash
170
170
  # 仕様ファイルと index.json をステージ
171
- git add packages/@markuplint/html-spec/src/spec.*.json packages/@markuplint/html-spec/index.json
171
+ git add packages/@markuplint/html-spec/src/spec.*.jsonc packages/@markuplint/html-spec/index.json
172
172
  # 再生成
173
173
  yarn up:gen
174
174
  # 変更した属性が diff に出ないことを確認(= 安定した出力)
@@ -214,12 +214,12 @@ description の表現変更などの表面的な変更は、更新された `ind
214
214
 
215
215
  ### 編集可能なファイル(これらを変更)
216
216
 
217
- | ファイル | 説明 |
218
- | --------------------------------- | -------------------------------------------------- |
219
- | `src/spec.*.json` | 要素ごとの仕様(177ファイル) |
220
- | `src/spec-common.attributes.json` | グローバル属性カテゴリ定義(19カテゴリ) |
221
- | `src/spec-common.contents.json` | コンテンツモデルカテゴリマクロ(HTML 10 + SVG 19) |
222
- | `build.mjs` | ビルドスクリプト設定 |
217
+ | ファイル | 説明 |
218
+ | ---------------------------------- | -------------------------------------------------- |
219
+ | `src/spec.*.jsonc` | 要素ごとの仕様(177ファイル) |
220
+ | `src/spec-common.attributes.jsonc` | グローバル属性カテゴリ定義(19カテゴリ) |
221
+ | `src/spec-common.contents.jsonc` | コンテンツモデルカテゴリマクロ(HTML 10 + SVG 19) |
222
+ | `build.mjs` | ビルドスクリプト設定 |
223
223
 
224
224
  ### 生成ファイル(編集不可)
225
225
 
@@ -253,14 +253,14 @@ yarn workspace @markuplint/html-spec run test
253
253
 
254
254
  スキーマテストでは以下のスキーマが使用される:
255
255
 
256
- | スキーマ | 対象 |
257
- | ------------------------------- | --------------------------------- |
258
- | `element.schema.json` | `src/spec.*.json` ファイル |
259
- | `global-attributes.schema.json` | `src/spec-common.attributes.json` |
260
- | `attributes.schema.json` | 属性定義の部分スキーマ |
261
- | `types.schema.json` | 型定義の部分スキーマ |
262
- | `aria.schema.json` | ARIA定義の部分スキーマ |
263
- | `content-models.schema.json` | コンテンツモデルの部分スキーマ |
256
+ | スキーマ | 対象 |
257
+ | ------------------------------- | ---------------------------------- |
258
+ | `element.schema.json` | `src/spec.*.jsonc` ファイル |
259
+ | `global-attributes.schema.json` | `src/spec-common.attributes.jsonc` |
260
+ | `attributes.schema.json` | 属性定義の部分スキーマ |
261
+ | `types.schema.json` | 型定義の部分スキーマ |
262
+ | `aria.schema.json` | ARIA定義の部分スキーマ |
263
+ | `content-models.schema.json` | コンテンツモデルの部分スキーマ |
264
264
 
265
265
  ## 依存関係管理
266
266
 
@@ -16,7 +16,7 @@ This is a practical operations and maintenance guide for contributors working on
16
16
  The generation process (`gen`) performs two steps in sequence via `npm-run-all`:
17
17
 
18
18
  1. **`gen:build`** -- Executes `build.mjs`, which calls the `main()` function from
19
- `@markuplint/spec-generator`. This reads all `src/spec.*.json` files, merges them
19
+ `@markuplint/spec-generator`. This reads all `src/spec.*.jsonc` files, merges them
20
20
  with scraped MDN data and the common attribute/content files, appends obsolete
21
21
  element stubs, and writes the consolidated output to `index.json`.
22
22
  2. **`gen:prettier`** -- Runs Prettier on `index.json` to ensure consistent formatting
@@ -30,19 +30,19 @@ Expect the build to take several minutes on a clean run.
30
30
 
31
31
  The build script derives element names from file names using a regex replacement:
32
32
 
33
- - `spec.div.json` becomes element name `div`
34
- - `spec.svg_circle.json` becomes element name `svg_circle`, which is later resolved
33
+ - `spec.div.jsonc` becomes element name `div`
34
+ - `spec.svg_circle.jsonc` becomes element name `svg_circle`, which is later resolved
35
35
  to namespace `svg:circle` by `resolveNamespace()`
36
36
  - Heading elements (`h1` through `h6`) are mapped to the MDN URL path `Heading_Elements`
37
37
 
38
- This naming convention is critical. Any deviation from the `spec.<name>.json` pattern
38
+ This naming convention is critical. Any deviation from the `spec.<name>.jsonc` pattern
39
39
  will cause the element to be silently excluded from the build output.
40
40
 
41
41
  ## Common Recipes
42
42
 
43
43
  ### 1. Adding a New HTML Element
44
44
 
45
- 1. Create `src/spec.<element>.json` (e.g., `src/spec.dialog.json`)
45
+ 1. Create `src/spec.<element>.jsonc` (e.g., `src/spec.dialog.jsonc`)
46
46
  2. Define the specification with at minimum:
47
47
  - `contentModel` with `contents`
48
48
  - `globalAttrs` (typically `#HTMLGlobalAttrs`, `#GlobalEventAttrs`, `#ARIAAttrs` all set to `true`)
@@ -55,7 +55,7 @@ will cause the element to be silently excluded from the build output.
55
55
  // https://w3c.github.io/html-aria/#el-<element>
56
56
  ```
57
57
  4. If the element belongs to any content categories (flow, phrasing, etc.), add it
58
- to the appropriate categories in `src/spec-common.contents.json` -- otherwise
58
+ to the appropriate categories in `src/spec-common.contents.jsonc` -- otherwise
59
59
  `@markuplint/rules`' `permitted-contents` rule will not recognize it as valid
60
60
  content in parent elements that allow those categories
61
61
  5. Run `yarn workspace @markuplint/html-spec run gen`
@@ -63,7 +63,7 @@ will cause the element to be silently excluded from the build output.
63
63
 
64
64
  ### 2. Modifying an Existing Element's Attributes
65
65
 
66
- 1. Open the relevant `src/spec.<element>.json`
66
+ 1. Open the relevant `src/spec.<element>.jsonc`
67
67
  2. Add or modify entries in the `attributes` object
68
68
  3. For conditional attributes, add a `condition` field with a CSS selector:
69
69
  ```json
@@ -77,7 +77,7 @@ will cause the element to be silently excluded from the build output.
77
77
 
78
78
  ### 3. Adding an SVG Element
79
79
 
80
- 1. Create `src/spec.svg_<localname>.json` (e.g., `src/spec.svg_circle.json`)
80
+ 1. Create `src/spec.svg_<localname>.jsonc` (e.g., `src/spec.svg_circle.jsonc`)
81
81
  2. The element name will be inferred as `svg:<localname>` (e.g., `svg:circle`)
82
82
  3. Use SVG-specific global attribute categories:
83
83
  ```json
@@ -100,7 +100,7 @@ will cause the element to be silently excluded from the build output.
100
100
 
101
101
  ### 4. Updating Global Attribute Categories
102
102
 
103
- 1. Edit `src/spec-common.attributes.json`
103
+ 1. Edit `src/spec-common.attributes.jsonc`
104
104
  2. Each top-level key is a category (e.g., `#HTMLGlobalAttrs`)
105
105
  3. Add, remove, or modify attribute definitions within the category
106
106
  4. Run `yarn workspace @markuplint/html-spec run gen`
@@ -108,7 +108,7 @@ will cause the element to be silently excluded from the build output.
108
108
 
109
109
  ### 5. Adding or Updating Content Model Categories
110
110
 
111
- 1. Edit `src/spec-common.contents.json`
111
+ 1. Edit `src/spec-common.contents.jsonc`
112
112
  2. Add a new entry to the `models` object or add elements to existing categories:
113
113
  ```json
114
114
  "#newCategory": ["element1", "element2", "svg|element3"]
@@ -131,7 +131,7 @@ will cause the element to be silently excluded from the build output.
131
131
 
132
132
  ### 6. Updating ARIA Mappings
133
133
 
134
- 1. Open the relevant `src/spec.<element>.json`
134
+ 1. Open the relevant `src/spec.<element>.jsonc`
135
135
  2. Modify the `aria` object:
136
136
  - Change `implicitRole` for the default role
137
137
  - Update `permittedRoles` array
@@ -197,7 +197,7 @@ If the diff reveals a substantive change to element behavior, ARIA mappings, or
197
197
  content models, the manual spec files may need updating:
198
198
 
199
199
  1. Identify which elements are affected
200
- 2. Update the relevant `src/spec.*.json` or `src/spec-common.*.json` files to
200
+ 2. Update the relevant `src/spec.*.jsonc` or `src/spec-common.*.jsonc` files to
201
201
  reflect the new specification. In rare cases, `@markuplint/ml-spec` schemas
202
202
  or types may also need updating.
203
203
  3. Regenerate to incorporate the manual spec changes:
@@ -208,7 +208,7 @@ content models, the manual spec files may need updating:
208
208
  output before committing:
209
209
  ```bash
210
210
  # Stage spec files and index.json
211
- git add packages/@markuplint/html-spec/src/spec.*.json packages/@markuplint/html-spec/index.json
211
+ git add packages/@markuplint/html-spec/src/spec.*.jsonc packages/@markuplint/html-spec/index.json
212
212
  # Regenerate
213
213
  yarn up:gen
214
214
  # Check that the attributes you changed are NOT in the diff (= stable output)
@@ -255,12 +255,12 @@ Obsolete elements automatically get:
255
255
 
256
256
  ### Editable Files (modify these)
257
257
 
258
- | File | Description |
259
- | --------------------------------- | -------------------------------------- |
260
- | `src/spec.*.json` | Per-element specifications (177 files) |
261
- | `src/spec-common.attributes.json` | Global attribute category definitions |
262
- | `src/spec-common.contents.json` | Content model category macros |
263
- | `build.mjs` | Build script configuration |
258
+ | File | Description |
259
+ | ---------------------------------- | -------------------------------------- |
260
+ | `src/spec.*.jsonc` | Per-element specifications (177 files) |
261
+ | `src/spec-common.attributes.jsonc` | Global attribute category definitions |
262
+ | `src/spec-common.contents.jsonc` | Content model category macros |
263
+ | `build.mjs` | Build script configuration |
264
264
 
265
265
  ### Generated Files (DO NOT EDIT)
266
266
 
@@ -283,8 +283,8 @@ The test file `test/structure.spec.mjs` validates:
283
283
 
284
284
  1. **Structure test**: Ensures all elements can be resolved via `resolveNamespace()` and `getAttrSpecsByNames()`
285
285
  2. **Schema tests**: Validates source JSON files against JSON schemas from `@markuplint/ml-spec`:
286
- - `spec.*.json` files against `element.schema.json` (with aria, content-models, global-attributes, attributes, and types schemas)
287
- - `spec-common.attributes.json` against `global-attributes.schema.json`
286
+ - `spec.*.jsonc` files against `element.schema.json` (with aria, content-models, global-attributes, attributes, and types schemas)
287
+ - `spec-common.attributes.jsonc` against `global-attributes.schema.json`
288
288
 
289
289
  The schema validation uses `ajv` (Another JSON Schema Validator) with multiple
290
290
  interrelated schemas loaded together. The element schema references the aria,
@@ -376,14 +376,14 @@ grep -A5 '"accept"' index.json
376
376
  **Resolution**:
377
377
 
378
378
  - Verify the file exists: `src/spec.<element>.json`
379
- - Check file naming: must match `spec.*.json` glob pattern
380
- - For SVG: must be `spec.svg_<name>.json`
379
+ - Check file naming: must match `spec.*.jsonc` glob pattern
380
+ - For SVG: must be `spec.svg_<name>.jsonc`
381
381
 
382
382
  ### JSON Comment Syntax Errors
383
383
 
384
384
  **Symptom**: Build fails with a JSON parse error.
385
385
  **Cause**: Spec files support JavaScript-style comments (`//` and `/* */`) via
386
- `strip-json-comments`, but other non-standard JSON syntax is not supported.
386
+ `jsonc-parser`, but other non-standard JSON syntax is not supported.
387
387
  **Resolution**:
388
388
 
389
389
  - Ensure trailing commas are not present