Expresso.Check.Document (expresso v0.1.0)

Copy Markdown View Source

The checks of --check that need no tool: they read the deck and its HTML

Expresso.Check runs these checks at each level. Each check returns a list of problems and a list of notes. A problem makes the exit status 1. A note tells of a choice that can be correct, such as an image with no alt text.

CheckKindFinds
theme/1problemEach role of a theme of 16 colors under its minimum of contrast
theme/1noteEach variant of the theme that does not dim at the dim_contrast option
size/1noteThe size of the document, and its largest files
slides/1noteAn image with no alt text, a diagram with no alt text, a slide with only a hidden heading, and a slide with no h1

Summary

Types

The problems and the notes of a check

Functions

Return a note with the size of the document, and with the size and the type of its largest files

Return a note for each slide with a part that a screen reader reads differently

Return a problem for each role of the theme of the deck under its minimum of contrast

Types

result()

@type result() :: %{problems: [String.t()], notes: [String.t()]}

The problems and the notes of a check

Functions

size(html)

@spec size(String.t()) :: result()

Return a note with the size of the document, and with the size and the type of its largest files

A file is a data URI in a src, an href or an xlink:href attribute, or in a url() of a style sheet, such as a font of the theme. Expresso.Assets keeps one copy of each large file, so the note names each file one time.

iex> Expresso.Check.Document.size(String.duplicate("a", 2_500_000))
%{problems: [], notes: ["The document is 2.4 MB."]}

slides(html)

@spec slides(String.t()) :: result()

Return a note for each slide with a part that a screen reader reads differently

The function reads the present view of each slide in the HTML, and it gives a note for:

  • an image with an empty alt. A screen reader skips such an image.
  • a diagram with no alt option. A screen reader reads the text of its SVG.
  • a slide with only a hidden heading. A screen reader reads the heading, but the slide shows no title.
  • a slide with no h1, from the option sr_heading false.

theme(deck)

@spec theme(Expresso.Deck.t()) :: result()

Return a problem for each role of the theme of the deck under its minimum of contrast

The problems are the warnings of Expresso.ThemeVerifier.messages/1. A built-in theme has no problem. The notes are the warnings of Expresso.ThemeVerifier.dim_messages/2: a deck that does not dim can be correct, so they do not change the exit status.