@markuplint/ml-spec 3.0.0-dev.25 → 3.0.0-dev.38
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/lib/dom-traverse/is-exposed.js +8 -0
- package/package.json +4 -4
- package/schemas/aria.schema.json +0 -258
- package/schemas/attributes.schema.json +0 -204
- package/schemas/content-models.schema.json +0 -199
- package/schemas/element.schema.json +0 -11
- package/schemas/global-attributes.schema.json +0 -761
- package/src/dom-traverse/accname-computation.spec.ts +0 -69
- package/src/dom-traverse/accname-computation.ts +0 -5
- package/src/dom-traverse/get-attr-specs.ts +0 -8
- package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
- package/src/dom-traverse/get-computed-aria-props.ts +0 -130
- package/src/dom-traverse/get-computed-role.spec.ts +0 -134
- package/src/dom-traverse/get-computed-role.ts +0 -181
- package/src/dom-traverse/get-content-model.ts +0 -32
- package/src/dom-traverse/get-explicit-role.ts +0 -112
- package/src/dom-traverse/get-implicit-role.ts +0 -36
- package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
- package/src/dom-traverse/get-permitted-roles.ts +0 -7
- package/src/dom-traverse/get-spec.ts +0 -7
- package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
- package/src/dom-traverse/has-required-owned-elements.ts +0 -85
- package/src/dom-traverse/is-exposed.spec.ts +0 -50
- package/src/dom-traverse/is-exposed.ts +0 -196
- package/src/dom-traverse/may-be-focusable.ts +0 -21
- package/src/index.ts +0 -24
- package/src/specs/aria-specs.ts +0 -6
- package/src/specs/content-model-category-to-tag-names.ts +0 -15
- package/src/specs/get-aria.ts +0 -85
- package/src/specs/get-attr-specs.spec.ts +0 -47
- package/src/specs/get-attr-specs.ts +0 -116
- package/src/specs/get-implicit-role.spec.ts +0 -81
- package/src/specs/get-implicit-role.ts +0 -17
- package/src/specs/get-permitted-roles.spec.ts +0 -420
- package/src/specs/get-permitted-roles.ts +0 -87
- package/src/specs/get-role-spec.spec.ts +0 -67
- package/src/specs/get-role-spec.ts +0 -72
- package/src/specs/get-selectors-by-content-model-category.ts +0 -10
- package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
- package/src/specs/get-spec-by-tag-name.ts +0 -20
- package/src/specs/is-nothing-content-model.ts +0 -9
- package/src/specs/is-palpable-elements.ts +0 -55
- package/src/specs/is-presentational.ts +0 -6
- package/src/specs/is-void-element.ts +0 -22
- package/src/specs/resolve-version.ts +0 -20
- package/src/specs/schema-to-spec.spec.ts +0 -39
- package/src/specs/schema-to-spec.ts +0 -103
- package/src/types/aria.ts +0 -153
- package/src/types/attributes.ts +0 -1524
- package/src/types/index.ts +0 -255
- package/src/types/permitted-structres.ts +0 -100
- package/src/types/permitted-structures.ts +0 -96
- package/src/utils/get-ns.ts +0 -18
- package/src/utils/merge-array.ts +0 -35
- package/src/utils/resolve-namespace.spec.ts +0 -37
- package/src/utils/resolve-namespace.ts +0 -40
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
package/src/types/index.ts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import type { ARIA } from './aria';
|
|
2
|
-
import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
|
|
3
|
-
import type { ContentModel, Category } from './permitted-structures';
|
|
4
|
-
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* markuplint Markup-language spec
|
|
8
|
-
*/
|
|
9
|
-
export interface MLMLSpec {
|
|
10
|
-
cites: Cites;
|
|
11
|
-
def: SpecDefs;
|
|
12
|
-
specs: ElementSpec[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
|
|
16
|
-
name: ElementSpec['name'];
|
|
17
|
-
attributes?: Record<string, Partial<Attribute>>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type ExtendedSpec = {
|
|
21
|
-
cites?: Cites;
|
|
22
|
-
def?: Partial<SpecDefs>;
|
|
23
|
-
specs?: ExtendedElementSpec[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Reference URLs
|
|
28
|
-
*/
|
|
29
|
-
export type Cites = string[];
|
|
30
|
-
|
|
31
|
-
export type SpecDefs = {
|
|
32
|
-
'#globalAttrs': Partial<{
|
|
33
|
-
'#extends': Record<string, Partial<Attribute>>;
|
|
34
|
-
'#HTMLGlobalAttrs': Record<string, Partial<Attribute>>;
|
|
35
|
-
[OtherGlobalAttrs: string]: Record<string, Partial<Attribute>>;
|
|
36
|
-
}>;
|
|
37
|
-
'#aria': {
|
|
38
|
-
'1.2': ARIASpec;
|
|
39
|
-
'1.1': ARIASpec;
|
|
40
|
-
};
|
|
41
|
-
'#contentModels': { [model in Category]?: string[] };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type ARIASpec = {
|
|
45
|
-
roles: ARIARoleInSchema[];
|
|
46
|
-
graphicsRoles: ARIARoleInSchema[];
|
|
47
|
-
props: ARIAProperty[];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Element spec
|
|
52
|
-
*/
|
|
53
|
-
export type ElementSpec = {
|
|
54
|
-
/**
|
|
55
|
-
* Tag name
|
|
56
|
-
*/
|
|
57
|
-
name: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Namespaces in XML
|
|
61
|
-
* @see https://www.w3.org/TR/xml-names/
|
|
62
|
-
*/
|
|
63
|
-
namespace?: NamespaceURI;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Reference URL
|
|
67
|
-
*/
|
|
68
|
-
cite: string;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Description
|
|
72
|
-
*/
|
|
73
|
-
description?: string;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Experimental technology
|
|
77
|
-
*/
|
|
78
|
-
experimental?: true;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Obsolete or alternative elements
|
|
82
|
-
*/
|
|
83
|
-
obsolete?:
|
|
84
|
-
| true
|
|
85
|
-
| {
|
|
86
|
-
alt: string;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Deprecated
|
|
91
|
-
*/
|
|
92
|
-
deprecated?: true;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Non-standard
|
|
96
|
-
*/
|
|
97
|
-
nonStandard?: true;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Element categories
|
|
101
|
-
*/
|
|
102
|
-
categories: Category[];
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Permitted contents and permitted parents
|
|
106
|
-
*/
|
|
107
|
-
contentModel: ContentModel;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Tag omission
|
|
111
|
-
*/
|
|
112
|
-
omission: ElementSpecOmission;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Global Attributes
|
|
116
|
-
*/
|
|
117
|
-
globalAttrs: GlobalAttributes;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Attributes
|
|
121
|
-
*/
|
|
122
|
-
attributes: Record<string, Attribute>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* WAI-ARIA role and properties
|
|
126
|
-
*/
|
|
127
|
-
aria: ARIA;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* If true, it is possible to add any properties as attributes,
|
|
131
|
-
* for example, when using a template engine or a view language.
|
|
132
|
-
*
|
|
133
|
-
* @see https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots
|
|
134
|
-
*
|
|
135
|
-
* **It assumes to specify it on the parser plugin.**
|
|
136
|
-
*/
|
|
137
|
-
possibleToAddProperties?: true;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
type ElementSpecOmission = false | ElementSpecOmissionTags;
|
|
141
|
-
|
|
142
|
-
type ElementSpecOmissionTags = {
|
|
143
|
-
startTag: boolean | ElementCondition;
|
|
144
|
-
endTag: boolean | ElementCondition;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
type ElementCondition = {
|
|
148
|
-
__WIP__: 'WORK_IN_PROGRESS';
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export type Attribute = {
|
|
152
|
-
name: string;
|
|
153
|
-
type: AttributeType | AttributeType[];
|
|
154
|
-
description?: string;
|
|
155
|
-
caseSensitive?: true;
|
|
156
|
-
experimental?: boolean;
|
|
157
|
-
obsolete?: true;
|
|
158
|
-
deprecated?: boolean;
|
|
159
|
-
nonStandard?: true;
|
|
160
|
-
} & ExtendableAttributeSpec;
|
|
161
|
-
|
|
162
|
-
type ExtendableAttributeSpec = Omit<AttributeJSON, 'type'>;
|
|
163
|
-
|
|
164
|
-
export type ARIARole = {
|
|
165
|
-
name: string;
|
|
166
|
-
isAbstract: boolean;
|
|
167
|
-
requiredContextRole: string[];
|
|
168
|
-
requiredOwnedElements: string[];
|
|
169
|
-
accessibleNameRequired: boolean;
|
|
170
|
-
accessibleNameFromAuthor: boolean;
|
|
171
|
-
accessibleNameFromContent: boolean;
|
|
172
|
-
accessibleNameProhibited: boolean;
|
|
173
|
-
childrenPresentational: boolean;
|
|
174
|
-
ownedProperties: ARIARoleOwnedProperties[];
|
|
175
|
-
prohibitedProperties: string[];
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export type ARIARoleInSchema = Partial<
|
|
179
|
-
ARIARole & {
|
|
180
|
-
description: string;
|
|
181
|
-
generalization: string[];
|
|
182
|
-
}
|
|
183
|
-
> & {
|
|
184
|
-
name: string;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export type ARIARoleOwnedProperties = {
|
|
188
|
-
name: string;
|
|
189
|
-
inherited?: true;
|
|
190
|
-
required?: true;
|
|
191
|
-
deprecated?: true;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export type ARIAProperty = {
|
|
195
|
-
name: string;
|
|
196
|
-
type: 'property' | 'state';
|
|
197
|
-
deprecated?: true;
|
|
198
|
-
isGlobal?: true;
|
|
199
|
-
value: ARIAAttributeValue;
|
|
200
|
-
conditionalValue?: {
|
|
201
|
-
role: string[];
|
|
202
|
-
value: ARIAAttributeValue;
|
|
203
|
-
}[];
|
|
204
|
-
enum: string[];
|
|
205
|
-
defaultValue?: string;
|
|
206
|
-
equivalentHtmlAttrs?: EquivalentHtmlAttr[];
|
|
207
|
-
valueDescriptions?: Record<string, string>;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export type ARIAAttributeValue =
|
|
211
|
-
| 'true/false'
|
|
212
|
-
| 'tristate'
|
|
213
|
-
| 'true/false/undefined'
|
|
214
|
-
| 'ID reference'
|
|
215
|
-
| 'ID reference list'
|
|
216
|
-
| 'integer'
|
|
217
|
-
| 'number'
|
|
218
|
-
| 'string'
|
|
219
|
-
| 'token'
|
|
220
|
-
| 'token list'
|
|
221
|
-
| 'URI';
|
|
222
|
-
|
|
223
|
-
export type ARIAVersion = '1.1' | '1.2';
|
|
224
|
-
|
|
225
|
-
export type EquivalentHtmlAttr = {
|
|
226
|
-
htmlAttrName: string;
|
|
227
|
-
isNotStrictEquivalent?: true;
|
|
228
|
-
value: string | null;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export type Matches = (selector: string) => boolean;
|
|
232
|
-
|
|
233
|
-
export type ComputedRole = {
|
|
234
|
-
el: Element;
|
|
235
|
-
role:
|
|
236
|
-
| (ARIARole & {
|
|
237
|
-
superClassRoles: ARIARoleInSchema[];
|
|
238
|
-
isImplicit?: boolean;
|
|
239
|
-
})
|
|
240
|
-
| null;
|
|
241
|
-
errorType?: RoleComputationError;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type RoleComputationError =
|
|
245
|
-
| 'ABSTRACT'
|
|
246
|
-
| 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL'
|
|
247
|
-
| 'IMPLICIT_ROLE_NAMESPACE_ERROR'
|
|
248
|
-
| 'INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
|
|
249
|
-
| 'INVALID_LANDMARK'
|
|
250
|
-
| 'INVALID_REQUIRED_CONTEXT_ROLE'
|
|
251
|
-
| 'NO_EXPLICIT'
|
|
252
|
-
| 'NO_OWNER'
|
|
253
|
-
| 'NO_PERMITTED'
|
|
254
|
-
| 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
|
|
255
|
-
| 'ROLE_NO_EXISTS';
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export type PermittedContentPattern =
|
|
9
|
-
| PermittedContentRequire
|
|
10
|
-
| PermittedContentOptional
|
|
11
|
-
| PermittedContentOneOrMore
|
|
12
|
-
| PermittedContentZeroOrMore
|
|
13
|
-
| PermittedContentChoice
|
|
14
|
-
| PermittedContentTransparent;
|
|
15
|
-
export type Model = ContentType | ContentType[];
|
|
16
|
-
export type ContentType = string | Category;
|
|
17
|
-
export type Category =
|
|
18
|
-
| '#text'
|
|
19
|
-
| '#phrasing'
|
|
20
|
-
| '#flow'
|
|
21
|
-
| '#interactive'
|
|
22
|
-
| '#heading'
|
|
23
|
-
| '#sectioning'
|
|
24
|
-
| '#metadata'
|
|
25
|
-
| '#embedded'
|
|
26
|
-
| '#palpable'
|
|
27
|
-
| '#script-supporting'
|
|
28
|
-
| '#SVGAnimation'
|
|
29
|
-
| '#SVGBasicShapes'
|
|
30
|
-
| '#SVGContainer'
|
|
31
|
-
| '#SVGDescriptive'
|
|
32
|
-
| '#SVGFilterPrimitive'
|
|
33
|
-
| '#SVGFont'
|
|
34
|
-
| '#SVGGradient'
|
|
35
|
-
| '#SVGGraphics'
|
|
36
|
-
| '#SVGGraphicsReferencing'
|
|
37
|
-
| '#SVGLightSource'
|
|
38
|
-
| '#SVGNeverRendered'
|
|
39
|
-
| '#SVGNone'
|
|
40
|
-
| '#SVGPaintServer'
|
|
41
|
-
| '#SVGRenderable'
|
|
42
|
-
| '#SVGShape'
|
|
43
|
-
| '#SVGStructural'
|
|
44
|
-
| '#SVGStructurallyExternal'
|
|
45
|
-
| '#SVGTextContent'
|
|
46
|
-
| '#SVGTextContentChild';
|
|
47
|
-
|
|
48
|
-
export interface ContentModelsSchema {
|
|
49
|
-
__contentModel?: ContentModel;
|
|
50
|
-
}
|
|
51
|
-
export interface ContentModel {
|
|
52
|
-
contents: PermittedContentPattern[] | boolean;
|
|
53
|
-
descendantOf?: string;
|
|
54
|
-
conditional?: {
|
|
55
|
-
condition: string;
|
|
56
|
-
contents: PermittedContentPattern[] | boolean;
|
|
57
|
-
}[];
|
|
58
|
-
}
|
|
59
|
-
export interface PermittedContentRequire {
|
|
60
|
-
require: Model;
|
|
61
|
-
max?: number;
|
|
62
|
-
min?: number;
|
|
63
|
-
_TODO_?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface PermittedContentOptional {
|
|
66
|
-
optional: Model;
|
|
67
|
-
max?: number;
|
|
68
|
-
_TODO_?: string;
|
|
69
|
-
}
|
|
70
|
-
export interface PermittedContentOneOrMore {
|
|
71
|
-
oneOrMore: Model | PermittedContentPattern[];
|
|
72
|
-
max?: number;
|
|
73
|
-
_TODO_?: string;
|
|
74
|
-
}
|
|
75
|
-
export interface PermittedContentZeroOrMore {
|
|
76
|
-
zeroOrMore: Model | PermittedContentPattern[];
|
|
77
|
-
max?: number;
|
|
78
|
-
_TODO_?: string;
|
|
79
|
-
}
|
|
80
|
-
export interface PermittedContentChoice {
|
|
81
|
-
/**
|
|
82
|
-
* @minItems 2
|
|
83
|
-
* @maxItems 5
|
|
84
|
-
*/
|
|
85
|
-
choice:
|
|
86
|
-
| [PermittedContentPattern[], PermittedContentPattern[]]
|
|
87
|
-
| [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
|
|
88
|
-
| [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
|
|
89
|
-
| [
|
|
90
|
-
PermittedContentPattern[],
|
|
91
|
-
PermittedContentPattern[],
|
|
92
|
-
PermittedContentPattern[],
|
|
93
|
-
PermittedContentPattern[],
|
|
94
|
-
PermittedContentPattern[],
|
|
95
|
-
];
|
|
96
|
-
_TODO_?: string;
|
|
97
|
-
}
|
|
98
|
-
export interface PermittedContentTransparent {
|
|
99
|
-
transparent: string;
|
|
100
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export type PermittedContentPattern =
|
|
9
|
-
| PermittedContentRequire
|
|
10
|
-
| PermittedContentOptional
|
|
11
|
-
| PermittedContentOneOrMore
|
|
12
|
-
| PermittedContentZeroOrMore
|
|
13
|
-
| PermittedContentChoice
|
|
14
|
-
| PermittedContentTransparent;
|
|
15
|
-
export type Model = ContentType | ContentType[];
|
|
16
|
-
export type ContentType = string | Category;
|
|
17
|
-
export type Category =
|
|
18
|
-
| '#text'
|
|
19
|
-
| '#phrasing'
|
|
20
|
-
| '#flow'
|
|
21
|
-
| '#interactive'
|
|
22
|
-
| '#heading'
|
|
23
|
-
| '#sectioning'
|
|
24
|
-
| '#metadata'
|
|
25
|
-
| '#embedded'
|
|
26
|
-
| '#palpable'
|
|
27
|
-
| '#script-supporting'
|
|
28
|
-
| '#SVGAnimation'
|
|
29
|
-
| '#SVGBasicShapes'
|
|
30
|
-
| '#SVGContainer'
|
|
31
|
-
| '#SVGDescriptive'
|
|
32
|
-
| '#SVGFilterPrimitive'
|
|
33
|
-
| '#SVGFont'
|
|
34
|
-
| '#SVGGradient'
|
|
35
|
-
| '#SVGGraphics'
|
|
36
|
-
| '#SVGGraphicsReferencing'
|
|
37
|
-
| '#SVGLightSource'
|
|
38
|
-
| '#SVGNeverRendered'
|
|
39
|
-
| '#SVGNone'
|
|
40
|
-
| '#SVGPaintServer'
|
|
41
|
-
| '#SVGRenderable'
|
|
42
|
-
| '#SVGShape'
|
|
43
|
-
| '#SVGStructural'
|
|
44
|
-
| '#SVGStructurallyExternal'
|
|
45
|
-
| '#SVGTextContent'
|
|
46
|
-
| '#SVGTextContentChild';
|
|
47
|
-
|
|
48
|
-
export interface ContentModelsSchema {
|
|
49
|
-
__contentModel?: ContentModel;
|
|
50
|
-
}
|
|
51
|
-
export interface ContentModel {
|
|
52
|
-
contents: PermittedContentPattern[] | boolean;
|
|
53
|
-
descendantOf?: string;
|
|
54
|
-
conditional?: {
|
|
55
|
-
condition: string;
|
|
56
|
-
contents: PermittedContentPattern[] | boolean;
|
|
57
|
-
}[];
|
|
58
|
-
}
|
|
59
|
-
export interface PermittedContentRequire {
|
|
60
|
-
require: Model;
|
|
61
|
-
max?: number;
|
|
62
|
-
min?: number;
|
|
63
|
-
_TODO_?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface PermittedContentOptional {
|
|
66
|
-
optional: Model;
|
|
67
|
-
max?: number;
|
|
68
|
-
_TODO_?: string;
|
|
69
|
-
}
|
|
70
|
-
export interface PermittedContentOneOrMore {
|
|
71
|
-
oneOrMore: Model | PermittedContentPattern[];
|
|
72
|
-
max?: number;
|
|
73
|
-
_TODO_?: string;
|
|
74
|
-
}
|
|
75
|
-
export interface PermittedContentZeroOrMore {
|
|
76
|
-
zeroOrMore: Model | PermittedContentPattern[];
|
|
77
|
-
max?: number;
|
|
78
|
-
_TODO_?: string;
|
|
79
|
-
}
|
|
80
|
-
export interface PermittedContentChoice {
|
|
81
|
-
choice:
|
|
82
|
-
| [PermittedContentPattern[], PermittedContentPattern[]]
|
|
83
|
-
| [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
|
|
84
|
-
| [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
|
|
85
|
-
| [
|
|
86
|
-
PermittedContentPattern[],
|
|
87
|
-
PermittedContentPattern[],
|
|
88
|
-
PermittedContentPattern[],
|
|
89
|
-
PermittedContentPattern[],
|
|
90
|
-
PermittedContentPattern[],
|
|
91
|
-
];
|
|
92
|
-
_TODO_?: string;
|
|
93
|
-
}
|
|
94
|
-
export interface PermittedContentTransparent {
|
|
95
|
-
transparent: string;
|
|
96
|
-
}
|
package/src/utils/get-ns.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Namespace } from '@markuplint/ml-ast';
|
|
2
|
-
|
|
3
|
-
export function getNS(namespaceURI: string | null): Namespace {
|
|
4
|
-
switch (namespaceURI) {
|
|
5
|
-
case 'http://www.w3.org/2000/svg': {
|
|
6
|
-
return 'svg';
|
|
7
|
-
}
|
|
8
|
-
case 'http://www.w3.org/1998/Math/MathML': {
|
|
9
|
-
return 'mml';
|
|
10
|
-
}
|
|
11
|
-
case 'http://www.w3.org/1999/xlink': {
|
|
12
|
-
return 'xlink';
|
|
13
|
-
}
|
|
14
|
-
default: {
|
|
15
|
-
return 'html';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/utils/merge-array.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type NamedDefinition = string | { name: string };
|
|
2
|
-
|
|
3
|
-
export function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[] {
|
|
4
|
-
if (!b) {
|
|
5
|
-
return a;
|
|
6
|
-
}
|
|
7
|
-
const result: T[] = a.slice();
|
|
8
|
-
for (const bItem of b) {
|
|
9
|
-
const bName = getName(bItem);
|
|
10
|
-
const aIndex = result.findIndex(item => getName(item) === bName);
|
|
11
|
-
if (aIndex === -1) {
|
|
12
|
-
result.push(bItem);
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const aItem = result.splice(aIndex, 1)[0];
|
|
16
|
-
if (typeof bItem === 'string') {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (typeof aItem === 'string') {
|
|
20
|
-
result.push(bItem);
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const exItem = {
|
|
24
|
-
...(aItem as { name: string }),
|
|
25
|
-
...(bItem as { name: string }),
|
|
26
|
-
};
|
|
27
|
-
result.push(exItem as T);
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getName(def: NamedDefinition): string {
|
|
33
|
-
const result = typeof def === 'string' ? def : def.name;
|
|
34
|
-
return result.toLowerCase().trim();
|
|
35
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { resolveNamespace } from './resolve-namespace';
|
|
2
|
-
|
|
3
|
-
test('tag', () => {
|
|
4
|
-
expect(resolveNamespace('a')).toStrictEqual({
|
|
5
|
-
localName: 'a',
|
|
6
|
-
localNameWithNS: 'a',
|
|
7
|
-
namespace: 'html',
|
|
8
|
-
namespaceURI: 'http://www.w3.org/1999/xhtml',
|
|
9
|
-
});
|
|
10
|
-
expect(resolveNamespace('svg:a')).toStrictEqual({
|
|
11
|
-
localName: 'a',
|
|
12
|
-
localNameWithNS: 'svg:a',
|
|
13
|
-
namespace: 'svg',
|
|
14
|
-
namespaceURI: 'http://www.w3.org/2000/svg',
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('attr', () => {
|
|
19
|
-
expect(resolveNamespace('href', 'http://www.w3.org/1999/xhtml')).toStrictEqual({
|
|
20
|
-
localName: 'href',
|
|
21
|
-
localNameWithNS: 'href',
|
|
22
|
-
namespace: 'html',
|
|
23
|
-
namespaceURI: 'http://www.w3.org/1999/xhtml',
|
|
24
|
-
});
|
|
25
|
-
expect(resolveNamespace('href', 'http://www.w3.org/2000/svg')).toStrictEqual({
|
|
26
|
-
localName: 'href',
|
|
27
|
-
localNameWithNS: 'svg:href',
|
|
28
|
-
namespace: 'svg',
|
|
29
|
-
namespaceURI: 'http://www.w3.org/2000/svg',
|
|
30
|
-
});
|
|
31
|
-
expect(resolveNamespace('xlink:href', 'http://www.w3.org/2000/svg')).toStrictEqual({
|
|
32
|
-
localName: 'href',
|
|
33
|
-
localNameWithNS: 'xlink:href',
|
|
34
|
-
namespace: 'xlink',
|
|
35
|
-
namespaceURI: 'http://www.w3.org/1999/xlink',
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { NamespaceURI, Namespace } from '@markuplint/ml-ast';
|
|
2
|
-
|
|
3
|
-
import { getNS } from './get-ns';
|
|
4
|
-
|
|
5
|
-
const cache = new Map<string, NamespacedElementName>();
|
|
6
|
-
|
|
7
|
-
type NamespacedElementName = {
|
|
8
|
-
localNameWithNS: string;
|
|
9
|
-
localName: string;
|
|
10
|
-
namespace: Namespace;
|
|
11
|
-
namespaceURI: NamespaceURI;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const namespaceURIMap: Record<Namespace, NamespaceURI> = {
|
|
15
|
-
html: 'http://www.w3.org/1999/xhtml',
|
|
16
|
-
svg: 'http://www.w3.org/2000/svg',
|
|
17
|
-
mml: 'http://www.w3.org/1998/Math/MathML',
|
|
18
|
-
xlink: 'http://www.w3.org/1999/xlink',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function resolveNamespace(name: string, namespaceURI: string | null = 'http://www.w3.org/1999/xhtml') {
|
|
22
|
-
const cached = cache.get(name + namespaceURI);
|
|
23
|
-
if (cached) {
|
|
24
|
-
return cached;
|
|
25
|
-
}
|
|
26
|
-
const [_explicitNS, _localName] = name.split(':');
|
|
27
|
-
const explicitNS = _localName ? _explicitNS : null;
|
|
28
|
-
const localName = _localName ?? _explicitNS;
|
|
29
|
-
const namespace =
|
|
30
|
-
(['html', 'svg', 'mml', 'xlink'] as const).find(_ns => _ns === (explicitNS || getNS(namespaceURI || null))) ||
|
|
31
|
-
'html';
|
|
32
|
-
const result: NamespacedElementName = {
|
|
33
|
-
localNameWithNS: `${namespace === 'html' ? '' : `${namespace}:`}${localName}`,
|
|
34
|
-
localName,
|
|
35
|
-
namespace,
|
|
36
|
-
namespaceURI: namespaceURIMap[namespace],
|
|
37
|
-
};
|
|
38
|
-
cache.set(name + namespaceURI, result);
|
|
39
|
-
return result;
|
|
40
|
-
}
|
package/tsconfig.test.json
DELETED