diff --git a/pandoc/beamer_filter.py b/pandoc/beamer_filter.py index 0b737d314..656ea7155 100755 --- a/pandoc/beamer_filter.py +++ b/pandoc/beamer_filter.py @@ -362,6 +362,7 @@ def source_file_contents(filename, keywords): "source_include", "admonition", "animate", + "overlay", "speakernote", "columns", "column", @@ -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 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 ## ######################## @@ -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)