Sha256: e4cd7944478a2ceac90fd33ad3914c8e81ba6e33b56e9b1500eb2a226b6a838c
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require "metadown/renderer" require "metadown/metadata_parser" require "metadown/version" # This module namespaces everything in the gem. It's also where the factory # #render method lives. module Metadown # This struct is what gets returned from a call to #render. # # It has two attributes, one for the metadata, and one for the rendered # output. Data = Struct.new(:metadata, :output) # 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. def render(text, renderer=nil) return redcarpet_render(text) if renderer.nil? metadata = MetadataParser.new(text).parse Data.new(metadata, renderer.new { text }.render) end module_function :render # Classic compatiblity mode: fall back to old redcarpet renderer def redcarpet_render(text) renderer = Renderer.new markdown = Redcarpet::Markdown.new(renderer) output = markdown.render(text) Data.new(renderer.metadata, output) end module_function :redcarpet_render end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metadown-1.1.0.beta | lib/metadown.rb |