Created
March 18, 2012 17:51
-
-
Save peterhellberg/2078566 to your computer and use it in GitHub Desktop.
GitHub Flavored Markdown parser for use with Jekyll and Marked.app
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/env ruby | |
require 'rubygems' | |
require 'redcarpet' | |
require 'pygments.rb' | |
class HTMLwithPygments < Redcarpet::Render::HTML | |
def block_code(code, language) | |
Pygments.highlight(code, :lexer => language.to_sym, :options => { | |
:encoding => 'utf-8' | |
}) | |
end | |
end | |
def from_markdown(text) | |
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 => false, | |
:tables => true, | |
:xhtml => false) | |
text.gsub!(/\{\{( *)?"(.*?)"\}\}/, '\1\2') | |
text.gsub!(/^\{% highlight (.+?) ?%\}(.*?)^\{% endhighlight %\}/m) do |match| | |
Pygments.highlight($2, :lexer => $1, :options => {:encoding => 'utf-8'}) | |
end | |
markdown.render(text) | |
end | |
puts from_markdown(ARGF.read) |
I'm not a ruby programmer. How do I set it up to work with Jekyll?
Looks like they added GFM to Marked.app
http://support.markedapp.com/kb/how-to-tips-and-tricks/using-marked-with-github-flavored-markdown-and-syntax-highlighting
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cboettig I’m not sure. I generally deploy to one of my private servers. But you are welcome to try :)