@markuplint/ml-spec 1.5.0 → 2.0.0-dev.26
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/README.md +3 -3
- package/lib/attributes.d.ts +31 -0
- package/lib/attributes.js +8 -0
- package/lib/get-ns.d.ts +1 -0
- package/lib/get-ns.js +17 -0
- package/lib/get-spec-by-tag-name.d.ts +2 -2
- package/lib/get-spec-by-tag-name.js +2 -3
- package/lib/get-spec.d.ts +3 -3
- package/lib/get-spec.js +13 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -14
- package/lib/permitted-structres.d.ts +1 -1
- package/lib/types.d.ts +27 -12
- package/lib/utils.js +4 -1
- package/package.json +9 -5
- package/schemas/attributes.schema.json +196 -55
- package/schemas/global-attributes.schema.json +12 -0
- package/schemas/permitted-structures.schema.json +34 -2
- package/src/attributes.ts +140 -0
- package/src/get-ns.ts +13 -0
- package/src/get-spec-by-tag-name.ts +3 -4
- package/src/get-spec.spec.ts +4 -1
- package/src/get-spec.ts +7 -3
- package/src/index.ts +2 -0
- package/src/permitted-structres.ts +21 -1
- package/src/types.ts +29 -51
- package/tsconfig.test.json +1 -6
- package/tsconfig.tsbuildinfo +1 -2820
|
@@ -3,10 +3,22 @@
|
|
|
3
3
|
"Node": {
|
|
4
4
|
"oneOf": [
|
|
5
5
|
{
|
|
6
|
+
"description": "HTML Element",
|
|
6
7
|
"type": "string",
|
|
7
|
-
"pattern": "^[a-z][a-z0-9]
|
|
8
|
+
"pattern": "^[a-z][a-z0-9]*$"
|
|
8
9
|
},
|
|
9
10
|
{
|
|
11
|
+
"description": "Namespaced HTML Element",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"pattern": "^html:[a-z][a-z0-9]*$"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"description": "SVG Element",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"pattern": "^svg:(?:[a-z][a-zA-Z0-9]*|[a-z][a-z0-9]*-[a-z][a-z0-9]*)$"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"description": "Text Node",
|
|
10
22
|
"type": "string",
|
|
11
23
|
"enum": ["#text"]
|
|
12
24
|
},
|
|
@@ -25,7 +37,27 @@
|
|
|
25
37
|
"#transparent",
|
|
26
38
|
"#embedded",
|
|
27
39
|
"#palpable",
|
|
28
|
-
"#script-supporting"
|
|
40
|
+
"#script-supporting",
|
|
41
|
+
"#SVGAnimation",
|
|
42
|
+
"#SVGBasicShapes",
|
|
43
|
+
"#SVGContainer",
|
|
44
|
+
"#SVGDescriptive",
|
|
45
|
+
"#SVGFilterPrimitive",
|
|
46
|
+
"#SVGFont",
|
|
47
|
+
"#SVGGradient",
|
|
48
|
+
"#SVGGraphics",
|
|
49
|
+
"#SVGGraphicsReferencing",
|
|
50
|
+
"#SVGLightSource",
|
|
51
|
+
"#SVGNeverRendered",
|
|
52
|
+
"#SVGNone",
|
|
53
|
+
"#SVGPaintServer",
|
|
54
|
+
"#SVGRenderable",
|
|
55
|
+
"#SVGShape",
|
|
56
|
+
"#SVGStructural",
|
|
57
|
+
"#SVGStructurallyExternal",
|
|
58
|
+
"#SVGTextContent",
|
|
59
|
+
"#SVGTextContentChild",
|
|
60
|
+
"#SVGOtherXMLNamespace"
|
|
29
61
|
]
|
|
30
62
|
},
|
|
31
63
|
"Target": {
|
|
@@ -0,0 +1,140 @@
|
|
|
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 AttributeType =
|
|
9
|
+
| (
|
|
10
|
+
| 'String'
|
|
11
|
+
| 'NonEmptyString'
|
|
12
|
+
| 'Boolean'
|
|
13
|
+
| 'Function'
|
|
14
|
+
| 'Date'
|
|
15
|
+
| 'Int'
|
|
16
|
+
| 'Uint'
|
|
17
|
+
| 'Float'
|
|
18
|
+
| 'NonZeroUint'
|
|
19
|
+
| 'ZeroToOne'
|
|
20
|
+
| 'AcceptList'
|
|
21
|
+
| 'AutoComplete'
|
|
22
|
+
| 'BCP47'
|
|
23
|
+
| 'Color'
|
|
24
|
+
| 'ColSpan'
|
|
25
|
+
| 'Coords'
|
|
26
|
+
| 'Crossorigin'
|
|
27
|
+
| 'DateTime'
|
|
28
|
+
| 'Destination'
|
|
29
|
+
| 'DOMID'
|
|
30
|
+
| 'DOMIDList'
|
|
31
|
+
| 'IRI'
|
|
32
|
+
| 'ItemType'
|
|
33
|
+
| 'LinkSizes'
|
|
34
|
+
| 'LinkType'
|
|
35
|
+
| 'LinkTypeList'
|
|
36
|
+
| 'MediaQuery'
|
|
37
|
+
| 'MediaQueryList'
|
|
38
|
+
| 'MIMEType'
|
|
39
|
+
| 'ReferrerPolicy'
|
|
40
|
+
| 'RowSpan'
|
|
41
|
+
| 'SourceSizeList'
|
|
42
|
+
| 'SrcSet'
|
|
43
|
+
| 'TabIndex'
|
|
44
|
+
| 'Target'
|
|
45
|
+
| 'URL'
|
|
46
|
+
| 'URLHash'
|
|
47
|
+
| 'URLList'
|
|
48
|
+
| 'CSSAngle'
|
|
49
|
+
| 'CSSBlendMode'
|
|
50
|
+
| 'CSSClipPath'
|
|
51
|
+
| 'CSSCustomIdent'
|
|
52
|
+
| 'CSSDisplay'
|
|
53
|
+
| 'CSSFilter'
|
|
54
|
+
| 'CSSFontFamily'
|
|
55
|
+
| 'CSSFontSize'
|
|
56
|
+
| 'CSSFontVariant'
|
|
57
|
+
| 'CSSFontWeight'
|
|
58
|
+
| 'CSSMask'
|
|
59
|
+
| 'CSSOpacity'
|
|
60
|
+
| 'CSSTextDecoration'
|
|
61
|
+
| 'CSSTransformList'
|
|
62
|
+
| 'CSSTransformOrigin'
|
|
63
|
+
| 'CSSURL'
|
|
64
|
+
| 'SVGAnimatableValue'
|
|
65
|
+
| 'SVGBeginValueList'
|
|
66
|
+
| 'SVGClockValue'
|
|
67
|
+
| 'SVGColorMatrix'
|
|
68
|
+
| 'SVGDashArray'
|
|
69
|
+
| 'SVGEndValueList'
|
|
70
|
+
| 'SVGFilterPrimitiveReference'
|
|
71
|
+
| 'SVGKernelMatrix'
|
|
72
|
+
| 'SVGKeyPoints'
|
|
73
|
+
| 'SVGKeySplines'
|
|
74
|
+
| 'SVGKeyTimes'
|
|
75
|
+
| 'SVGLanguageTags'
|
|
76
|
+
| 'SVGLength'
|
|
77
|
+
| 'SVGLengthList'
|
|
78
|
+
| 'SVGNumberList'
|
|
79
|
+
| 'SVGNumberOptionalNumber'
|
|
80
|
+
| 'SVGOrigin'
|
|
81
|
+
| 'SVGPaint'
|
|
82
|
+
| 'SVGPathCommands'
|
|
83
|
+
| 'SVGPercentage'
|
|
84
|
+
| 'SVGPercentageList'
|
|
85
|
+
| 'SVGPoints'
|
|
86
|
+
| 'SVGPreserveAspectRatio'
|
|
87
|
+
| 'SVGViewBox'
|
|
88
|
+
)
|
|
89
|
+
| {
|
|
90
|
+
enum: string[];
|
|
91
|
+
};
|
|
92
|
+
export type AttributeCondition =
|
|
93
|
+
| {
|
|
94
|
+
ancestor: string;
|
|
95
|
+
}
|
|
96
|
+
| {
|
|
97
|
+
self: string | string[];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export interface AttributesSchema {
|
|
101
|
+
tag: string;
|
|
102
|
+
attributes: (
|
|
103
|
+
| (
|
|
104
|
+
| '#globalAttrs'
|
|
105
|
+
| '#ariaAttrs'
|
|
106
|
+
| '#SVGAnimationAdditionAttrs'
|
|
107
|
+
| '#SVGAnimationAttributeTargetAttrs'
|
|
108
|
+
| '#SVGAnimationEventAttrs'
|
|
109
|
+
| '#SVGAnimationTargetElementAttrs'
|
|
110
|
+
| '#SVGAnimationTimingAttrs'
|
|
111
|
+
| '#SVGAnimationValueAttrs'
|
|
112
|
+
| '#SVGConditionalProcessingAttrs'
|
|
113
|
+
| '#SVGCoreAttrs'
|
|
114
|
+
| '#SVGDocumentElementEventAttrs'
|
|
115
|
+
| '#SVGDocumentEventAttrs'
|
|
116
|
+
| '#SVGFilterPrimitiveAttrs'
|
|
117
|
+
| '#SVGGlobalEventAttrs'
|
|
118
|
+
| '#SVGGraphicalEventAttrs'
|
|
119
|
+
| '#SVGPresentationAttrs'
|
|
120
|
+
| '#SVGTransferFunctionAttrs'
|
|
121
|
+
| '#XLinkAttrs'
|
|
122
|
+
)
|
|
123
|
+
| AttributeJSON
|
|
124
|
+
| DefineDefaultAttributeType
|
|
125
|
+
)[];
|
|
126
|
+
}
|
|
127
|
+
export interface AttributeJSON {
|
|
128
|
+
name: string;
|
|
129
|
+
type: AttributeType | [AttributeType, ...AttributeType[]];
|
|
130
|
+
defaultValue?: string;
|
|
131
|
+
deprecated?: boolean;
|
|
132
|
+
required?: boolean | AttributeCondition;
|
|
133
|
+
requiredEither?: string[];
|
|
134
|
+
noUse?: boolean;
|
|
135
|
+
condition?: AttributeCondition;
|
|
136
|
+
}
|
|
137
|
+
export interface DefineDefaultAttributeType {
|
|
138
|
+
name: string;
|
|
139
|
+
defaultValue: string;
|
|
140
|
+
}
|
package/src/get-ns.ts
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attribute, MLDOMElementSpec, MLMLSpec, SpecOM } from './types';
|
|
1
|
+
import type { Attribute, MLDOMElementSpec, MLMLSpec, SpecOM } from './types';
|
|
2
2
|
|
|
3
3
|
function getSpecOM({ specs }: MLMLSpec): SpecOM {
|
|
4
4
|
const som: SpecOM = {};
|
|
@@ -18,8 +18,7 @@ function getSpecOM({ specs }: MLMLSpec): SpecOM {
|
|
|
18
18
|
return som;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function getSpecByTagName(
|
|
21
|
+
export function getSpecByTagName(nameWithNS: string, specs: MLMLSpec): MLDOMElementSpec | null {
|
|
22
22
|
const specOM = getSpecOM(specs);
|
|
23
|
-
|
|
24
|
-
return specOM[tagName] || null;
|
|
23
|
+
return specOM[nameWithNS] || null;
|
|
25
24
|
}
|
package/src/get-spec.spec.ts
CHANGED
package/src/get-spec.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ElementSpec, ExtendedSpec, MLMLSpec } from '
|
|
1
|
+
import type { ElementSpec, ExtendedSpec, MLMLSpec } from './types';
|
|
2
|
+
|
|
2
3
|
import { mergeArray } from './utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -19,8 +20,11 @@ export function getSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]) {
|
|
|
19
20
|
if (extendedSpec.def['#ariaAttrs']) {
|
|
20
21
|
result.def['#ariaAttrs'] = [...result.def['#ariaAttrs'], ...extendedSpec.def['#ariaAttrs']];
|
|
21
22
|
}
|
|
22
|
-
if (extendedSpec.def['#globalAttrs']) {
|
|
23
|
-
result.def['#globalAttrs']
|
|
23
|
+
if (extendedSpec.def['#globalAttrs']?.['#extends']) {
|
|
24
|
+
result.def['#globalAttrs']['#HTMLGlobalAttrs'] = [
|
|
25
|
+
...(result.def['#globalAttrs']?.['#HTMLGlobalAttrs'] || []),
|
|
26
|
+
...(extendedSpec.def['#globalAttrs']?.['#extends'] || []),
|
|
27
|
+
];
|
|
24
28
|
}
|
|
25
29
|
if (extendedSpec.def['#roles']) {
|
|
26
30
|
result.def['#roles'] = [...result.def['#roles'], ...extendedSpec.def['#roles']];
|
package/src/index.ts
CHANGED
|
@@ -24,7 +24,27 @@ export type ContentModel =
|
|
|
24
24
|
| '#transparent'
|
|
25
25
|
| '#embedded'
|
|
26
26
|
| '#palpable'
|
|
27
|
-
| '#script-supporting'
|
|
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
|
+
| '#SVGOtherXMLNamespace';
|
|
28
48
|
export type PermittedContentSpec = PermittedContent[];
|
|
29
49
|
|
|
30
50
|
export interface PermittedStructuresSchema {
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AttributeCondition, AttributeType } from './attributes';
|
|
2
|
+
import type { ContentModel, PermittedStructuresSchema } from './permitted-structres';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* markuplit Markup-language spec
|
|
@@ -23,9 +24,13 @@ export type ExtendedSpec = {
|
|
|
23
24
|
export type Cites = string[];
|
|
24
25
|
|
|
25
26
|
export type SpecDefs = {
|
|
26
|
-
'#globalAttrs':
|
|
27
|
-
|
|
27
|
+
'#globalAttrs': Partial<{
|
|
28
|
+
'#extends': Attribute[];
|
|
29
|
+
'#HTMLGlobalAttrs': Attribute[];
|
|
30
|
+
[OtherGlobalAttrs: string]: Attribute[];
|
|
31
|
+
}>;
|
|
28
32
|
'#ariaAttrs': ARIAAttribute[];
|
|
33
|
+
'#roles': ARIRRoleAttribute[];
|
|
29
34
|
'#contentModels': { [model in ContentModel]?: string[] };
|
|
30
35
|
};
|
|
31
36
|
|
|
@@ -38,6 +43,12 @@ export type ElementSpec = {
|
|
|
38
43
|
*/
|
|
39
44
|
name: string;
|
|
40
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Namespaces in XML
|
|
48
|
+
* @see https://www.w3.org/TR/xml-names/
|
|
49
|
+
*/
|
|
50
|
+
namespace?: 'http://www.w3.org/1999/xhtml' | 'http://www.w3.org/2000/svg' | 'http://www.w3.org/1998/Math/MathML';
|
|
51
|
+
|
|
41
52
|
/**
|
|
42
53
|
* Reference URL
|
|
43
54
|
*/
|
|
@@ -141,64 +152,19 @@ type ElementCondition = {
|
|
|
141
152
|
|
|
142
153
|
export type Attribute = {
|
|
143
154
|
name: string;
|
|
144
|
-
type: AttributeType;
|
|
155
|
+
type: AttributeType | [AttributeType, ...AttributeType[]];
|
|
145
156
|
description: string;
|
|
146
157
|
caseSensitive?: true;
|
|
147
158
|
experimental?: true;
|
|
148
159
|
obsolete?: true;
|
|
149
|
-
deprecated?:
|
|
160
|
+
deprecated?: boolean;
|
|
150
161
|
nonStandard?: true;
|
|
151
|
-
required?:
|
|
162
|
+
required?: boolean | AttributeCondition;
|
|
152
163
|
requiredEither?: string[];
|
|
153
|
-
enum?: string[];
|
|
154
164
|
noUse?: boolean;
|
|
155
165
|
condition?: AttributeCondition;
|
|
156
166
|
};
|
|
157
167
|
|
|
158
|
-
export type AttributeCondition = {
|
|
159
|
-
ancestor?: string;
|
|
160
|
-
self?: string | string[];
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// type AttributeCtegory = 'global' | 'xml' | 'aria' | 'eventhandler' | 'form' | 'particular';
|
|
164
|
-
|
|
165
|
-
export type AttributeType =
|
|
166
|
-
| 'String'
|
|
167
|
-
| 'NonEmptyString'
|
|
168
|
-
| 'Boolean'
|
|
169
|
-
| 'Function' // JavaScript function body
|
|
170
|
-
| 'Date'
|
|
171
|
-
| 'Int' // Integer
|
|
172
|
-
| 'Uint' // Non-negative integer
|
|
173
|
-
| 'Float' // Floating-point number
|
|
174
|
-
| 'NonZeroUint' // Non-negative integer greater than zero
|
|
175
|
-
| 'AcceptList' // https://html.spec.whatwg.org/multipage/input.html#attr-input-accept
|
|
176
|
-
| 'AutoComplete' // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens
|
|
177
|
-
| 'BCP47' // https://tools.ietf.org/html/bcp47
|
|
178
|
-
| 'Color' // https://drafts.csswg.org/css-color/#typedef-color
|
|
179
|
-
| 'ColSpan' // https://html.spec.whatwg.org/multipage/tables.html#attr-tdth-colspan
|
|
180
|
-
| 'Coords' // https://html.spec.whatwg.org/multipage/image-maps.html#attr-area-coords
|
|
181
|
-
| 'DateTime' // https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value
|
|
182
|
-
| 'Destination' // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as
|
|
183
|
-
| 'DOMID'
|
|
184
|
-
| 'DOMIDList'
|
|
185
|
-
| 'ItemType' // https://html.spec.whatwg.org/multipage/microdata.html#attr-itemtype
|
|
186
|
-
| 'LinkSizes' // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes
|
|
187
|
-
| 'LinkType' // https://html.spec.whatwg.org/multipage/links.html#linkTypes
|
|
188
|
-
| 'LinkTypeList' // https://html.spec.whatwg.org/multipage/links.html#linkTypes
|
|
189
|
-
| 'MediaQuery' // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-media-query-list
|
|
190
|
-
| 'MediaQueryList' // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-media-query-list
|
|
191
|
-
| 'MIMEType' // https://mimesniff.spec.whatwg.org/#valid-mime-type
|
|
192
|
-
| 'ReferrerPolicy' // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#referrer-policy-attributes
|
|
193
|
-
| 'RowSpan' // https://html.spec.whatwg.org/multipage/tables.html#attr-tdth-rowspan
|
|
194
|
-
| 'SourceSizeList' // https://html.spec.whatwg.org/multipage/images.html#sizes-attributes
|
|
195
|
-
| 'SrcSet' // https://html.spec.whatwg.org/multipage/images.html#srcset-attribute
|
|
196
|
-
| 'TabIndex' // https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex
|
|
197
|
-
| 'Target' // https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-target
|
|
198
|
-
| 'URL' // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces
|
|
199
|
-
| 'URLHash' // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-hash-name-reference
|
|
200
|
-
| 'URLList'; // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces
|
|
201
|
-
|
|
202
168
|
export type ARIRRoleAttribute = {
|
|
203
169
|
name: string;
|
|
204
170
|
description: string;
|
|
@@ -227,8 +193,14 @@ export type ARIAAttribute = {
|
|
|
227
193
|
deprecated?: true;
|
|
228
194
|
isGlobal?: true;
|
|
229
195
|
value: ARIAAttributeValue;
|
|
196
|
+
conditionalValue?: {
|
|
197
|
+
role: string[];
|
|
198
|
+
value: ARIAAttributeValue;
|
|
199
|
+
}[];
|
|
230
200
|
enum: string[];
|
|
231
201
|
defaultValue?: string;
|
|
202
|
+
equivalentHtmlAttrs?: EquivalentHtmlAttr[];
|
|
203
|
+
valueDescriptions?: Record<string, string>;
|
|
232
204
|
};
|
|
233
205
|
|
|
234
206
|
export type ARIAAttributeValue =
|
|
@@ -244,6 +216,12 @@ export type ARIAAttributeValue =
|
|
|
244
216
|
| 'token list'
|
|
245
217
|
| 'URI';
|
|
246
218
|
|
|
219
|
+
export type EquivalentHtmlAttr = {
|
|
220
|
+
htmlAttrName: string;
|
|
221
|
+
isNotStrictEquivalent?: true;
|
|
222
|
+
value: string | null;
|
|
223
|
+
};
|
|
224
|
+
|
|
247
225
|
export interface SpecOM {
|
|
248
226
|
[tagName: string]: MLDOMElementSpec;
|
|
249
227
|
}
|