Expresso.SectionTransformer (expresso v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Callback implementation for Spark.Dsl.Transformer.after?/1.

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

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

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

Functions

after?(_)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(arg1)

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

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

sections(slides)

@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(dsl_state)

@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