class MarkItZero::Markdown
Public Class Methods
cleanse(text)
click to toggle source
# File lib/mark_it_zero/markdown.rb, line 28 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)
click to toggle source
# File lib/mark_it_zero/markdown.rb, line 42 def self.to_html(text) @@renderer.render(cleanse(text)) end