@markuplint/ml-spec 4.10.1 → 4.10.2
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/ARCHITECTURE.ja.md +253 -0
- package/ARCHITECTURE.md +253 -0
- package/CHANGELOG.md +3 -3
- package/README.md +4 -186
- package/SKILL.md +116 -0
- package/docs/aria-algorithms.ja.md +651 -0
- package/docs/aria-algorithms.md +651 -0
- package/docs/html-algorithms.ja.md +469 -0
- package/docs/html-algorithms.md +469 -0
- package/docs/maintenance.ja.md +340 -0
- package/docs/maintenance.md +340 -0
- package/docs/spec-resolution.ja.md +540 -0
- package/docs/spec-resolution.md +551 -0
- package/docs/type-definitions.ja.md +561 -0
- package/docs/type-definitions.md +561 -0
- package/lib/algorithm/aria/accname-computation.d.ts +7 -0
- package/lib/algorithm/aria/accname-computation.js +7 -0
- package/lib/algorithm/aria/aria-specs.d.ts +7 -0
- package/lib/algorithm/aria/aria-specs.js +7 -0
- package/lib/algorithm/aria/get-aria.d.ts +12 -0
- package/lib/algorithm/aria/get-aria.js +12 -0
- package/lib/algorithm/aria/get-computed-aria-props.d.ts +22 -0
- package/lib/algorithm/aria/get-computed-aria-props.js +10 -0
- package/lib/algorithm/aria/get-computed-role.d.ts +12 -0
- package/lib/algorithm/aria/get-computed-role.js +12 -0
- package/lib/algorithm/aria/get-implicit-role.d.ts +18 -0
- package/lib/algorithm/aria/get-implicit-role.js +18 -0
- package/lib/algorithm/aria/get-permitted-roles.d.ts +9 -0
- package/lib/algorithm/aria/get-permitted-roles.js +9 -0
- package/lib/algorithm/aria/get-role-spec.d.ts +11 -0
- package/lib/algorithm/aria/get-role-spec.js +11 -0
- package/lib/algorithm/aria/has-required-owned-elements.d.ts +23 -0
- package/lib/algorithm/aria/has-required-owned-elements.js +23 -0
- package/lib/algorithm/aria/is-exposed.d.ts +7 -4
- package/lib/algorithm/aria/is-exposed.js +7 -4
- package/lib/algorithm/aria/is-presentational.d.ts +8 -0
- package/lib/algorithm/aria/is-presentational.js +8 -0
- package/lib/algorithm/aria/matches-context-role.d.ts +11 -0
- package/lib/algorithm/aria/matches-context-role.js +11 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.d.ts +9 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.js +9 -0
- package/lib/algorithm/html/get-content-model.d.ts +9 -0
- package/lib/algorithm/html/get-content-model.js +9 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.d.ts +8 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.js +8 -0
- package/lib/algorithm/html/is-nothing-content-model.d.ts +7 -0
- package/lib/algorithm/html/is-nothing-content-model.js +7 -0
- package/lib/algorithm/html/is-palpable-elements.d.ts +13 -0
- package/lib/algorithm/html/is-palpable-elements.js +13 -0
- package/lib/algorithm/html/is-void-element.d.ts +9 -0
- package/lib/algorithm/html/is-void-element.js +9 -0
- package/lib/algorithm/html/may-be-focusable.d.ts +10 -0
- package/lib/algorithm/html/may-be-focusable.js +10 -0
- package/lib/types/index.d.ts +54 -0
- package/lib/utils/aria-version.d.ts +6 -0
- package/lib/utils/aria-version.js +6 -0
- package/lib/utils/get-attr-specs-spec.d.ts +18 -0
- package/lib/utils/get-attr-specs-spec.js +18 -0
- package/lib/utils/get-attr-specs.d.ts +9 -0
- package/lib/utils/get-attr-specs.js +9 -0
- package/lib/utils/get-spec-by-tag-name.d.ts +11 -0
- package/lib/utils/get-spec-by-tag-name.js +11 -0
- package/lib/utils/get-spec.d.ts +11 -1
- package/lib/utils/get-spec.js +10 -0
- package/lib/utils/resolve-namespace.d.ts +13 -0
- package/lib/utils/resolve-namespace.js +10 -0
- package/lib/utils/schema-to-spec.d.ts +5 -2
- package/lib/utils/schema-to-spec.js +5 -2
- package/lib/utils/validate-aria-version.d.ts +7 -0
- package/lib/utils/validate-aria-version.js +7 -0
- package/package.json +6 -6
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
# HTML コンテンツモデルアルゴリズム
|
|
2
|
+
|
|
3
|
+
## 概要
|
|
4
|
+
|
|
5
|
+
`@markuplint/ml-spec` パッケージは、[HTML Living Standard](https://html.spec.whatwg.org/multipage/dom.html#content-models) に基づくコンテンツモデル評価および要素分類アルゴリズムを実装しています。これらの関数は DOM の `Element` インターフェースと `MLMLSpec`(markuplint の仕様データ)を組み合わせて、要素が含むことのできるコンテンツ、要素がボイド要素か、パルパブルか、フォーカス可能かなどを判定します。
|
|
6
|
+
|
|
7
|
+
HTML アルゴリズム関数はすべて `src/algorithm/html/` 配下に配置されています。
|
|
8
|
+
|
|
9
|
+
コンテンツモデルカテゴリの型は `src/types/permitted-structures.ts` で定義されており、**10 の HTML カテゴリ**と **19 の SVG カテゴリ**でコンテンツモデルシステムの基盤を構成しています。
|
|
10
|
+
|
|
11
|
+
## コンテンツモデルシステム
|
|
12
|
+
|
|
13
|
+
### カテゴリからセレクタへのマッピング
|
|
14
|
+
|
|
15
|
+
仕様定義(`SpecDefs['#contentModels']`)は、各 `Category` 文字列を CSS セレクタ文字列の読み取り専用配列にマッピングします。
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
type SpecDefs = {
|
|
19
|
+
readonly '#contentModels': {
|
|
20
|
+
readonly [model in Category]?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
各カテゴリは、そのカテゴリに属する要素を特定するセレクタにマッピングされます。例:
|
|
26
|
+
|
|
27
|
+
- `#flow` は `['a', 'abbr', 'address', ...]` にマッピング
|
|
28
|
+
- `#interactive` は `['a[href]', 'audio[controls]', ...]` にマッピング
|
|
29
|
+
|
|
30
|
+
一部のセレクタには属性条件(`a[href]`、`audio[controls]`)が含まれていることに注目してください。これは、要素のカテゴリへの所属がその属性に依存する場合があることを意味します。HTML Standard の条件付きコンテンツモデルはこの仕組みで表現されています。
|
|
31
|
+
|
|
32
|
+
### 条件付きコンテンツモデル
|
|
33
|
+
|
|
34
|
+
要素の許可されるコンテンツは、その属性に基づいて変化する場合があります。`ContentModel` インターフェースはこれをサポートします。
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface ContentModel {
|
|
38
|
+
contents: PermittedContentPattern[] | boolean;
|
|
39
|
+
descendantOf?: string;
|
|
40
|
+
conditional?: {
|
|
41
|
+
condition: string;
|
|
42
|
+
contents: PermittedContentPattern[] | boolean;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`conditional` が存在する場合、各条件の `condition` 文字列が `el.matches(condition)` で検査されます。最初にマッチした条件の `contents` 値が使用されます。どの条件にもマッチしない場合、デフォルトの `contents` 値が適用されます。
|
|
48
|
+
|
|
49
|
+
## 関数リファレンス
|
|
50
|
+
|
|
51
|
+
### 1. `getContentModel(el, specs)`
|
|
52
|
+
|
|
53
|
+
**ファイル:** `src/algorithm/html/get-content-model.ts`
|
|
54
|
+
|
|
55
|
+
要素の許可されるコンテンツモデルを取得します。
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
function getContentModel(
|
|
59
|
+
el: Element,
|
|
60
|
+
specs: readonly Pick<ElementSpec, 'name' | 'contentModel'>[],
|
|
61
|
+
): ReadonlyDeep<PermittedContentPattern[]> | boolean | null;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**パラメータ:**
|
|
65
|
+
|
|
66
|
+
| パラメータ | 型 | 説明 |
|
|
67
|
+
| ---------- | -------------------------------------------------------- | ----------------------------------------- |
|
|
68
|
+
| `el` | `Element` | コンテンツモデルを取得する対象の DOM 要素 |
|
|
69
|
+
| `specs` | `readonly Pick<ElementSpec, 'name' \| 'contentModel'>[]` | コンテンツモデル定義を含む要素仕様 |
|
|
70
|
+
|
|
71
|
+
**戻り値:**
|
|
72
|
+
|
|
73
|
+
| 値 | 意味 |
|
|
74
|
+
| --------------------------- | ------------------------------------ |
|
|
75
|
+
| `PermittedContentPattern[]` | 要素に対する具体的なコンテンツルール |
|
|
76
|
+
| `true` | あらゆるコンテンツが許可される |
|
|
77
|
+
| `false` | コンテンツが許可されない |
|
|
78
|
+
| `null` | 要素の仕様が見つからない |
|
|
79
|
+
|
|
80
|
+
**動作:**
|
|
81
|
+
|
|
82
|
+
1. ネストされた `Map<Specs, Map<Element, result>>` キャッシュを確認します。指定された specs 参照と要素インスタンスに対するキャッシュ結果が存在すれば、即座に返します。
|
|
83
|
+
2. `getSpec()` を使用して要素の仕様を検索します。見つからない場合、`null` をキャッシュして返します。
|
|
84
|
+
3. `contentModel.conditional[]`(存在する場合)を走査します。各条件に対して `el.matches(cond.condition)` を呼び出します。
|
|
85
|
+
4. 最初にマッチした条件の `contents` を返します。どの条件にもマッチしない場合、デフォルトの `contentModel.contents` を返します。
|
|
86
|
+
5. すべての結果は返却前にキャッシュされます。
|
|
87
|
+
|
|
88
|
+
**キャッシュ戦略:**
|
|
89
|
+
|
|
90
|
+
キャッシュは 2 階層の `Map` です。外側のマップは `specs` 配列の参照をキーとし、内側のマップは `Element` インスタンスをキーとします。これにより、specs が変更された場合に結果が正しく無効化される一方、同じ要素に対する冗長な計算を回避できます。
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### 2. `isPalpableElement(el, specs, options?)`
|
|
95
|
+
|
|
96
|
+
**ファイル:** `src/algorithm/html/is-palpable-elements.ts`
|
|
97
|
+
|
|
98
|
+
要素がパルパブルコンテンツと見なされるかどうかを判定します。パルパブル要素とは、ユーザーに対して可視的または意味のあるコンテンツをレンダリングする要素です。
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
function isPalpableElement(
|
|
102
|
+
el: Element,
|
|
103
|
+
specs: MLMLSpec,
|
|
104
|
+
options?: {
|
|
105
|
+
readonly extendsSvg?: boolean;
|
|
106
|
+
readonly extendsExposableElements?: boolean;
|
|
107
|
+
},
|
|
108
|
+
): boolean;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**パラメータ:**
|
|
112
|
+
|
|
113
|
+
| パラメータ | 型 | デフォルト | 説明 |
|
|
114
|
+
| ---------------------------------- | ---------- | ---------- | ------------------------------------- |
|
|
115
|
+
| `el` | `Element` | -- | チェック対象の DOM 要素 |
|
|
116
|
+
| `specs` | `MLMLSpec` | -- | マークアップ言語の完全な仕様 |
|
|
117
|
+
| `options.extendsSvg` | `boolean` | `true` | `#SVGRenderable` 要素を含めるかどうか |
|
|
118
|
+
| `options.extendsExposableElements` | `boolean` | `false` | 追加の露出可能な要素を含めるかどうか |
|
|
119
|
+
|
|
120
|
+
**露出可能な要素**(意味的に重要だが `#palpable` カテゴリには属さない要素):
|
|
121
|
+
|
|
122
|
+
`body`, `dd`, `dt`, `figcaption`, `html`, `legend`, `li`, `optgroup`, `option`, `rp`, `rt`, `summary`, `tbody`, `td`, `tfoot`, `th`, `thead`, `tr`
|
|
123
|
+
|
|
124
|
+
**動作:**
|
|
125
|
+
|
|
126
|
+
1. `#palpable` コンテンツモデルカテゴリから CSS セレクタを収集します。
|
|
127
|
+
2. `extendsSvg` が `false` でない場合(デフォルト: `true`)、`#SVGRenderable` セレクタを追加します。
|
|
128
|
+
3. `extendsExposableElements` が `true` の場合(デフォルト: `false`)、ハードコードされた露出可能要素のリストを追加します。
|
|
129
|
+
4. 収集されたセレクタ文字列のいずれかに対して `el.matches()` が成功すれば `true` を返します。
|
|
130
|
+
|
|
131
|
+
> **警告:** この実装は著者による HTML 仕様の解釈を含んでいます。不正確な点を発見した場合は、https://github.com/markuplint/markuplint/issues/new で Issue を報告してください。
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 3. `isVoidElement(el)`
|
|
136
|
+
|
|
137
|
+
**ファイル:** `src/algorithm/html/is-void-element.ts`
|
|
138
|
+
|
|
139
|
+
HTML 仕様で定義されたボイド要素かどうかを判定します。ボイド要素はコンテンツを持つことができません。
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
function isVoidElement(el: { readonly localName: string }): boolean;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**パラメータ:**
|
|
146
|
+
|
|
147
|
+
| パラメータ | 型 | 説明 |
|
|
148
|
+
| ---------- | -------------------------------- | ---------------------------------------------- |
|
|
149
|
+
| `el` | `{ readonly localName: string }` | `localName` プロパティを持つ任意のオブジェクト |
|
|
150
|
+
|
|
151
|
+
この関数は DOM `Element` だけでなく、`localName` プロパティを持つ任意のオブジェクトを受け付けることに注意してください。これにより、完全な Element が利用できないコンテキストでも使用可能です。
|
|
152
|
+
|
|
153
|
+
**ボイド要素(13 個):**
|
|
154
|
+
|
|
155
|
+
`area`, `base`, `br`, `col`, `embed`, `hr`, `img`, `input`, `link`, `meta`, `source`, `track`, `wbr`
|
|
156
|
+
|
|
157
|
+
リストは O(1) のルックアップ性能のために `Set` として格納されています。
|
|
158
|
+
|
|
159
|
+
**仕様:** https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### 4. `isNothingContentModel(el)`
|
|
164
|
+
|
|
165
|
+
**ファイル:** `src/algorithm/html/is-nothing-content-model.ts`
|
|
166
|
+
|
|
167
|
+
要素が「nothing」コンテンツモデルを使用するかどうかを判定します。これは、要素がコンテンツを一切含んではならないことを意味します。
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
function isNothingContentModel(el: Element): boolean;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**パラメータ:**
|
|
174
|
+
|
|
175
|
+
| パラメータ | 型 | 説明 |
|
|
176
|
+
| ---------- | --------- | ----------------------- |
|
|
177
|
+
| `el` | `Element` | チェック対象の DOM 要素 |
|
|
178
|
+
|
|
179
|
+
**動作:**
|
|
180
|
+
|
|
181
|
+
以下のいずれかに該当する場合 `true` を返します:
|
|
182
|
+
|
|
183
|
+
- **ボイド要素**である(`isVoidElement()` に委譲)
|
|
184
|
+
- `<iframe>` 要素である
|
|
185
|
+
- `<template>` 要素である
|
|
186
|
+
|
|
187
|
+
`<iframe>` と `<template>` はボイド要素ではありませんが、HTML 仕様上「nothing」コンテンツモデルを使用します。iframe のコンテンツは別のコンテンツに置換され、template のコンテンツは別のドキュメントフラグメントに格納されるためです。
|
|
188
|
+
|
|
189
|
+
**仕様:** https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 5. `mayBeFocusable(el, specs)`
|
|
194
|
+
|
|
195
|
+
**ファイル:** `src/algorithm/html/may-be-focusable.ts`
|
|
196
|
+
|
|
197
|
+
要素がフォーカス可能である可能性があるかどうかをヒューリスティックに判定します。
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**パラメータ:**
|
|
204
|
+
|
|
205
|
+
| パラメータ | 型 | 説明 |
|
|
206
|
+
| ---------- | ---------- | ---------------------------------------------------------------- |
|
|
207
|
+
| `el` | `Element` | チェック対象の DOM 要素 |
|
|
208
|
+
| `specs` | `MLMLSpec` | インタラクティブコンテンツ定義を含むマークアップ言語の完全な仕様 |
|
|
209
|
+
|
|
210
|
+
**動作:**
|
|
211
|
+
|
|
212
|
+
要素を以下のセレクタに対してマッチングします:
|
|
213
|
+
|
|
214
|
+
1. `#interactive` コンテンツモデルカテゴリのすべてのセレクタ(`getSelectorsByContentModelCategory()` で取得)
|
|
215
|
+
2. `[tabindex]` -- `tabindex` 属性を持つ任意の要素
|
|
216
|
+
3. `[contenteditable]:not([contenteditable="false" i])` -- contenteditable 要素(大文字小文字を区別しない比較)
|
|
217
|
+
|
|
218
|
+
これらのセレクタのいずれかに対して `el.matches()` が成功すれば `true` を返します。
|
|
219
|
+
|
|
220
|
+
**制限事項:**
|
|
221
|
+
|
|
222
|
+
これは静的なヒューリスティックです。フォーカス可能性を妨げる可能性のあるランタイム状態は考慮**しません**:
|
|
223
|
+
|
|
224
|
+
- フォーム要素の `disabled` 属性
|
|
225
|
+
- `inert` 属性
|
|
226
|
+
- CSS によって非表示にされた要素(`display: none`、`visibility: hidden`)
|
|
227
|
+
- Shadow DOM の境界
|
|
228
|
+
|
|
229
|
+
この関数は主に ARIA ロール計算で使用され、WAI-ARIA 仕様に従い、フォーカス可能な要素にプレゼンテーショナルロール(`role="none"` / `role="presentation"`)が適用されるのを防ぎます。
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### 6. `getSelectorsByContentModelCategory(specs, category)`
|
|
234
|
+
|
|
235
|
+
**ファイル:** `src/algorithm/html/get-selectors-by-content-model-category.ts`
|
|
236
|
+
|
|
237
|
+
コンテンツモデルカテゴリに関連付けられた CSS セレクタを取得するためのダイレクトアクセサです。
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**パラメータ:**
|
|
244
|
+
|
|
245
|
+
| パラメータ | 型 | 説明 |
|
|
246
|
+
| ---------- | ---------- | ------------------------------------------------------------- |
|
|
247
|
+
| `specs` | `MLMLSpec` | マークアップ言語の完全な仕様 |
|
|
248
|
+
| `category` | `Category` | コンテンツモデルカテゴリ識別子(例: `#flow`、`#interactive`) |
|
|
249
|
+
|
|
250
|
+
**戻り値:**
|
|
251
|
+
|
|
252
|
+
カテゴリの CSS セレクタ文字列の読み取り専用配列。カテゴリが仕様に定義されていない場合は空配列を返します。
|
|
253
|
+
|
|
254
|
+
**実装:**
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
const selectors = specs.def['#contentModels'][category];
|
|
258
|
+
return selectors ?? [];
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
直接的なプロパティアクセスに対する null 安全性を提供する薄いラッパーです。
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### 7. `contentModelCategoryToTagNames(contentModel, def)`
|
|
266
|
+
|
|
267
|
+
**ファイル:** `src/algorithm/html/content-model-category-to-tag-names.ts`
|
|
268
|
+
|
|
269
|
+
コンテンツモデルカテゴリを、そのカテゴリに属するタグ名のソート済み・凍結済み配列に変換します。
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**パラメータ:**
|
|
276
|
+
|
|
277
|
+
| パラメータ | 型 | 説明 |
|
|
278
|
+
| -------------- | ----------------- | ------------------------------ |
|
|
279
|
+
| `contentModel` | `Category` | コンテンツモデルカテゴリ識別子 |
|
|
280
|
+
| `def` | `MLMLSpec['def']` | 仕様定義 |
|
|
281
|
+
|
|
282
|
+
**戻り値:**
|
|
283
|
+
|
|
284
|
+
`Object.freeze()` されたソート済みのタグ名文字列配列。カテゴリが定義されていないかエントリがない場合は、凍結された空配列を返します。
|
|
285
|
+
|
|
286
|
+
**キャッシュ:**
|
|
287
|
+
|
|
288
|
+
結果はモジュールレベルの `Map<Category, ReadonlyArray<string>>` にキャッシュされます。一度あるカテゴリについて計算されると、以降の呼び出しではその結果が再利用されます。
|
|
289
|
+
|
|
290
|
+
**重要な注意:** この関数はコンテンツモデル定義に格納されたセレクタ文字列からタグ名を直接取得します。CSS セレクタの解析は行いません。`#contentModels` のセレクタは単純なタグ名またはタグ+属性セレクタであることが前提です。複雑なセレクタはタグ名に正しく分解されない場合があります。
|
|
291
|
+
|
|
292
|
+
## コンテンツモデルカテゴリ
|
|
293
|
+
|
|
294
|
+
### HTML カテゴリ(10)
|
|
295
|
+
|
|
296
|
+
| カテゴリ | 説明 | 要素の例 |
|
|
297
|
+
| -------------------- | ---------------------------------------- | ----------------------------------------------------------- |
|
|
298
|
+
| `#text` | テキストコンテンツ | テキストノード |
|
|
299
|
+
| `#phrasing` | インラインレベルコンテンツ | `a`, `em`, `strong`, `span`, `img` |
|
|
300
|
+
| `#flow` | ブロックレベルおよびインラインコンテンツ | ほぼすべての body 内要素 |
|
|
301
|
+
| `#interactive` | ユーザーが操作可能なコンテンツ | `a[href]`, `button`, `input`, `select` |
|
|
302
|
+
| `#heading` | セクション見出し | `h1`, `h2`, `h3`, `h4`, `h5`, `h6` |
|
|
303
|
+
| `#sectioning` | 文書構造セクション | `article`, `aside`, `nav`, `section` |
|
|
304
|
+
| `#metadata` | 文書に関するメタデータ | `base`, `link`, `meta`, `script`, `style`, `title` |
|
|
305
|
+
| `#embedded` | 文書に埋め込まれた外部コンテンツ | `audio`, `canvas`, `embed`, `iframe`, `img`, `video` |
|
|
306
|
+
| `#palpable` | 可視的・意味のあるコンテンツ | メタデータ以外のほとんどのフロー/フレージングコンテンツ要素 |
|
|
307
|
+
| `#script-supporting` | スクリプトインフラストラクチャ | `script`, `template` |
|
|
308
|
+
|
|
309
|
+
### SVG カテゴリ(19)
|
|
310
|
+
|
|
311
|
+
| カテゴリ | 説明 |
|
|
312
|
+
| -------------------------- | ------------------------------------------------------------------------------ |
|
|
313
|
+
| `#SVGAnimation` | SVG アニメーション要素(`animate`、`animateMotion` など) |
|
|
314
|
+
| `#SVGBasicShapes` | 基本図形要素(`circle`、`ellipse`、`line`、`polygon`、`polyline`、`rect`) |
|
|
315
|
+
| `#SVGContainer` | コンテナ要素(`a`、`defs`、`g`、`marker`、`mask`、`svg`、`symbol` など) |
|
|
316
|
+
| `#SVGDescriptive` | 説明要素(`desc`、`metadata`、`title`) |
|
|
317
|
+
| `#SVGFilterPrimitive` | フィルタプリミティブ要素(`feBlend`、`feColorMatrix`、`feGaussianBlur` など) |
|
|
318
|
+
| `#SVGFont` | フォント要素(非推奨: `font`、`font-face` など) |
|
|
319
|
+
| `#SVGGradient` | グラデーション要素(`linearGradient`、`radialGradient`、`stop`) |
|
|
320
|
+
| `#SVGGraphics` | グラフィックス要素(図形、画像、テキストなど) |
|
|
321
|
+
| `#SVGGraphicsReferencing` | グラフィックス参照要素(`image`、`use`) |
|
|
322
|
+
| `#SVGLightSource` | 光源要素(`feDistantLight`、`fePointLight`、`feSpotLight`) |
|
|
323
|
+
| `#SVGNeverRendered` | 直接レンダリングされない要素(`clipPath`、`defs`、`linearGradient` など) |
|
|
324
|
+
| `#SVGNone` | コンテンツ不可 |
|
|
325
|
+
| `#SVGPaintServer` | ペイントサーバー要素(`linearGradient`、`pattern`、`radialGradient` など) |
|
|
326
|
+
| `#SVGRenderable` | レンダリング可能な要素(`a`、`circle`、`g`、`rect`、`svg`、`text` など) |
|
|
327
|
+
| `#SVGShape` | 図形要素(`circle`、`ellipse`、`line`、`path`、`polygon`、`polyline`、`rect`) |
|
|
328
|
+
| `#SVGStructural` | 構造要素(`defs`、`g`、`svg`、`symbol`、`use`) |
|
|
329
|
+
| `#SVGStructurallyExternal` | 構造的外部要素(`image`、`use`) |
|
|
330
|
+
| `#SVGTextContent` | テキストコンテンツ要素(`text`、`textPath`、`tspan`) |
|
|
331
|
+
| `#SVGTextContentChild` | テキストコンテンツ子要素(`textPath`、`tspan`) |
|
|
332
|
+
|
|
333
|
+
## PermittedContentPattern フォーマット
|
|
334
|
+
|
|
335
|
+
`PermittedContentPattern` 型は 6 つのパターン型の判別共用体(discriminated union)です。これらのパターンは `src/types/permitted-structures.ts` で定義されており、JSON Schema から自動生成されています。
|
|
336
|
+
|
|
337
|
+
### パターン型
|
|
338
|
+
|
|
339
|
+
#### `PermittedContentRequire`
|
|
340
|
+
|
|
341
|
+
出現しなければならない必須コンテンツを指定します。
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
interface PermittedContentRequire {
|
|
345
|
+
require: Model | PermittedContentPattern[];
|
|
346
|
+
min?: number;
|
|
347
|
+
max?: number;
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**例:** ちょうど 1 つの `<caption>` を必要とする要素:
|
|
352
|
+
|
|
353
|
+
```json
|
|
354
|
+
{ "require": "caption", "min": 1, "max": 1 }
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### `PermittedContentOptional`
|
|
358
|
+
|
|
359
|
+
任意で出現してもよいコンテンツを指定します。
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
interface PermittedContentOptional {
|
|
363
|
+
optional: Model | PermittedContentPattern[];
|
|
364
|
+
max?: number;
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**例:** オプションの `<thead>`:
|
|
369
|
+
|
|
370
|
+
```json
|
|
371
|
+
{ "optional": "thead", "max": 1 }
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
#### `PermittedContentOneOrMore`
|
|
375
|
+
|
|
376
|
+
少なくとも 1 回は出現しなければならないコンテンツを指定します(1..N)。
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
interface PermittedContentOneOrMore {
|
|
380
|
+
oneOrMore: Model | PermittedContentPattern[];
|
|
381
|
+
max?: number;
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**例:** 1 つ以上の `<tr>` 要素:
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{ "oneOrMore": "tr" }
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
#### `PermittedContentZeroOrMore`
|
|
392
|
+
|
|
393
|
+
任意の回数出現してもよいコンテンツを指定します(0..N)。
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
interface PermittedContentZeroOrMore {
|
|
397
|
+
zeroOrMore: Model | PermittedContentPattern[];
|
|
398
|
+
max?: number;
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**例:** 0 個以上のフローコンテンツの子要素:
|
|
403
|
+
|
|
404
|
+
```json
|
|
405
|
+
{ "zeroOrMore": "#flow" }
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### `PermittedContentChoice`
|
|
409
|
+
|
|
410
|
+
2 つから 5 つの代替コンテンツパターンの選択を指定します。
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
interface PermittedContentChoice {
|
|
414
|
+
choice:
|
|
415
|
+
| [PermittedContentPattern[], PermittedContentPattern[]]
|
|
416
|
+
| [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
|
|
417
|
+
| [
|
|
418
|
+
/* 4 つの選択肢 */
|
|
419
|
+
]
|
|
420
|
+
| [
|
|
421
|
+
/* 5 つの選択肢 */
|
|
422
|
+
];
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
**例:** フローコンテンツ、または `<param>` 要素の後にフローコンテンツ:
|
|
427
|
+
|
|
428
|
+
```json
|
|
429
|
+
{
|
|
430
|
+
"choice": [[{ "zeroOrMore": "#flow" }], [{ "oneOrMore": "param" }, { "zeroOrMore": "#flow" }]]
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
#### `PermittedContentTransparent`
|
|
435
|
+
|
|
436
|
+
要素が親のコンテンツモデルを継承することを示します(透過的コンテンツモデル)。
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
interface PermittedContentTransparent {
|
|
440
|
+
transparent: string;
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**例:** `<a>` 要素は透過的:
|
|
445
|
+
|
|
446
|
+
```json
|
|
447
|
+
{ "transparent": "a" }
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### `Model` 型
|
|
451
|
+
|
|
452
|
+
`require`、`optional`、`oneOrMore`、`zeroOrMore` プロパティは `Model` 値を受け付けます。定義は以下の通りです:
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
type Model = ContentType | ContentType[];
|
|
456
|
+
type ContentType = string | Category;
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
- 単一の文字列: タグ名(例: `"div"`)またはカテゴリ(例: `"#flow"`)
|
|
460
|
+
- 文字列の配列: 複数の許可される型(論理 OR)
|
|
461
|
+
|
|
462
|
+
## HTML Standard 参照リンク
|
|
463
|
+
|
|
464
|
+
- [コンテンツモデル](https://html.spec.whatwg.org/multipage/dom.html#content-models)
|
|
465
|
+
- [ボイド要素](https://html.spec.whatwg.org/multipage/syntax.html#void-elements)
|
|
466
|
+
- [インタラクティブコンテンツ](https://html.spec.whatwg.org/multipage/dom.html#interactive-content)
|
|
467
|
+
- [パルパブルコンテンツ](https://html.spec.whatwg.org/multipage/dom.html#palpable-content)
|
|
468
|
+
- [nothing コンテンツモデル](https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model)
|
|
469
|
+
- [要素インデックス](https://html.spec.whatwg.org/multipage/indices.html#elements-3)
|