codefocus
CodeFocus for Quarto Revealjs
Use this syntax to add progressive code highlighting with explanations in Quarto revealjs presentations.
When to use
- When creating Quarto revealjs presentations
- When you need step-by-step code walkthroughs
- When teaching code concepts progressively
Setup
- Install the extension:
quarto add reuning/codefocus
- Add to
_quarto.yml:
revealjs-plugins:
- codefocus
Instructions
Syntax
## Slide Title
```python
import requests
import json
api_url = "https://api.example.com/data"
headers = {"Authorization": "Bearer token"}
response = requests.get(api_url, headers=headers)
data = response.json()
```
::: {.fragment .current-only data-code-focus="1-2"}
First, we import the required libraries for HTTP requests and JSON handling.
:::
::: {.fragment .current-only data-code-focus="4-5"}
Define the API endpoint URL and authentication headers.
:::
::: {.fragment .current-only data-code-focus="7-8"}
Make the GET request and parse the JSON response.
:::
Key Attributes
.fragment- Makes content appear progressively.current-only- Fragment disappears when advancing (keeps slide clean)data-code-focus="N"- Line number to highlight (1-indexed)data-code-focus="1-3"- Range of linesdata-code-focus="1,3,5"- Multiple specific lines
Notes
- Code block must come BEFORE the fragment divs
- Each fragment highlights different lines as you press arrow keys
- The explanation text appears below the code when that fragment is active
More from htlin222/dotfiles
cpp
Write modern C++ with RAII, smart pointers, and STL. Use for C++ development, memory safety, or performance optimization.
130refactor
Refactor code for quality and maintainability. Use for cleanup and tech debt reduction.
74data-science
Data analysis, SQL queries, BigQuery operations, and data insights. Use for data analysis tasks and queries.
52c-lang
Write efficient C code with proper memory management and system calls. Use for C optimization, memory issues, or system programming.
46quarto-book
Generate Quarto Book project structure with chapters, configuration, and output settings. Use when user wants to create a book, multi-chapter document, technical manual, or asks about Quarto book setup.
45scientific-figure-assembly
Assemble multi-panel scientific figures with panel labels (A, B, C) at publication quality (300 DPI) using R. Use when combining individual plots into journal-ready figures.
43