Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b3a85c7
removed lines cell setting metadata incorrectly
bouzidanas Sep 7, 2022
3ffd5c2
added ability to set slide "data-*" attribute
bouzidanas Sep 7, 2022
2807347
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 7, 2022
73e32e9
removed trailing spacing - cleaning
bouzidanas Sep 7, 2022
bd1cf0d
added slideshow metadata check
bouzidanas Sep 7, 2022
42c8ebe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 7, 2022
1d840f3
cell metadata -> section dataset
bouzidanas Sep 7, 2022
0f2ffdb
returned to original
bouzidanas Sep 7, 2022
274a136
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 7, 2022
ecf6895
Merge pull request #3 from bouzidanas/Working
bouzidanas Sep 8, 2022
53d6237
Merge pull request #2 from bouzidanas/Hotfix
bouzidanas Sep 8, 2022
39a42d3
Merge pull request #4 from jupyter/main
bouzidanas Dec 13, 2025
f5885c5
feat(slides): Read reveal.js config from notebook metadata
bouzidanas Dec 13, 2025
be3ebcd
Merge pull request #5 from bouzidanas/Feature-Development
bouzidanas Dec 13, 2025
ab74021
Sanitize 'since' input in prep-release workflow
bouzidanas Dec 14, 2025
4ab28a3
Merge pull request #9 from bouzidanas/Feature-Development
bouzidanas Dec 14, 2025
0099657
fixed formatting issue: Added missing separation between two functions
bouzidanas Dec 14, 2025
14943fc
Merge pull request #10 from bouzidanas/Feature-Development
bouzidanas Dec 14, 2025
e944ce4
fixed incorrect reveal config merging hierarchy
bouzidanas Dec 14, 2025
d472e1f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 14, 2025
0b1516c
Merge pull request #11 from bouzidanas/Feature-Development
bouzidanas Dec 14, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
post_version_spec: ${{ github.event.inputs.post_version_spec }}
target: ${{ github.event.inputs.target }}
branch: ${{ github.event.inputs.branch }}
since: ${{ github.event.inputs.since }}
since: ${{ steps.since.outputs.since }}
since_last_stable: ${{ github.event.inputs.since_last_stable }}

- name: "** Next Step **"
Expand Down
68 changes: 57 additions & 11 deletions nbconvert/exporters/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from copy import deepcopy
from warnings import warn

from traitlets import Bool, Unicode, default
from traitlets import Bool, Dict, Unicode, default

from nbconvert.preprocessors.base import Preprocessor

Expand Down Expand Up @@ -195,15 +195,61 @@ def _reveal_url_prefix_default(self):
""",
).tag(config=True)

def _init_resources(self, resources):
resources = super()._init_resources(resources)
reveal_config = Dict(
{},
help="""A dictionary of configuration options for reveal.js.
This is passed directly to the Reveal.initialize() call.
""",
).tag(config=True)

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. Config file
4. Default values (lowest)
Parameters
----------
nb : :class:`~nbformat.NotebookNode`
Notebook node
resources : dict
Additional resources that can be accessed by exporters and preprocessors.
"""
if resources is None:
resources = {}

# 1. Start with the config file settings
reveal_config = self.reveal_config.copy()

# 2. Layer notebook metadata on top
if "reveal" in nb.metadata:
self.log.info("Applying reveal config from notebook metadata")
reveal_config.update(nb.metadata.get("reveal", {}))

# 3. Layer command-line options on top
traitlet_map = {
"reveal_url_prefix": "url_prefix",
"reveal_theme": "theme",
"reveal_transition": "transition",
"reveal_scroll": "scroll",
"reveal_number": "number",
"reveal_height": "height",
"reveal_width": "width",
}
for trait_name, config_key in traitlet_map.items():
# Check if the trait was set via command-line config
if trait_name in self.config.SlidesExporter:
reveal_config[config_key] = getattr(self, trait_name)

# Update the resources dictionary
if "reveal" not in resources:
resources["reveal"] = {}
resources["reveal"]["url_prefix"] = self.reveal_url_prefix
resources["reveal"]["theme"] = self.reveal_theme
resources["reveal"]["transition"] = self.reveal_transition
resources["reveal"]["scroll"] = self.reveal_scroll
resources["reveal"]["number"] = self.reveal_number
resources["reveal"]["height"] = self.reveal_height
resources["reveal"]["width"] = self.reveal_width
return resources
resources["reveal"].update(reveal_config)

return super().from_notebook_node(nb, resources=resources, **kw)
48 changes: 36 additions & 12 deletions share/templates/reveal/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{% set reveal_width = resources.reveal.width | default('960', true) %}
{% set reveal_height = resources.reveal.height | default('700', true) %}
{% set reveal_scroll = resources.reveal.scroll | default(false, true) | json_dumps %}
{% set reveal_controls = resources.reveal.controls | default(true, true) | json_dumps %}
{% set reveal_progress = resources.reveal.progress | default(true, true) | json_dumps %}
{% set reveal_history = resources.reveal.history | default(true, true) | json_dumps %}

{%- block header -%}
<!DOCTYPE html>
Expand Down Expand Up @@ -150,17 +153,38 @@ require(

function(Reveal, RevealNotes){
// Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
transition: "{{reveal_transition}}",
slideNumber: "{{reveal_number}}",
plugins: [RevealNotes],
width: {{reveal_width}},
height: {{reveal_height}},

});
var config = {
// Pass in reveal.js options from template's default arguments
controls: {{ reveal_controls }},
progress: {{ reveal_progress }},
history: {{ reveal_history }},
transition: "{{ reveal_transition }}",
slideNumber: "{{ reveal_number }}",
width: {{ reveal_width }},
height: {{ reveal_height }},
scroll: {{ reveal_scroll }},
}
// Then override with any metadata passed in from the notebook or config.
var reveal_opts = {{ resources.reveal | json_dumps }};

function isEmpty(obj) {
if (obj === null || obj === "") return true;
if (Array.isArray(obj) && obj.length === 0) return true;
if (typeof obj === 'object' && Object.keys(obj).length === 0 && obj.constructor === Object) return true;
return false;
}

for (var key in reveal_opts) {
if (!isEmpty(reveal_opts[key])) {
config[key] = reveal_opts[key];
}
}

if (config.plugins === undefined) {
config.plugins = [];
}
config.plugins.push(RevealNotes);
Reveal.initialize(config);

var update = function(event){
if(MathJax.Hub.getAllJax(Reveal.getCurrentSlide())){
Expand All @@ -171,7 +195,7 @@ require(
Reveal.addEventListener('slidechanged', update);

function setScrollingSlide() {
var scroll = {{ reveal_scroll }}
var scroll = config.scroll;
if (scroll === true) {
var h = $('.reveal').height() * 0.95;
$('section.present').find('section')
Expand Down
Loading