# -*- 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": "
", "junk-br-before-source": "
", "junk-br-after-source": "
", "junk-video-before": "", "junk-video-no-img": "", "junk-p-before": "

", "junk-p-after": "

", "junk-p-wrapping": "

", "junk-span-before": "", "junk-span-after": "", "junk-span-wrapping": "", "junk-picture-before": "", "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": "", "parent-dl": "
", "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": "", "multiple-img-with-script": "", "multiple-img-with-source": "", "multiple-img-with-source-and-script": "", # 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": "

", "parent-h1": "

x

", "parent-noscript-in-body": "", "parent-object": "", "parent-video": "", "parent-section": "

x

", "parent-main": "
", "parent-canvas": "", "parent-template-in-body": "", "parent-ruby": "x", "parent-rt": "x", "parent-rp": "xxx", "parent-a": "", "parent-button": "", "parent-td": "
", # 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": "", "embed-srcset-junk": "", "embed-sizes-empty": "", "embed-sizes-junk": "", # img src also in srcset "img-src-also-in-srcset-1x": "", "img-src-also-in-srcset-2x": "", "img-src-also-in-srcset-w": "", # img src not in srcset "img-src-not-in-srcset-x": "", "img-src-not-in-srcset-w": "", # source type "source-type": "", "source-type-srcset-x": "", "source-type-srcset-w-sizes": "", # sizes microsyntax "sizes-microsyntax-media-min-width": "", "sizes-microsyntax-multiple-source-sizes": "", "sizes-microsyntax-no-default": "", "sizes-microsyntax-media-not-and": "", "sizes-microsyntax-only-default": "", "sizes-microsyntax-calc-in-default": "", "sizes-microsyntax-calc-in-source-size-value": "", "sizes-microsyntax-calc-in-media": "", "sizes-microsyntax-zero": "", "sizes-microsyntax-minus-zero": "", "sizes-microsyntax-em-in-source-size-value": "", "sizes-microsyntax-ex-in-source-size-value": "", "sizes-microsyntax-ch-in-source-size-value": "", "sizes-microsyntax-rem-in-source-size-value": "", "sizes-microsyntax-vw-in-source-size-value": "", "sizes-microsyntax-vh-in-source-size-value": "", "sizes-microsyntax-vmin-in-source-size-value": "", "sizes-microsyntax-vmax-in-source-size-value": "", "sizes-microsyntax-cm-in-source-size-value": "", "sizes-microsyntax-mm-in-source-size-value": "", "sizes-microsyntax-q-in-source-size-value": "", "sizes-microsyntax-in-in-source-size-value": "", "sizes-microsyntax-pc-in-source-size-value": "", "sizes-microsyntax-pt-in-source-size-value": "", "sizes-microsyntax-px-in-source-size-value": "", "sizes-microsyntax-non-integer-px-in-source-size-value": "", "sizes-microsyntax-leading-css-comment": "", "sizes-microsyntax-trailing-css-comment": "", "sizes-microsyntax-plus": "", "sizes-microsyntax-non-integer-omitted-zero": "", "sizes-microsyntax-scientifi-notation-0": "", "sizes-microsyntax-scientifi-notation-1": "", "sizes-microsyntax-scientifi-notation-2": "", "sizes-microsyntax-scientifi-notation-3": "", "sizes-microsyntax-scientifi-notation-4": "", # srcset microsyntax "srcset-microsyntax-comma-in-url": "", "srcset-microsyntax-percent-escaped-leading-comma-in-url": "", "srcset-microsyntax-percent-escaped-trailing-comma-in-url": "", "srcset-microsyntax-percent-escaped-space-in-url": "", "srcset-microsyntax-w": "", "srcset-microsyntax-x": "", "srcset-microsyntax-non-integer-x": "", "srcset-microsyntax-scientific-notation-x": "", "srcset-microsyntax-scientific-notation-decimals-x": "", "srcset-microsyntax-scientific-notation-e-plus-x": "", "srcset-microsyntax-scientific-notation-e-minus-x": "", "srcset-microsyntax-scientific-notation-e-uppercase-x": "", "srcset-microsyntax-no-space-between-candidates": "", # valid attributes on img in picture "img-crossorigin-with-picture": "", "img-usemap-with-picture": "", "img-ismap-with-picture": "", "img-width-height-with-picture": "", "img-width-height-zero-with-picture": "", # global attributes on picture "picture-global-attributes": "", } for key in errors.keys(): template_error = template template_error += 'invalid %s\n' % key template_error += errors[key] file = open(os.path.join(ccdir, "html/elements/picture/%s-novalid.html" % key), 'wb') file.write(template_error) file.close() file = open(os.path.join(ccdir, "html/elements/picture/picture-isvalid.html"), 'wb') file.write(template + 'valid picture\n') for key in non_errors_in_head.keys(): file.write('%s \n' % (non_errors_in_head[key], key)) file.write('\n') for key in non_errors.keys(): file.write('%s \n' % (non_errors[key], key)) file.close() # vim: ts=4:sw=4