Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more RISE config options to SlidesExporter #2147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,7 @@ raw template
{%- endblock in_prompt -%}
"""


exporter_attr = AttrExporter()
output_attr, _ = exporter_attr.from_notebook_node(nb)
assert "raw template" in output_attr
Expand Down
37 changes: 37 additions & 0 deletions nbconvert/exporters/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def preprocess(self, nb, resources=None):
nb.cells[-1].metadata.subslide_end = True
nb.cells[-1].metadata.slide_end = True

# Update reveal config values using values from notebook metadata if present
if isinstance(resources, dict) and "reveal" in resources:
resources["reveal"].update(nb.metadata.get("reveal", {}))

return nb, resources


Expand Down Expand Up @@ -186,6 +190,35 @@ def _reveal_url_prefix_default(self):
""",
).tag(config=True)

reveal_overlay = Unicode(
"",
help="""
Optional text or html overlay.
If this is set then reveal_header, reveal_footer and reveal_backimage are ignored.
""",
).tag(config=True)

reveal_header = Unicode(
"",
help="""
Optional header to display above slides.
""",
).tag(config=True)

reveal_backimage = Unicode(
"",
help="""
Optional background image to display behind the slides.
""",
).tag(config=True)

reveal_footer = Unicode(
"",
help="""
Optional footer to display below slides.
""",
).tag(config=True)

font_awesome_url = Unicode(
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css",
help="""
Expand All @@ -206,4 +239,8 @@ def _init_resources(self, resources):
resources["reveal"]["number"] = self.reveal_number
resources["reveal"]["height"] = self.reveal_height
resources["reveal"]["width"] = self.reveal_width
resources["reveal"]["overlay"] = self.reveal_overlay
resources["reveal"]["header"] = self.reveal_header
resources["reveal"]["backimage"] = self.reveal_backimage
resources["reveal"]["footer"] = self.reveal_footer
return resources
19 changes: 19 additions & 0 deletions share/templates/reveal/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{% 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_overlay = resources.reveal.overlay | default('', true) %}
{% set reveal_header = resources.reveal.header | default('', true) %}
{% set reveal_backimage = resources.reveal.backimage | default('', true) %}
{% set reveal_footer = resources.reveal.footer | default('', true) %}

{%- block header -%}
<!DOCTYPE html>
Expand Down Expand Up @@ -122,6 +126,21 @@ a.anchor-link {
{% endif %}
<main>
<div class="reveal">

{% if reveal_overlay != '' %}
<div id='rise-overlay'>{{ reveal_overlay }}</div>
{% else %}
{% if reveal_header != '' %}
<div id='rise-header'>{{ reveal_header }}</div>
{% endif %}
{% if reveal_backimage != '' %}
<img id='rise-backimage' src="{{ reveal_backimage }}" />
{% endif %}
{% if reveal_footer != '' %}
<div id='rise-footer'>{{ reveal_footer }}</div>
{% endif %}
{% endif %}

<div class="slides">
{%- endblock body_header -%}

Expand Down
25 changes: 25 additions & 0 deletions share/templates/reveal/static/custom_reveal.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.reveal .slides {
text-align: left;
}

.reveal.fade {
opacity: 1;
}
Expand Down Expand Up @@ -107,6 +108,30 @@ main {
background: #727272;
}

.reveal #rise-header {
position: absolute; top: 0;
}

.reveal #rise-header a {
z-index: 1;
}

.reveal #rise-backimage {
margin: 0;
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
}

.reveal #rise-footer {
position: absolute; bottom: 0;
}

.reveal #rise-footer a {
z-index: 1;
}

/* Scrollbars */

::-webkit-scrollbar {
Expand Down
Loading