Skip to content

Instantly share code, notes, and snippets.

@fielding
Created April 6, 2012 09:18
Show Gist options
  • Save fielding/2318434 to your computer and use it in GitHub Desktop.
Save fielding/2318434 to your computer and use it in GitHub Desktop.
gfm-pre-processor
#!/usr/bin/env ruby
require 'rubygems'
require 'redcarpet'
require 'Pygments'
class HTMLwithPygments < Redcarpet::Render::XHTML
# def doc_header()
# puts Pygments.styles()
# monokai
# manni
# perldoc
# borland
# colorful
# default
# murphy
# vs
# trac
# tango
# fruity
# autumn
# bw
# emacs
# vim
# pastie
# friendly
# native
# '<style>' + Pygments.css('.highlight',:style => 'vs') + '</style>'
# end
def block_code(code, language)
Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'})
end
end
def fromMarkdown(text)
# options = [:fenced_code => true, :generate_toc => true, :hard_wrap => true, :no_intraemphasis => true, :strikethrough => true ,:gh_blockcode => true, :autolink => true, :xhtml => true, :tables => true]
markdown = Redcarpet::Markdown.new(HTMLwithPygments,
:fenced_code_blocks => true,
:no_intra_emphasis => true,
:autolink => true,
:strikethrough => true,
:lax_html_blocks => true,
:superscript => true,
:hard_wrap => true,
:tables => true,
:xhtml => true)
markdown.render(text)
end
puts fromMarkdown(ARGF.read)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment