Landslide’s documentation

Landslide is a command-line based presentation generator relying on Web standards (html, javascript, css) and some Python libraries such as Jinja2, Pygments, docutils and Markdown.

Installation

Landslide requires Python v2.5 minimum and these dependencies installed:

One of the syntax handlers above:

The easiest way to install Landslide is using Pip:

$ pip install landslide

Alternatively, you can use easy_install:

$ easy_install landslide

If you rather want to stay on the edge:

$ git clone https://github.com/n1k0/landslide.git
$ cd landslide
$ python setup.py build
$ sudo python setup.py install

Basic Usage

Using the Markdown syntax

  • Your Markdown source files must be suffixed by .md, .markdn, .mdown or .markdown
  • To create a title slide, render a single h1 element (eg. # My Title)
  • Separate your slides with a horizontal rule (--- in markdown) except at the end of markdown files
  • Your other slides should have a heading that renders to an <h1> or <h2> element
  • To highlight blocks of code, put !{lang} where {lang} is the pygment supported language identifier as the first indented line

Here’s a sample presentation based on Markdown:

# My Presentation Heading
---
## My First Slide Title
With some contents
---
## My Second Slide Title
With some contents

Using the reStructuredText syntax

Bar

API Documentation

Generator

class landslide.generator.Generator(source, **kwargs)

The Generator class takes and processes presentation source as a file, a folder or a configuration file and provides methods to render them as a presentation.

add_toc_entry(title, level, slide_number)

Adds a new entry to current presentation Table of Contents.

add_user_css(css_list)

Adds supplementary user css files to the presentation. The css_list arg can be either a list or a basestring instance.

add_user_js(js_list)

Adds supplementary user javascript files to the presentation. The js_list arg can be either a list or a basestring instance.

execute()

Execute this generator regarding its current configuration.

fetch_contents(source)

Recursively fetches Markdown contents from a single file or directory containing itself Markdown files.

find_theme_dir(theme, copy_theme=False)

Finds them dir path from its name.

get_css()

Fetches and returns stylesheet file path or contents, for both print and screen contexts, depending if we want a standalone presentation or not.

get_js()

Fetches and returns javascript file path or contents, depending if we want a standalone presentation or not.

get_slide_vars(slide_src, source=None)

Computes a single slide template vars from its html source code. Also extracts slide informations for the table of contents.

get_template_file()

Retrieves Jinja2 template file path.

get_template_vars(slides)

Computes template vars from slides html source code.

linenos_check(value)

Checks and returns a valid value for the linenos option.

log(message, type='notice')

Logs a message (eventually, override to do something more clever).

parse_config(config_source)

Parses a landslide configuration file and returns a normalized python dict.

process_macros(content, source=None)

Processed all macros.

register_macro(*macros)

Registers macro classes passed a method arguments.

render()

Returns generated html code.

toc

Smart getter for Table of Content list.

write()

Writes generated presentation code into the destination file.

write_pdf(html)

Tries to write a PDF export from the command line using PrinceXML if available.

Macros

class landslide.macro.CodeHighlightingMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro performs syntax coloration in slide code blocks using Pygments.

descape(string, defs=None)

Decodes html entities from a given string

class landslide.macro.EmbedImagesMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro extracts images url and embed them using the base64 algorithm.

class landslide.macro.FixImagePathsMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro replaces html image paths with fully qualified absolute urls.

class landslide.macro.FxMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro processes fx directives, ie adds specific css classes named after what the parser found in them.

class landslide.macro.Macro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

Base class for Macros. A Macro aims to analyse, process and eventually alter some provided HTML contents and to provide supplementary informations to the slide context.

process(content, source=None)

Generic processor (does actually nothing)

class landslide.macro.NotesMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro processes Notes.

class landslide.macro.QRMacro(logger=<open file '<stdout>', mode 'w' at 0xf7798078>, embed=False, options=None)

This Macro generates a QR Code with Google Chart API.

Parser

class landslide.parser.Parser(extension, encoding='utf8', md_extensions='')

This class generates the HTML code depending on which syntax is used in the souce document.

The Parser currently supports both Markdown and restructuredText syntaxes.

parse(text)

Parses and renders a text as HTML regarding current format.

Utils

landslide.utils.get_abs_path_url(path)

Returns the absolute url for a given local path.

landslide.utils.get_path_url(abs_path, relative=False)

Returns an absolute or relative path url from an absolute path.

landslide.utils.get_rel_path_url(path, base_path='/builddir/build/BUILD/landslide-a0078400c8e8f2fe19a754c0dbd55e7a3dbb796d/docs')

Returns a relative path from the absolute one passed as argument. Silently returns originally provided path on failure.

Indices and tables