OCaml HTML5 parser/serialiser based on Python's JustHTML
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 9c420b4676d1731182b39c03cd3d95ab05b008d1 50 lines 1.7 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: MIT 4 ---------------------------------------------------------------------------*) 5 6(** Srcset and sizes attribute validation checker. 7 8 This checker validates the [srcset] and [sizes] attributes on [<img>] 9 and [<source>] elements. These attributes use a specialized microsyntax 10 for responsive images. 11 12 {2 Srcset Syntax} 13 14 The [srcset] attribute contains a comma-separated list of image 15 candidates, each with: 16 - A URL 17 - An optional width descriptor ([Nw], e.g., "800w") 18 - Or an optional pixel density descriptor ([Nx], e.g., "2x") 19 20 Width and pixel density descriptors cannot be mixed in the same srcset. 21 22 {2 Sizes Syntax} 23 24 The [sizes] attribute contains a comma-separated list of: 25 - Media conditions (optional) 26 - Source sizes (CSS lengths) 27 28 The last entry should not have a media condition (it's the default). 29 30 {2 Validation Rules} 31 32 - URLs in srcset must be valid 33 - Width descriptors must be positive integers 34 - Pixel density descriptors must be positive numbers 35 - Sizes must use valid CSS length units 36 - Duplicate descriptors are flagged 37 38 {2 Error Messages} 39 40 - Invalid srcset syntax 41 - Invalid sizes syntax 42 - Missing sizes when srcset uses width descriptors 43 - Invalid CSS length units 44 45 @see <https://html.spec.whatwg.org/multipage/images.html#srcset-attributes> 46 HTML Standard: Srcset attributes 47*) 48 49val checker : Checker.t 50(** The srcset/sizes attribute checker instance. *)