Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions nbconvert/exporters/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,35 @@ def _init_resources(self, resources):
resources["reveal"]["scroll"] = self.reveal_scroll
resources["reveal"]["number"] = self.reveal_number
return resources

def from_notebook_node(self, nb, resources=None, **kw):
"""
Convert a notebook from a notebook node instance.
This method extends the parent implementation to override reveal.js
configuration with metadata from the notebook.
It reads reveal.js settings from the `reveal` key in the notebook's
metadata and merges them with the existing configuration.
The precedence for settings is:
1. Command-line arguments (highest)
2. Notebook metadata
3. Default configuration (lowest)
Parameters
----------
nb : :class:`~nbformat.NotebookNode`
Notebook node
resources : dict
Additional resources that can be accessed by exporters and preprocessors.
"""
output, resources = super().from_notebook_node(nb, resources, **kw)
if "reveal" in nb.metadata:
self.log.info("Applying reveal config from notebook metadata")
# Get reveal config from notebook metadata.
nb_reveal_config = nb.metadata.get("reveal", {})

# `resources['reveal']` contains config from command line.
# We merge the two, with command-line config having precedence.
reveal_config = nb_reveal_config.copy()
reveal_config.update(resources.get("reveal", {}))
resources["reveal"] = reveal_config

return output, resources
Loading