Skip to content

feat(slides): Allow reveal.js configuration from notebook metadata#5

Merged
bouzidanas merged 1 commit intomainfrom
Feature-Development
Dec 13, 2025
Merged

feat(slides): Allow reveal.js configuration from notebook metadata#5
bouzidanas merged 1 commit intomainfrom
Feature-Development

Conversation

@bouzidanas
Copy link
Copy Markdown
Owner

Description

This pull request introduces a new feature that allows reveal.js presentation settings to be configured directly within a notebook's metadata.

Currently, reveal.js options for slide exports are primarily set via command-line arguments or configuration files. This separates the presentation's configuration from its content, making it less portable. For example, if a user wants to share a notebook that is designed to be presented with a specific theme or transition, they must also share the command-line flags needed to reproduce it.

This enhancement allows users to embed reveal.js settings within the .ipynb file itself, making presentations self-contained and easier to share and reproduce consistently.

Implementation Details

The feature is implemented by overriding the from_notebook_node method in the SlidesExporter. The new implementation preserves the existing conversion logic by first calling super().from_notebook_node(). It then inspects the notebook's metadata for a reveal key and merges the settings with the configuration already loaded from command-line options and defaults.

A clear order of precedence is maintained to ensure intuitive and predictable behavior:

  1. Command-line arguments (e.g., --SlidesExporter.reveal_theme=night) have the highest priority.
  2. Notebook metadata is applied next.
  3. Exporter defaults are used as the base (lowest priority).

This ensures that users can set project-wide defaults in a notebook but still easily override them from the command line for a specific export.

How to Use

To use this feature, a user can edit the notebook's metadata (e.g., in Jupyter, via Edit > Edit Notebook Metadata) and add a reveal object.

Example Notebook Metadata:

{
  "kernelspec": {
    "display_name": "Python 3",
    "language": "python",
    "name": "python3"
  },
  "language_info": {
    "name": "python",
    "version": "3.9.7"
  },
  "reveal": {
    "theme": "sky",
    "transition": "zoom",
    "scroll": true
  }
}

When a notebook with this metadata is exported using jupyter nbconvert --to slides, it will automatically use the "sky" theme and "zoom" transition, unless a different value is provided on the command line.


@bouzidanas bouzidanas merged commit be3ebcd into main Dec 13, 2025
20 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant