数码鹭岛论坛

标题: landslide将文本生成幻灯片 [打印本页]

作者: 翔子    时间: 2013-1-17 14:41
标题: landslide将文本生成幻灯片
[url=https://github.com/adamzap/landslide]https://github.com/adamzap/landslide

LandslideLandslide generates a slideshow using from markdown, ReST, or textile. Itbuilds off of Google's [url=http://code.google.com/p/html5slides/]html5slides template.
The following markdown produces [url=http://adamzap.com/misc/presentation.html]this slideshow.
# Landslide---# OverviewGenerate HTML5 slideshows from markdown, ReST, or textile.![python]()Landslide is primarily written in Python, but it's themes use:- HTML5- Javascript- CSS---# Code SampleLandslide supports code snippets    !python    def log(self, message, level='notice'):        if self.logger and not callable(self.logger):            raise ValueError(u"Invalid logger set, must be a callable")        if self.verbose and self.logger:            self.logger(message, level)Requirementspython and the following modules:
Markup ConversionOptionalInstallationInstall the latest stable version of Landslide with a python package managerlike pip:
$ pip install landslideIf you want to stay on the edge:
$ git clone https://github.com/adamzap/landslide.git$ cd landslide$ python setup.py build$ sudo python setup.py installFormattingMarkdownReStructuredTextTextileRenderingOr get it as a PDF document if PrinceXML is installed and available on yoursystem:
$ landslide README.md -d readme.pdf$ open readme.pdfViewingCommandline OptionsSeveral options are available using the command line:
-h, --help            show this help message and exit-c, --copy-theme      Copy theme directory into current presentation source                      directory-b, --debug           Will display any exception trace to stdin-d FILE, --destination=FILE                      The path to the to the destination file: .html or .pdf                      extensions allowed (default: presentation.html)-e ENCODING, --encoding=ENCODING                      The encoding of your files (defaults to utf8)-i, --embed           Embed stylesheet and javascript contents,                      base64-encoded images in presentation to make a                      standalone document-l LINENOS, --linenos=LINENOS                      How to output linenos in source code. Three options                      availables: no (no line numbers); inline (inside <pre>                      tag); table (lines numbers in another cell, copy-paste                      friendly)-o, --direct-output    Prints the generated HTML code to stdin; won't work                      with PDF export-q, --quiet           Won't write anything to stdin (silent mode)-r, --relative        Make your presentation asset links relative to current                      pwd; This may be useful if you intend to publish your                      html presentation online.-t THEME, --theme=THEME                      A theme name, or path to a landlside theme directory-v, --verbose         Write informational messages to stdin (enabled by                      default)-w, --watch           Watch the source directory for changes and                      auto-regenerate the presentation-x EXTENSIONS, --extensions=EXTENSIONS                      Comma-separated list of extensions for MarkdownPresentation ConfigurationLandslide allows to configure your presentation using a cfg configurationfile, therefore easing the aggregation of source directories and the reuse ofthem across presentations. Landslide configuration files use the cfg syntax.If you know ini files, you get the picture. Below is a sample configurationfile:
[landslide]theme  = /path/to/my/beautiful/themesource = 0_my_first_slides.md         a_directory         another_directory         now_a_slide.markdown         another_one.rstdestination = myWonderfulPresentation.htmlcss =    my_first_stylesheet.css         my_other_stylesheet.cssjs =     jquery.js         my_fancy_javascript.jsrelative = Truelinenos = inlineDon't forget to declare the [landslide] section.  All configuration filesmust end in the .cfg extension.
To generate the presentation as configured, just run:
$ cd /path/to/my/presentation/sources$ landslide config.cfgMacrosYou can use macros to enhance your presentation:
NotesAdd notes to your slides using the .notes: keyword, eg.:
# My Slide Title.notes: These are my notes, hidden by defaultMy visible content goes hereYou can toggle display of notes by pressing the 2 key.
Some other macros are also available by default: .fx: foo bar will add thefoo and bar classes to the corresponding slide <div> element, easingstyling of your presentation using CSS.
Presenter NotesYou can also add presenter notes to each slide by following the slide contentwith a heading entitled "Presenter Notes". Press the 'p' key to open thepresenter view.
Registering MacrosMacros are used to transform the HTML contents of your slide.
You can register your own macros by creating landslide.macro.Macro derivedclasses, implementing a process(content, source=None) method and returninga tuple containing the modified contents and some css classes you may bewanting to add to your slide <div> element. For example:
!pythonimport landslideclass MyMacro(landslide.Macro):  def process(self, content, source=None):    return content + '<p>plop</p>', ['plopped_slide']g = landslide.generator.Generator(source='toto.md')g.register_macro(MyMacro)print g.render()This will render any slide as below:
!html<div class="slide plopped_slide">  <header><h2>foo</h2></header>  <section>    <p>my slide contents</p>    <p>plop</p>  </section></div>Advanced UsageSetting Custom Destination File$ landslide slides.md -d ~/MyPresentations/presentation.htmlWorking with Directories$ landslide slides/Working with Direct Output$ landslide slides.md -o | tidyUsing an Alternate Landslide Theme$ landslide slides.md -t mytheme$ landslide slides.md -t /path/to/theme/dirEmbedding Base-64-Encoded Images$ landslide slides.md -iExporting to PDF$ landslide slides.md -d presentation.pdfThemingA Landslide theme is a directory following this simple structure:
mytheme/|-- base.html|-- css|   |-- print.css|   `-- screen.css`-- js    `-- slides.jsIf a theme does not provide HTML and JS files, those from the default themewill be used. CSS is not optional.
Last, you can also copy the whole theme directory to your presentation one bypassing the --copy-theme option to the landslide command:
$ landslide slides.md -t /path/to/some/theme --copy-themeUser stylesheets and JavascriptsIf you don't want to bother making your own theme, you can include your ownuser css and js files to the generated presentation.
This feature is only available if you use a landslide configuration file, bysetting the css and/or js flags:
[landslide]theme  = /path/to/my/beautiful/themesource = slides.mdowncss =    custom.cssjs =     jquery.js         powerpoint.jsThese will link the custom.css stylesheet and both the jquery.js andpowerpoint.js files within the <head> section of the presentation htmlfile.
NOTE: Paths to the css and js files must be relative to the directoryyou're running the landslide command from.
Publishing your Presentation OnlineIf you intend to publish your HTML presentation online, you'll have to use the--relative option, as well as the --copy-theme one to have all asset linksrelative to the root of your presentation;
$ landslide slides.md --relative --copy-themeThat way, you'll just have to host the whole presentation directory toa webserver. Of course, no Python nor PHP nor anything else than a HTTPwebserver (like Apache) is required to host a landslide presentation.
[url=http://www.akei.com/presentations/2011-Djangocong/index.html]Here's an example.
Theme VariablesThe base.html must be a [url=http://jinja.pocoo.org/2/documentation/templates]Jinja2 template file where you canharness the following template variables:
Styles ScopeAuthorsOriginal Author and Development LeadCo-AuthorContributorsSee [url=https://github.com/adamzap/landslide/contributors]https://github.com/adamzap/landslide/contributors
Base Template Authors and Contributors (html5-slides)




欢迎光临 数码鹭岛论坛 (http://www.clore.net/forum/) Powered by Discuz! X3.2