Add support for full configuration of reveal slides in notebook metadata#2257
Open
bouzidanas wants to merge 21 commits intojupyter:mainfrom
Open
Add support for full configuration of reveal slides in notebook metadata#2257bouzidanas wants to merge 21 commits intojupyter:mainfrom
bouzidanas wants to merge 21 commits intojupyter:mainfrom
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Working - ability to add section element dataset attribute via cell metadata
removed trailing spacing - cleaning
Update fork with latest changes
feat(slides): Allow reveal.js configuration from notebook metadata
Sanitize 'since' input in prep-release workflow
fixed formatting issue
for more information, see https://pre-commit.ci
Feature development: Allow reveal.js configuration from notebook metadata with correct precedence
|
This would really help make jupyter a more functional platform for making presentations. Thanks for working on this! Where's the right way to document this - here? |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Suggested labels: enhancement, feature)
This pull request introduces a new feature that allows
reveal.jspresentation settings to be configured directly within a notebook's metadata.Currently,
reveal.jsoptions 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 or edit the html file themselves which requires familiarity withreveal.js. Furthermore, only a limited number of reveal.js options are accessible via the command line and in the configuration files.This enhancement allows users to embed
reveal.jssettings within the.ipynbfile itself, making presentations self-contained and easier to share and reproduce consistently.Implementation Details
The feature is implemented by overriding the
from_notebook_nodemethod in theSlidesExporter. The new implementation preserves the existing conversion logic by callingsuper().from_notebook_node(). It also inspects the notebook's metadata for arevealkey and merges the settings with the configuration already loaded from command-line options and defaults.A clear order of precedence (override order) is maintained to ensure intuitive and predictable behavior:
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 arevealobject.Example Notebook Metadata:
{ "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.9.7" }, + "reveal": { + "theme": "night", + "transition": "zoom", + "scroll": true +} }When a notebook with this metadata is exported using
jupyter nbconvert --to slides, it will automatically use the "night" theme and "zoom" transition, unless a different value is provided on the command line.List of config options
Related Issues