# `Expresso.SectionTransformer`
[🔗](https://github.com/rellen/expresso/blob/main/lib/expresso/section_transformer.ex#L1)

The Spark transformer of the sections of a deck

It runs one time for each deck module at compile time, and before
`Expresso.Overlay.Transformer`. A slide with the `section` option starts a
section, and the section runs to the next slide with a `section` option. The
transformer does two things:

- It puts the title of the section of each slide into the metadata of the
  slide, under the key `:section`. A slide before the first section has no
  key. A template reads it as `@metadata[:section]`.
- It puts one `Expresso.Element.TocEntry` for each section into each
  `Expresso.Element.Toc`, with a link to the first slide of the section and
  the place of the section from the slide of the toc. The entries are then
  the children of the toc, so the overlay transformer gives them their steps.

A toc in a deck without a section is an error, which becomes a
`Spark.Error.DslError` with the path of the slide.

# `after?`

# `after_compile?`

# `before?`

```elixir
@spec before?(module()) :: boolean()
```

Run this transformer before the overlay transformer, which gives the entries their steps

# `sections`

```elixir
@spec sections([Expresso.Slide.t()]) :: [{String.t(), pos_integer()}]
```

Return the title and the number of the first slide of each section

    iex> slides = [%Expresso.Slide{}, %Expresso.Slide{section: "Why"}, %Expresso.Slide{section: "How"}]
    iex> Expresso.SectionTransformer.sections(slides)
    [{"Why", 2}, {"How", 3}]

# `transform`

```elixir
@spec transform(map()) :: {:ok, map()} | {:error, Spark.Error.DslError.t()}
```

Put the section of each slide into its metadata, and the entries into each toc

---

*Consult [api-reference.md](api-reference.md) for complete listing*
