Created
          March 27, 2013 11:28 
        
      - 
      
- 
        Save carwin/5253509 to your computer and use it in GitHub Desktop. 
    GitHub Flavored Markdown Processor
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/ruby | |
| require 'rubygems' | |
| require 'redcarpet' | |
| require 'albino' | |
| class SyntaxRenderer < Redcarpet::Render::HTML | |
| def block_code(code, language) | |
| if language && !language.empty? | |
| Albino.colorize(code, language) | |
| else | |
| "<pre><code>#{code}</code></pre>" | |
| end | |
| end | |
| end | |
| def markdown(text) | |
| renderer = SyntaxRenderer.new(optionize [ | |
| :with_toc_data, | |
| #:hard_wrap, | |
| :xhtml | |
| ]) | |
| markdown = Redcarpet::Markdown.new(renderer, optionize([ | |
| :fenced_code_blocks, | |
| :no_intra_emphasis, | |
| :tables, | |
| :superscript, | |
| :autolink, | |
| :strikethrough, | |
| :space_after_headers, | |
| :with_toc_data, | |
| #:no_styles, | |
| :lax_spacing | |
| ])) | |
| markdown.render(text) | |
| end | |
| def optionize(options) | |
| options.inject({}) { |memo, option| memo[option] = true; memo } | |
| end | |
| puts markdown(ARGF.read) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Check out my fork, overrode the build in header rendering function to use semanticised versions of the header text as the ids for using with internal links.