logo

Slides Filter

← Back to Filter List

Slides


↓ examples

Converts paragraphs to HTML and wrap each slide in a header and footer.

Aliases for this filter

  • slides

Converts from file formats:

  • .*

To file formats:

  • .html

Available settings:

SettingDescriptionDefault
add-new-filesBoolean or list of extensions/patterns to match.False
added-in-versionDexy version when this filter was first available.0.9.9.6
additional-doc-filtersFilters to apply to additional documents created as side effects.{}
additional-doc-settingsSettings to apply to additional documents created as side effects.{}
comment-charLines starting with this comment char will not show up in slides.;
data-typeAlias of custom data class to use to store filter output.generic
examplesTemplates which should be used as examples for this filter.[u'slides']
exclude-add-new-filesList of patterns to skip even if they match add-new-files.[]
exclude-new-files-from-dirList of directories to skip when adding new files.[]
extFile extension to output.None
extension-mapDictionary mapping input extensions to default output extensions.None
extensionsWhich Markdown extensions to enable.{u'nl2br': {}}
helpHelpstring for plugin.Converts paragraphs to HTML and wrap each slide in a header and footer.
input-extensionsList of extensions which this filter can accept as input.[u'.*']
keep-originalsWhether, if additional-doc-filters are specified, the original unmodified docs should also be added.False
mkdirA directory which should be created in working dir.None
mkdirsA list of directories which should be created in working dir.[]
nodocWhether filter should be excluded from documentation.False
outputWhether to output results of this filter by default by reporters such as 'output' or 'website'.False
output-extensionsList of extensions which this filter can produce as output.[u'.html']
override-workspace-exclude-filtersIf True, document will be populated to other workspaces ignoring workspace-exclude-filters.False
preserve-prior-data-classWhether output data class should be set to match the input data class.False
require-outputShould dexy raise an exception if no output is produced by this filter?True
slide-footerContent to append to end of each slide.
slide-headerContent to prepend to start of each slide.
splitString to use to split slides.
tagsTags which describe the filter.[]
variablesA dictionary of variable names and values to make available to this filter.{}
varsA dictionary of variable names and values to make available to this filter.{}
workspace-exclude-filtersFilters whose output should be excluded from workspace.[u'pyg']
workspace-includesIf set to a list of filenames or extensions, only these will be populated to working dir.None

Slides Filter

The slides filter takes markdown content, like this:

# My Presentation


## This is a header

Some paragraph text


## Another slide

- foo
- bar
- baz

and lets you generate slides using javascript/css slide presentation tools such as impress.js or deck.js. Just leave 2 blank lines to indicate a new slide (this is configurable with the split setting).

Here is the HTML generated by the slides filter with default settings:

<section class="slide">
<h1>My Presentation</h1>
</section>

<section class="slide">
<h2>This is a header</h2>
<p>Some paragraph text</p>
</section>

<section class="slide">
<h2>Another slide</h2>
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</section>

The default settings work for deck.js.

Here is a dexy configuration which inserts content from the slides.md source (as shown above) into a deck.html file which is a deck.js template:

- deck.html|jinja:
    - slides.md|jinja|slides:
        - output: False

Here are the resulting deck.js slides:

To use the slides filter with other presentation tools, change the slide-header and slide-footer settings to whatever each slide needs to be wrapped with. Here are settings which work with impress.js:

- impress.html|jinja:
    - impress.md|jinja|slides:
        - output: False
        - slides: {
            slide-header: "<div class=\"slide step\" id=\"slide%(number)s\">",
            slide-footer: "</div>"
        }

These header and footer strings are run through python string interpolation before they are wrapped around the content of each slide. Currently there is one variable available to this interpolation named number which gives you the slide number, starting with slide 1.

Here are the resulting impress.js slides:

Filter Source Code
class MarkdownSlidesFilter(MarkdownFilter):
    """
    Converts paragraphs to HTML and wrap each slide in a header and footer.
    """
    aliases = ['slides']

    _settings = {
            'extensions' : { 'nl2br' : {} },
            'added-in-version': "0.9.9.6",
            'examples' : ['slides'],
            'comment-char' : (
                "Lines starting with this comment char will not show up in slides.",
                ';'),
            'split' : (
                "String to use to split slides.",
                "\n\n\n" # e.g. 2 blank lines.
                ),
            'slide-header' : (
                "Content to prepend to start of each slide.",
                """<section class="slide">"""
                ),
            'slide-footer' : (
                "Content to append to end of each slide.",
                """</section>"""
                ),
            }

    def process_text(self, input_text):
        self.capture_markdown_logger()
        md = self.initialize_markdown()

        slides = ""
        comment_regexp = "^%s(.*)$" % self.setting('comment-char')

        for counter, slide in enumerate(input_text.split(self.setting('split'))):
            slide = re.sub(comment_regexp, "", slide, flags=re.MULTILINE)
            html = md.convert(slide)

            # Variables to make available for string interpolation in header and footer.
            interp = {
                    'number' : (counter+1)
                    }

            header = self.setting('slide-header') % interp
            footer = self.setting('slide-footer')% interp

            slide_text = "\n%s\n%s\n%s\n" % (header, html, footer)
            slides += slide_text

        return slides

Content © 2013 Dr. Ana Nelson | Site Design © Copyright 2011 Andre Gagnon | All Rights Reserved.