Skip to content

Commit

Permalink
Merge pull request #112 from YusukeHirao/features/mdn-update/20201109
Browse files Browse the repository at this point in the history
Update specs.
  • Loading branch information
YusukeHirao committed Nov 9, 2020
2 parents c3df548 + 094effa commit 94ff2ee
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 99 deletions.
12 changes: 6 additions & 6 deletions packages/@markuplint/html-spec/gen/html-elements.ts
Expand Up @@ -104,7 +104,7 @@ export async function getHTMLElement(link: string) {
return spec;
}

export function getAttributes($: CheerioStatic, heading: string, tagName: string): Attribute[] {
export function getAttributes($: cheerio.Root, heading: string, tagName: string): Attribute[] {
const $heading = $(heading);
const $outline = getThisOutline($, $heading);
const { attributes } = getAttribute(tagName);
Expand Down Expand Up @@ -162,7 +162,7 @@ export function getAttributes($: CheerioStatic, heading: string, tagName: string
return result;
}

function getProperty($: CheerioStatic, prop: string) {
function getProperty($: cheerio.Root, prop: string) {
const $tr = $('#wikiArticle table.properties tr') || $('#Technical_summary').next('table tr');
const $th = $(
$tr
Expand All @@ -177,7 +177,7 @@ function getProperty($: CheerioStatic, prop: string) {
.replace(/(?:\r?\n|\s)+/gi, ' ');
}

function getThisOutline($: CheerioStatic, $start: Cheerio) {
function getThisOutline($: cheerio.Root, $start: cheerio.Cheerio) {
const $container = $('<div></div>');
let $next = $start.next();
const els = [$start.clone()];
Expand All @@ -189,7 +189,7 @@ function getThisOutline($: CheerioStatic, $start: Cheerio) {
return $container;
}

function getItsHeading($start: Cheerio) {
function getItsHeading($start: cheerio.Cheerio) {
let $needle = upToPrevOrParent($start);
while ($needle.length) {
if (isHeading($needle)) {
Expand All @@ -200,15 +200,15 @@ function getItsHeading($start: Cheerio) {
return null;
}

function upToPrevOrParent($start: Cheerio) {
function upToPrevOrParent($start: cheerio.Cheerio) {
let $needle = $start.prev();
if (!$needle.length) {
$needle = $start.parent();
}
return $needle;
}

function isHeading($el: Cheerio) {
function isHeading($el: cheerio.Cheerio) {
return /^h[1-6]$/i.test($el[0].tagName);
}

Expand Down
118 changes: 47 additions & 71 deletions packages/@markuplint/html-spec/index.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/@markuplint/html-spec/package.json
Expand Up @@ -15,13 +15,13 @@
"gen": "ts-node gen/index.ts; prettier --write index.json"
},
"devDependencies": {
"@types/cheerio": "^0.22.18",
"@types/cli-progress": "^3.7.0",
"@types/cheerio": "^0.22.22",
"@types/cli-progress": "^3.8.0",
"@types/node-fetch": "^2.5.7",
"cheerio": "^1.0.0-rc.3",
"cli-progress": "^3.8.2",
"fast-xml-parser": "^3.17.2",
"node-fetch": "^2.6.0"
"fast-xml-parser": "^3.17.4",
"node-fetch": "^2.6.1"
},
"dependencies": {
"@markuplint/ml-spec": "^1.0.0-alpha.11"
Expand Down
5 changes: 0 additions & 5 deletions packages/@markuplint/html-spec/src/attributes/iframe.json
Expand Up @@ -55,11 +55,6 @@
"name": "referrerpolicy",
"type": "ReferrerPolicy"
},
{
"name": "importance",
"type": "String",
"enum": ["auto", "high", "low"]
},
{
"name": "loading",
"type": "String",
Expand Down
5 changes: 0 additions & 5 deletions packages/@markuplint/html-spec/src/attributes/img.json
Expand Up @@ -19,11 +19,6 @@
"name": "height",
"type": "Uint"
},
{
"name": "importance",
"type": "String",
"enum": ["auto", "high", "low"]
},
{
"name": "ismap",
"type": "Boolean",
Expand Down
8 changes: 0 additions & 8 deletions packages/@markuplint/html-spec/src/attributes/link.json
Expand Up @@ -65,14 +65,6 @@
"condition": {
"self": "[rel=mask-icon]"
}
},
{
"name": "importance",
"type": "String",
"enum": ["auto", "high", "low"],
"condition": {
"self": ["[rel=preload]", "[rel=prefetch]"]
}
}
]
}

0 comments on commit 94ff2ee

Please sign in to comment.