# -*- coding: utf-8 -*-
import os
ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
template = """
"""
errors = {
# missing src on img
"img-no-src": "
",
"img-no-src-with-srcset": "
",
"img-no-src-with-picture": "
",
"img-no-src-with-srcset-and-picture": "
",
"img-no-src-with-source": "
",
# junk content in picture
"junk-text-before-img": "x
",
"junk-text-after-img": "
x",
"junk-text-before-source": "x
",
"junk-text-after-source": "x
",
"junk-br-before-img": "
",
"junk-br-after-img": "![](x)
",
"junk-br-before-source": "
",
"junk-br-after-source": "
",
"junk-video-before": "
",
"junk-video-no-img": "",
"junk-p-before": "
",
"junk-p-after": "
",
"junk-p-wrapping": "![](x)
",
"junk-span-before": "
",
"junk-span-after": "
",
"junk-span-wrapping": "
",
"junk-picture-before": "![](x)
",
"junk-picture-wrapping": "
",
"junk-figure-wrapping": "
",
"junk-input-type-hidden": "
",
"junk-style-scroped": "
",
"junk-noscript": "
",
"junk-noscript-after-source-no-img": "",
"junk-svg": "
",
"junk-svg-no-img": "",
"junk-math-nog-img": "",
# parents
"parent-ul": "
![](x)
",
"parent-dl": "![](x)
",
"parent-hgroup": "x
",
"parent-noscript-in-head": "",
# invalid html syntax
"html-syntax-source-end-tag": "
",
"html-syntax-img-end-tag": "
",
"html-syntax-picture-no-end-tag": "
",
"html-syntax-picture-slash": "
",
"html-syntax-picture-slash-no-end-tag": "
",
# missing img in picture
"missing-img-empty-picture": "",
"missing-img-only-source": "",
"missing-img-only-script": "",
"missing-img-script-and-source": "",
"missing-img-source-and-script": "",
# multiple img in picture
"multiple-img": "![](x)
",
"multiple-img-with-script": "![](x)
",
"multiple-img-with-source": "![](x)
",
"multiple-img-with-source-and-script": "![](x)
",
# source after img
"source-after-img": "
",
"source-before-and-after-img": "
",
# source with following sibling source element or img element with a srcset attribute
"always-matching-source-with-following-img-srcset": "
",
"always-matching-source-with-following-source-srcset": "
",
"always-matching-source-with-following-source-media": "
",
"always-matching-source-with-following-source-type": "
",
"always-matching-source-media-empty-with-following-source-srcset": "
",
"always-matching-source-media-spaces-with-following-source-srcset": "
",
"always-matching-source-media-all-with-following-source-srcset": "
",
"always-matching-source-media-uppercase-with-following-source-srcset": "
",
"always-matching-source-media-all-spaces-with-following-source-srcset": "
",
"always-matching-source-sizes-with-following-source-srcset": "
",
# sizes present
"img-srcset-no-descriptor-with-sizes": "
",
"img-srcset-w-and-x-width-sizes": "
",
"source-srcset-x-with-sizes": "
",
"source-srcset-h-with-sizes": "
",
"source-srcset-w-and-x-with-sizes": "
",
"img-with-sizes-no-srcset": "
",
# width descriptor without sizes
"img-srcset-w-no-sizes": "
",
"source-srcset-w-no-sizes": "
",
"source-type-srcset-w": "
",
# invalid attributes on source
"source-src": "
",
"source-src-srcset": "
",
"source-alt": "
",
"source-width": "
",
"source-height": "
",
"source-usemap": "
",
"source-ismap": "
",
"source-crossorigin": "
",
"source-name": "
",
"source-align": "
",
"source-hspace": "
",
"source-vspace": "
",
"source-longdesc": "
",
"source-border": "
",
# missing srcset on source
"source-no-srcset": "
",
"source-no-srcset-with-sizes": "
",
"source-no-srcset-with-media": "
",
"source-no-srcset-with-type": "
",
# invalid attributes on picture
"picture-src": "
",
"picture-srcset": "
",
"picture-media": "
",
"picture-sizes": "
",
"picture-alt": "
",
"picture-width": "
",
"picture-height": "
",
"picture-usemap": "
",
"picture-ismap": "
",
"picture-crossorigin": "
",
"picture-name": "
",
"picture-lowsrc": "
",
"picture-align": "
",
"picture-hspace": "
",
"picture-vspace": "
",
"picture-longdesc": "
",
"picture-border": "
",
# invalid attributes on source in video
"video-source-srcset": "",
"video-source-srcset-src": "",
"video-source-sizes-srcset": "",
"video-source-media-src": "",
# srcset on other elements
"link-rel-icon-srcset": "",
"input-type-image-srcset": "",
"object-srcset": "",
"video-srcset": "",
"audio-srcset": "",
"track-srcset": "",
"svg-image-srcset": "",
# invalid attributes on img
"img-type": "
",
"img-type-with-picture": "
",
# sizes microsyntax
"sizes-microsyntax-media-all": "
",
"sizes-microsyntax-media-all-and-min-width": "
",
"sizes-microsyntax-media-min-width-no-parenthesis": "
",
"sizes-microsyntax-media-general-enclosed-junk": "
",
"sizes-microsyntax-media-bad-junk": "
",
"sizes-microsyntax-two-defaults": "
",
"sizes-microsyntax-default-first": "
",
"sizes-microsyntax-trailing-comma": "
",
"sizes-microsyntax-trailing-junk": "
",
"sizes-microsyntax-junk-in-default": "
",
"sizes-microsyntax-junk-in-source-size": "
",
"sizes-microsyntax-percent-in-source-size-value": "
",
"sizes-microsyntax-no-unit-in-source-size-value": "
",
"sizes-microsyntax-deg-source-size-value": "
",
"sizes-microsyntax-grad-source-size-value": "
",
"sizes-microsyntax-rad-source-size-value": "
",
"sizes-microsyntax-turn-source-size-value": "
",
"sizes-microsyntax-s-source-size-value": "
",
"sizes-microsyntax-ms-source-size-value": "
",
"sizes-microsyntax-hz-source-size-value": "
",
"sizes-microsyntax-khz-source-size-value": "
",
"sizes-microsyntax-dpi-source-size-value": "
",
"sizes-microsyntax-dpcm-source-size-value": "
",
"sizes-microsyntax-dppx-source-size-value": "
",
"sizes-microsyntax-auto-source-size-value": "
",
"sizes-microsyntax-inherit-source-size-value": "
",
"sizes-microsyntax-initial-source-size-value": "
",
"sizes-microsyntax-default-source-size-value": "
",
"sizes-microsyntax-foo-bar-source-size-value": "
",
"sizes-microsyntax-negative-source-size-value": "
",
"sizes-microsyntax-empty": "
",
"sizes-microsyntax-comma": "
",
"sizes-microsyntax-css-comment-after-plus": "
",
"sizes-microsyntax-css-comment-before-unit": "
",
"sizes-microsyntax-scientific-notation-negative": "
",
"sizes-microsyntax-scientific-notation-non-integer-in-exponent": "
",
# srcset microsyntax
"srcset-microsyntax-leading-comma": "
",
"srcset-microsyntax-leading-comma-multiple": "
",
"srcset-microsyntax-trailing-comma": "
",
"srcset-microsyntax-trailing-comma-multiple": "
",
"srcset-microsyntax-broken-url": "
",
"srcset-microsyntax-non-integer-w": "
",
"srcset-microsyntax-uppercase-w": "
",
"srcset-microsyntax-plus-w": "
",
"srcset-microsyntax-scientific-notation-w": "
",
"srcset-microsyntax-zero-w": "
",
"srcset-microsyntax-negative-zero-w": "
",
"srcset-microsyntax-negative-w": "
",
"srcset-microsyntax-plus-x": "
",
"srcset-microsyntax-negative-x": "
",
"srcset-microsyntax-zero-x": "
",
"srcset-microsyntax-negative-zero-x": "
",
"srcset-microsyntax-leading-dot-x": "
",
"srcset-microsyntax-nan-x": "
",
"srcset-microsyntax-infinity-x": "
",
"srcset-microsyntax-x-and-w": "
",
"srcset-microsyntax-x-and-h": "
",
"srcset-microsyntax-w-and-h": "
",
"srcset-microsyntax-h": "
",
"srcset-microsyntax-function": "
",
"srcset-microsyntax-parenthesis-junk": "
",
"srcset-microsyntax-square-bracket-junk": "
",
"srcset-microsyntax-curly-bracket-junk": "
",
"srcset-microsyntax-pipe-junk": "
",
"srcset-microsyntax-w-and-no-descriptor": "
",
"srcset-microsyntax-unique-descriptors-1x-and-omitted": "
",
"srcset-microsyntax-unique-descriptors-2x": "
",
"srcset-microsyntax-unique-descriptors-integer-and-decimals-x": "
",
"srcset-microsyntax-unique-descriptors-w": "
",
"srcset-microsyntax-empty": "
",
"srcset-microsyntax-comma": "
",
"srcset-microsyntax-css-comment-after-descriptor": "
",
# aria
"picture-aria-role-img": "
",
"picture-aria-role-button": "
",
"picture-aria-role-region": "
",
"picture-aria-role-application": "
",
"source-aria-role-img": "
",
"picture-aria-role-presentation": "
",
"source-aria-role-presentation": "
",
}
non_errors_in_head = {
"parent-template-in-head": "
",
}
non_errors = {
# basic
"basic-img-src": "
",
"basic-picture-img-src": "
",
"basic-picture-source": "
",
# inter-element whitespace
"inter-element-whitespace": "
",
# parents
"parent-p": "![](x)
",
"parent-h1": "![x](x)
",
"parent-noscript-in-body": "",
"parent-object": "",
"parent-video": "",
"parent-section": "x
",
"parent-main": "
",
"parent-canvas": "",
"parent-template-in-body": "
",
"parent-ruby": "
",
"parent-rt": "x",
"parent-rp": "x",
"parent-a": "
",
"parent-button": "",
"parent-td": "![](x) |
",
# script-supporting elements
"script-first": "
",
"template-first": "
",
"script-between": "
",
"script-after": "
",
"script-before-after": "
",
"script-before-between-after": "
",
"script-and-template": "
",
# source with following sibling source element or img element with a srcset attribute
"source-with-media-img-with-srcset": "
",
"source-with-media-uppercase-img-with-srcset": "
",
"source-with-media-spaces-img-with-srcset": "
",
"source-with-media-source-with-srcset": "
",
"source-with-type-img-with-srcset": "
",
"source-with-type-source-with-srcset": "
",
# sizes present
"img-with-sizes": "
",
"source-with-sizes": "
",
# embed allows any attributes
"embed-srcset-empty": "