Sha256: 212944cc3091916cf33ffa4bf683c0fcdf512275dc3deead4102c0edb5a8b82c
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'redcarpet' require 'pygments.rb' module MarkItZero class HTMLwithPygments < Redcarpet::Render::HTML def block_code(code, language) Pygments.highlight(code, :lexer => language, :options => { :linespans => 'line' } ) end end class Markdown @@renderer = Redcarpet::Markdown.new( HTMLwithPygments.new(:hard_wrap => false, :with_toc_data => true), { :autolink => true, :fenced_code_blocks => true, :highlight => true, :space_after_headers => true, :strikethrough => true, :tables => true, :underline => true, } ) def self.cleanse(text) return "" if text.blank? text.gsub( /(?:http[s]?:\/\/)?(?:www\.)?(?:youtu\.be)\/(?:watch\?v=)?(.+)/, '<iframe width="420" height="345" src="http://www.youtube.com/embed/\1" frameborder="0" allowfullscreen></iframe>' ).gsub( /[”“]/, '"' ).gsub( /\[file\:(.*)\]/, '<p class="file"><code>\1</code></p>' ) end def self.to_html(text) @@renderer.render(cleanse(text)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mark_it_zero-0.3.2 | lib/mark_it_zero/markdown.rb |
mark_it_zero-0.3.1 | lib/mark_it_zero/markdown.rb |