Class: MarkItZero::Markdown
- Inherits:
-
Object
- Object
- MarkItZero::Markdown
- Defined in:
- lib/mark_it_zero/markdown.rb
Constant Summary collapse
- @@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, } )
Class Method Summary collapse
Class Method Details
.cleanse(text) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mark_it_zero/markdown.rb', line 27 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 |
.to_html(text) ⇒ Object
41 42 43 |
# File 'lib/mark_it_zero/markdown.rb', line 41 def self.to_html(text) @@renderer.render(cleanse(text)) end |