class Makeup::Markup
Public Class Methods
can_render?(path)
click to toggle source
# File lib/makeup/markup.rb, line 61 def self.can_render?(path) GitHub::Markup.can_render?(path) end
markups()
click to toggle source
# File lib/makeup/markup.rb, line 65 def self.markups GitHub::Markup.markups end
new(options = {})
click to toggle source
# File lib/makeup/markup.rb, line 39 def initialize(options = {}) @markup_class_name = options[:markup_class_name] || "prettyprint" @highlighter = options[:highlighter] || NoopHighlighter.new end
Public Instance Methods
highlight_code_blocks(path, markup)
click to toggle source
# File lib/makeup/markup.rb, line 53 def highlight_code_blocks(path, markup) return markup unless path =~ /\.(md|mkdn?|mdwn|mdown|markdown)$/ CodeBlockParser.parse(markup) do |lexer, code| hb = @highlighter.highlight(path, code, { :lexer => lexer }) "<pre class=\"#{hb.lexer} #{@markup_class_name}\">#{hb.code}</pre>" end end
render(path, content)
click to toggle source
# File lib/makeup/markup.rb, line 44 def render(path, content) content = highlight_code_blocks(path, content) sanitize(GitHub::Markup.render(path, content)) end
sanitize(html)
click to toggle source
# File lib/makeup/markup.rb, line 49 def sanitize(html) Loofah.fragment(html).scrub!(:prune).to_s end