reveal-code-focus breaks down code blocks into individual lines. Fragments with the attribute data-code-focus are then associated with the lines of code to focus on. When these fragments are displayed, reveal-code-focus will focus on the respective lines of code.
Each line of code is wrapped in a <span> element with a class of "line". When lines are focused on, they will also have the "focus" class. The .line.focus selector can thus be used for custom styling to highlight particular lines.
Usage
<section> <pre><code> // Useless comment. alert('hi'); </pre></code> <p class="fragment" data-code-focus="1"> When this fragment is shown, the first line of code (`span.line`) will have the `"focus"` class added to it. </p> <p class="fragment" data-code-focus="1-2"> Another fragment. This time, both lines will now have the `"focus"` class. </p></section>
Styling
The most important style is to ensure that .line is set to display: block, so that lines will be rendered as block elements. You can then customize your CSS to set a different background or text colour when lines are focused on.
For slides with multiple code blocks, the data-code-block attribute can be used to focus on lines from a particular code block. By default, all fragments will focus on the first code block, unless otherwise specified.