Module: Metadown
- Defined in:
- lib/metadown.rb,
lib/metadown/version.rb,
lib/metadown/renderer.rb,
lib/metadown/metadata_parser.rb
Overview
This module namespaces everything in the gem. It's also where the factory #render method lives.
Defined Under Namespace
Classes: Data, MetadataParser, Renderer
Constant Summary
- VERSION =
The current released version of Metadown
"1.1.0.beta"
Instance Method Summary (collapse)
-
- (Object) redcarpet_render(text)
Classic compatiblity mode: fall back to old redcarpet renderer.
-
- (Object) render(text, renderer = nil)
The render method is a convenient factory.
Instance Method Details
- (Object) redcarpet_render(text)
Classic compatiblity mode: fall back to old redcarpet renderer
28 29 30 31 32 33 34 35 |
# File 'lib/metadown.rb', line 28 def redcarpet_render(text) renderer = Renderer.new markdown = Redcarpet::Markdown.new(renderer) output = markdown.render(text) Data.new(renderer., output) end |
- (Object) render(text, renderer = nil)
The render method is a convenient factory. If we give it text, it delegates to the classic markdown renderer, otherwise, we can inject one of our own.
18 19 20 21 22 23 24 |
# File 'lib/metadown.rb', line 18 def render(text, renderer=nil) return redcarpet_render(text) if renderer.nil? = MetadataParser.new(text).parse Data.new(, renderer.new { text }.render) end |