@markuplint/ml-spec
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -1,17 +0,4 @@ | ||
import { Attribute, MLMLSpec } from './types'; | ||
import { ContentModel, PermittedStructuresSchema } from './permitted-structres'; | ||
export * from './permitted-structres'; | ||
export * from './get-spec-by-tag-name'; | ||
export * from './get-spec'; | ||
export * from './types'; | ||
export interface SpecOM { | ||
[tagName: string]: MLDOMElementSpec; | ||
} | ||
export interface MLDOMElementSpec { | ||
experimental: boolean; | ||
obsolete: boolean | string; | ||
deprecated: boolean; | ||
nonStandard: boolean; | ||
categories: ContentModel[]; | ||
permittedStructures: PermittedStructuresSchema; | ||
attributes: Attribute[]; | ||
} | ||
export declare function getSpecByTagName(tagName: string, specs: MLMLSpec): MLDOMElementSpec | null; |
@@ -13,25 +13,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSpecByTagName = void 0; | ||
__exportStar(require("./permitted-structres"), exports); | ||
__exportStar(require("./get-spec-by-tag-name"), exports); | ||
__exportStar(require("./get-spec"), exports); | ||
__exportStar(require("./types"), exports); | ||
function getSpecOM({ specs }) { | ||
const som = {}; | ||
for (const el of specs) { | ||
som[el.name] = { | ||
experimental: !!el.experimental, | ||
obsolete: typeof el.obsolete === 'boolean' ? !!el.obsolete : el.obsolete ? el.obsolete.alt : false, | ||
deprecated: !!el.deprecated, | ||
nonStandard: !!el.nonStandard, | ||
categories: el.categories, | ||
permittedStructures: el.permittedStructures, | ||
attributes: el.attributes.filter((attr) => !(typeof attr === 'string')), | ||
}; | ||
} | ||
return som; | ||
} | ||
function getSpecByTagName(tagName, specs) { | ||
const specOM = getSpecOM(specs); | ||
tagName = tagName.toLowerCase(); | ||
return specOM[tagName] || null; | ||
} | ||
exports.getSpecByTagName = getSpecByTagName; |
@@ -10,6 +10,9 @@ import { ContentModel, PermittedStructuresSchema } from './permitted-structres'; | ||
} | ||
declare type ExtendedElementSpec = Partial<ElementSpec> & { | ||
name: ElementSpec['name']; | ||
}; | ||
export declare type ExtendedSpec = { | ||
cites?: Cites; | ||
def?: Partial<SpecDefs>; | ||
specs?: ElementSpec[]; | ||
specs?: ExtendedElementSpec[]; | ||
}; | ||
@@ -122,2 +125,3 @@ /** | ||
description: string; | ||
caseSensitive?: true; | ||
experimental?: true; | ||
@@ -168,2 +172,14 @@ obsolete?: true; | ||
export declare type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI'; | ||
export interface SpecOM { | ||
[tagName: string]: MLDOMElementSpec; | ||
} | ||
export interface MLDOMElementSpec { | ||
experimental: boolean; | ||
obsolete: boolean | string; | ||
deprecated: boolean; | ||
nonStandard: boolean; | ||
categories: ContentModel[]; | ||
permittedStructures: PermittedStructuresSchema; | ||
attributes: Attribute[]; | ||
} | ||
export {}; |
{ | ||
"name": "@markuplint/ml-spec", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "Types and schema that specs of the Markup languages for markuplint", | ||
@@ -24,3 +24,3 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
}, | ||
"gitHead": "b74f154408bb46b20973cba9d36a65042ba5043f" | ||
"gitHead": "361f6e18dbeb369e769e3b1ae8c97a006452938d" | ||
} |
@@ -1,43 +0,4 @@ | ||
import { Attribute, MLMLSpec } from './types'; | ||
import { ContentModel, PermittedStructuresSchema } from './permitted-structres'; | ||
export * from './permitted-structres'; | ||
export * from './get-spec-by-tag-name'; | ||
export * from './get-spec'; | ||
export * from './types'; | ||
export interface SpecOM { | ||
[tagName: string]: MLDOMElementSpec; | ||
} | ||
export interface MLDOMElementSpec { | ||
experimental: boolean; | ||
obsolete: boolean | string; | ||
deprecated: boolean; | ||
nonStandard: boolean; | ||
categories: ContentModel[]; | ||
permittedStructures: PermittedStructuresSchema; | ||
attributes: Attribute[]; | ||
} | ||
function getSpecOM({ specs }: MLMLSpec): SpecOM { | ||
const som: SpecOM = {}; | ||
for (const el of specs) { | ||
som[el.name] = { | ||
experimental: !!el.experimental, | ||
obsolete: typeof el.obsolete === 'boolean' ? !!el.obsolete : el.obsolete ? el.obsolete.alt : false, | ||
deprecated: !!el.deprecated, | ||
nonStandard: !!el.nonStandard, | ||
categories: el.categories, | ||
permittedStructures: el.permittedStructures, | ||
attributes: el.attributes.filter( | ||
(attr: Attribute | string): attr is Attribute => !(typeof attr === 'string'), | ||
), | ||
}; | ||
} | ||
return som; | ||
} | ||
export function getSpecByTagName(tagName: string, specs: MLMLSpec): MLDOMElementSpec | null { | ||
const specOM = getSpecOM(specs); | ||
tagName = tagName.toLowerCase(); | ||
return specOM[tagName] || null; | ||
} |
@@ -12,6 +12,8 @@ import { ContentModel, PermittedStructuresSchema } from './permitted-structres'; | ||
type ExtendedElementSpec = Partial<ElementSpec> & { name: ElementSpec['name'] }; | ||
export type ExtendedSpec = { | ||
cites?: Cites; | ||
def?: Partial<SpecDefs>; | ||
specs?: ElementSpec[]; | ||
specs?: ExtendedElementSpec[]; | ||
}; | ||
@@ -145,2 +147,3 @@ | ||
description: string; | ||
caseSensitive?: true; | ||
experimental?: true; | ||
@@ -245,1 +248,15 @@ obsolete?: true; | ||
| 'URI'; | ||
export interface SpecOM { | ||
[tagName: string]: MLDOMElementSpec; | ||
} | ||
export interface MLDOMElementSpec { | ||
experimental: boolean; | ||
obsolete: boolean | string; | ||
deprecated: boolean; | ||
nonStandard: boolean; | ||
categories: ContentModel[]; | ||
permittedStructures: PermittedStructuresSchema; | ||
attributes: Attribute[]; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213294
28
1930