Class: Makeup::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/makeup/markup.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Markup

Returns a new instance of Markup.



52
53
54
55
# File 'lib/makeup/markup.rb', line 52

def initialize(options = {})
  @markup_class_name = options[:markup_class_name] || "prettyprint"
  @highlighter = options[:highlighter] || NoopHighlighter.new
end

Class Method Details

.can_render?(path) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/makeup/markup.rb', line 70

def self.can_render?(path)
  GitHub::Markup.can_render?(path)
end

.markupsObject



74
75
76
# File 'lib/makeup/markup.rb', line 74

def self.markups
  GitHubMarkupAccessor.markups
end

Instance Method Details

#highlight_code_blocks(path, markup) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/makeup/markup.rb', line 62

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) ⇒ Object



57
58
59
60
# File 'lib/makeup/markup.rb', line 57

def render(path, content)
  content = highlight_code_blocks(path, content)
  GitHub::Markup.render(path, content)
end