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

Allow container "overlay" to overlay images #459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions pandoc/beamer_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def source_file_contents(filename, keywords):
"source_include",
"admonition",
"animate",
"overlay",
"speakernote",
"columns",
"column",
Expand Down Expand Up @@ -468,6 +469,57 @@ def animate(classes, contents):
return value


##############
## OVERLAYS ##
##############

"""
We are going to use a container to actually overlay one
container with another. This will be most useful when
you want to overlay one image with another image to
show image animation.
The format of the directive is:

.. container:: overlay <slide #>

Slide number is the "slide" to display the contents.
(Unlike "animate", whatever you overlay will get replaced
by the next overlay - it's not actual layers)
A number will appear on the specific overlay.
NOTE: We use "onlyenv" to make the block appear, so if the blocks (images)
are not the same size, there will probably be some resizing, makeing things
look bad.
"""


def is_overlay(classes):
return ("container" in classes) and ("overlay" in classes)


def overlay(classes, contents):
slide_number = 1
dash = "-"
if len(classes) > 2:
requested = classes[2]
if len(requested) > 0:
slide_number = int(requested)

slide_number = str(slide_number)
first = {
"t": "RawBlock",
"c": ["latex", "\\begin{onlyenv}<" + slide_number + ">"],
}
last = {"t": "RawBlock", "c": ["latex", "\\end{onlyenv}"]}

value = []
value.append(first)
for c in contents:
value.append(c)
value.append(last)

return value


########################
## LATEX ENVIRONMENTS ##
########################
Expand Down Expand Up @@ -836,6 +888,9 @@ def perform_filter(key, value, format, meta):
if is_animate(classes):
return animate(classes, contents)

if is_overlay(classes):
return overlay(classes, contents)

if is_latex_environment(classes):
return latex_environment(classes, contents)

Expand Down
Loading