Skip to content

Instantly share code, notes, and snippets.

@nathany nathany/app.rb
Created Feb 17, 2013

Embed
What would you like to do?
Configuring Nesta CMS to use Redcarpet and Pygments.rb.
require 'redcarpet'
require 'pygments'
class Syntactical < Redcarpet::Render::HTML
include Redcarpet::Render::SmartyPants
def block_code(code, language)
Pygments.highlight(code, lexer: language)
end
end
class SyntacticalTemplate < Tilt::RedcarpetTemplate::Redcarpet2
def generate_renderer
Syntactical.new(hard_wrap: false, with_toc_data: true)
end
def prepare
# override the options to include code fencing, etc.
opts = {
no_intra_emphasis: true,
tables: true,
fenced_code_blocks: true,
autolink: true,
strikethrough: true,
lax_html_blocks: true,
space_after_headers: false,
superscript: true
}
@engine = Redcarpet::Markdown.new(generate_renderer, opts)
@output = nil
end
end
Tilt::register SyntacticalTemplate, 'mdown'
Tilt.prefer SyntacticalTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.