Class: Makeup::Markup
- Inherits:
-
Object
- Object
- Makeup::Markup
- Defined in:
- lib/makeup/markup.rb
Class Method Summary collapse
Instance Method Summary collapse
- #highlight_code_blocks(path, markup) ⇒ Object
-
#initialize(options = {}) ⇒ Markup
constructor
A new instance of Markup.
- #render(path, content) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Markup
Returns a new instance of Markup.
52 53 54 55 |
# File 'lib/makeup/markup.rb', line 52 def initialize( = {}) @markup_class_name = [:markup_class_name] || "prettyprint" @highlighter = [:highlighter] || NoopHighlighter.new end |
Class Method Details
.can_render?(path) ⇒ Boolean
70 71 72 |
# File 'lib/makeup/markup.rb', line 70 def self.can_render?(path) GitHub::Markup.can_render?(path) end |
.markups ⇒ Object
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 |