mdpress-0.0.15/ 0000755 0001750 0001750 00000000000 12250154716 012633 5 ustar boutil boutil mdpress-0.0.15/examples/ 0000755 0001750 0001750 00000000000 12250154716 014451 5 ustar boutil boutil mdpress-0.0.15/examples/helloworld.md 0000644 0001750 0001750 00000000067 12250154716 017151 0 ustar boutil boutil # Hello ## World! --- = data-x='1000' # Hi, mdpress! mdpress-0.0.15/examples/code.md 0000644 0001750 0001750 00000000141 12250154716 015701 0 ustar boutil boutil # Here's some code! def fib x return x if x < 2 fib(x - 1) + fib(x - 2) end mdpress-0.0.15/examples/demo.md 0000644 0001750 0001750 00000000554 12250154716 015723 0 ustar boutil boutil --- author: Aditya Bhargava title: All about chicken --- # Just because ## my middle name is **Pancake**, > doesn't mean you can put syrup on me before I'm ready to come out of the oven. mdpress++ --- = data-x='1000' # Let's Make Lists! 1. Chicken 2. *Emphasized Chicken* 3. [Chicken Link](http://github.com/egonschiele/mdpress) - unordered `chicken = 1` mdpress-0.0.15/bin/ 0000755 0001750 0001750 00000000000 12250154716 013403 5 ustar boutil boutil mdpress-0.0.15/bin/mdpress 0000755 0001750 0001750 00000010756 12250154716 015017 0 ustar boutil boutil #!/usr/bin/env ruby require 'rubygems' require 'redcarpet' require 'fileutils' require 'impress_renderer' require 'trollop' require 'tempfile' require 'launchy' require 'yaml' THEMES_DIRNAME = './themes/' def log(x) puts "\033[94m" + x + "\033[0m" if OPTS[:verbose] end def base_dir File.dirname(__FILE__) + "/../lib/" end def list_available_stylesheets log "Available stylesheets:" log "mdpress stylesheets" Dir.glob(base_dir + "impress_css/*.css").each do |file| puts File.basename(file, ".css") end log "Local stylesheets" Dir.glob(THEMES_DIRNAME + "*.css").each do |file| puts File.basename(file, ".css") end end def readfile file if file =~ /^http/ require 'httparty' response = HTTParty.get(file) if response return response.body else raise "couldn't download url: #{file}" end else return File.read(file) end end def extract_metadata text if md = text.match(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m) [md.post_match, YAML.load(md[1])] else [text, {}] end end def render opts text, metadata = extract_metadata(readfile(FILENAME)) # ugly hack to get attributes for impress.js # TODO make this pretty lines = text.split("\n") lines.drop_while { |l| l =~ /^\s*$/ } attrs = [""] new_lines = [] lines.each_with_index do |line, i| if line =~ /^=(.*)$/ && (i == 0 || lines[i-1] =~ /^(-\s*){3,}$/) line =~ /^=(.*)$/ attrs[attrs.size-1] = $~.to_a[1] next elsif line =~ /^(-\s*){3,}$/ attrs << "" end new_lines << line end text = new_lines.join("\n") # now use those attributes and render the file include Redcarpet ImpressRenderer.init_with_attrs attrs, opts ImpressRenderer.author= metadata['author'] if metadata['author'] ImpressRenderer.title= metadata['title'] if metadata['title'] if File.exist?(STYLESHEET_HEAD) ImpressRenderer.head= File.read(STYLESHEET_HEAD) end m = Markdown.new(ImpressRenderer, :autolink => true, :fenced_code_blocks => true, :tables => true) log "rendering presentation" f = File.open(DIRNAME + "/index.html", "w+") f.write(m.render(text)) f.close end OPTS = Trollop::options do banner <<-EOS Usage: mdpress [filename] [options] where [options] are: EOS opt :automatic, "Keeps running and automatically updates the presentation to reflect changes to markdown file." opt :stylesheet, "Specify what stylesheet to use.", :default => "default" opt :list, "List all available stylesheets." opt :run, "Run presentation (automatically compiles to a tmp directory and opens in a browser window)" opt :latex, "Provide Latex support" opt :verbose, "Be verbose." end if OPTS[:list] list_available_stylesheets exit end Trollop::die("no file specified") if ARGV.empty? # show help screen if OPTS[:run] file = ARGV[0] tmp = Tempfile.new("mdpress") tmp.write(readfile(file)) tmp.flush FILENAME = tmp.path DIRNAME = FILENAME + "_dir" else FILENAME = ARGV[0] DIRNAME = File.basename(FILENAME, File.extname(FILENAME)) end if File.exist?(THEMES_DIRNAME + "#{OPTS[:stylesheet]}.css") STYLESHEET = THEMES_DIRNAME + "#{OPTS[:stylesheet]}.css" STYLESHEET_HEAD = THEMES_DIRNAME + "#{OPTS[:stylesheet]}.html" else STYLESHEET = base_dir + "impress_css/#{OPTS[:stylesheet]}.css" STYLESHEET_HEAD = base_dir + "impress_css/#{OPTS[:stylesheet]}.html" end unless File.exist?(STYLESHEET) puts OPTS[:stylesheet] + " is not a valid stylesheet. See available stylesheets with `mdpress -l`." exit end if File.exist?(DIRNAME) unless File.directory?(DIRNAME) puts "please delete the file: #{DIRNAME} before continuing." exit end else log "making directory" Dir.mkdir(DIRNAME) end render OPTS log "copying files" FileUtils.cp_r(base_dir + "js", DIRNAME) FileUtils.cp_r(base_dir + "css", DIRNAME) FileUtils.cp(STYLESHEET, DIRNAME + "/css/style.css") def auto while true sleep 2 if FileUtils.uptodate?(FILENAME, [DIRNAME + "/index.html"]) log "updating from #{FILENAME}" render OPTS end # Takes care of updating stylesheets for local styles. if FileUtils.uptodate?(STYLESHEET, [DIRNAME + "/css/style.css"]) log "updating stylesheet #{STYLESHEET}" FileUtils.cp(STYLESHEET, DIRNAME + "/css/style.css") end end end if OPTS[:automatic] if ARGV[0] =~ /^http/ puts "Can't run in auto mode for remote files." else log "waiting for updates..." auto end elsif OPTS[:run] log "opening in browser." Launchy.open(DIRNAME + "/index.html", :application => :browser) else log "done." end mdpress-0.0.15/README.md 0000644 0001750 0001750 00000013724 12250154716 014121 0 ustar boutil boutil # mdpress This is a tool that converts markdown files to presentations using impress. # Example [This presentation](http://egonschiele.github.com/mdpress/default) was created from [this markdown file](https://raw.github.com/egonSchiele/mdpress/master/examples/demo.md). [This presentation](http://egonschiele.github.com/mdpress/impress) was created from the same markdown file and a different stylesheet using `mdpress -s [stylesheet name]`. ## Advantages - dead simple, works with any markdown file - comes with a beautiful default stylesheet + more styles (more styles TBD) ... no need to write your own - ...but you can write your own easily if you want! - comes with [prettify](http://code.google.com/p/google-code-prettify/) integrated, does code highlighting out of the box - has an auto-update mode; update your markdown file and mdpress will update your presentation automatically - quick install as a ruby gem - presentations are tiny and easy to distribute - presentations are easy to read as a plain text file ## Install gem install mdpress ## Usage mdpress [filename.md] mdpress [http://www.yourdomain.com/path/to/filename.md] This creates a directory named `filename`. Start the presentation by opening up `index.html`. ## Quickstart (writing your first presentation!) # Chicken Chicken Chicken ## By Chicken --- # Chicken - Chicken - Chicken Chicken Save that as `test.md` and then use `mdpress test.md` to convert it to a presentation. `mdpress` uses [Redcarpet](https://github.com/tanoku/redcarpet), so it can parse whatever markdown you throw at it. We use the horizonal rule, `---`, to indicate the start of a new slide. ### Getting Fancy: adding transformations So far the slide transitions haven't been that exciting. Let's spice them up. Below the `---`, type: = data-x="1000" And re-compile with `mdpress test.md` (you might have to delete your old presentation directory first). Aha! Not bad! We specify transformations with `= [list of transformations]` as the first line of whatever slide we want to apply the transformation to. We could have written = data-x="1000" data-scale="2" To make it scale as well as swipe. ## Possible Attributes - `data-x`, `data-y`, `data-z`: positioning - `data-rotate-x`, `data-rotate-y`, 'data-rotate-z`, `data-rotate`: rotation (`data-rotate` and `data-rotate-z` are exactly the same) - `data-scale`: scale - `id`: used as the slide link. For example, if you use `id=intro`, you can link to that slide using `index.html#/intro`. See [impress.js](https://github.com/bartaz/impress.js/blob/master/index.html) for a broader description of these. Adding this syntax to Markdown feels like kind of a hack, but it's concise. I'm open to suggestions for something better. ## Auto-update Earlier, our workflow involved having to delete the old presentation and recompile every time we made an edit. The better choice is to use the automatic mode: mdpress -a [filename.md] Now, `mdpress` will keep running and check for updates to your markdown file. It will automatically recompile the presentation for you, so you can seamlessly edit your markdown and view your changes instantly. ## Stylesheets `mdpress` comes with a default stylesheet, plus a few more. See the full list of available stylesheets with mdpress -l Or specify a stylesheet to use with mdpress -s [stylesheet] If you make your own stylesheets, send me a pull request and I'll add them to the list! See below. You can also create your own local theme: 1. Use the 'lib/impress_css/' files as a model to work from. 2. Create a folder called 'themes' in the directory where your markdown file is. Inside it put the [yourtheme].css and [yourtheme].html files 3. Call mdpress -s [yourtheme] and mdpress will look for the two theme files in themes/ matching that name. ## Running a presentation Someone emailed you a `mdpress` presentation. Now you want to **just run it**? Sure: mdpress -r [filename.md] That will automatically compile the presentation and open it in a browser window. ## Latex Support mdpress now has Latex support through [MathJax](http://www.mathjax.org/). To build your presentation with latex support, use the `--latex` flag. Put your latex code between a pair of `$$`'s, like this: # Latex! $$e^{\imath\pi} = -1$$ **Note**: you might run into conflicts between markdown and latex. For example, `_` means emphasize in markdown. So if you want subscripts, escape `_`: $a_x$ # wrong, x will be italic $a\_x$ # right, x will be a subscript ## Metadata Metadata can be set via YAML-Frontmatter. Have a look at the examples for further information. For example, if you want to set a title, put this at the top of the markdown file: --- title: All about chicken --- ## Contributing To contribute a new stylesheet, follow these steps: 1. Fork this repo. 2. Place your new stylesheet in `lib/impress_css/[your stylesheet name].css` 3. Send me a pull request! ## Contributors - Mte90 ## License (MIT) Copyright (C) 2012 by Aditya Bhargava Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mdpress-0.0.15/LICENSE 0000644 0001750 0001750 00000002043 12250154716 013637 0 ustar boutil boutil Copyright (c) 2012 Aditya Bhargava Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mdpress-0.0.15/lib/ 0000755 0001750 0001750 00000000000 12250154716 013401 5 ustar boutil boutil mdpress-0.0.15/lib/impress_renderer.rb 0000644 0001750 0001750 00000004572 12250154716 017306 0 ustar boutil boutil require 'redcarpet' class ImpressRenderer < Redcarpet::Render::HTML @@attrs = [] @@current = 0 @@author, @@head, @@title = nil def self.init_with_attrs _attrs, _opts @@attrs = _attrs @@current = 0 @@opts = _opts end def self.author= author @@author = "" end def self.head= head @@head = head end def self.title= title @@title = "
#{code}
"
end
def codespan code
"#{code}
"
end
def mathjax
if @@opts[:latex]
%{
}
end
end
def doc_header
%{
#{@@title}
#{@@author}
#{self.mathjax}
#{@@head}