Sha256: 70a938138bc0612aca8fc3d057fa4b5d9087fc738fc9fabfcbe7e64e0a25c4a0
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
module Markdown class Wrapper def initialize( lib, mn, content, options={} ) @lib = lib @mn = mn @content = content @options = options end def to_html # call markdown filter; turn markdown lib name into method_name (mn) # eg. rpeg-markdown => rpeg_markdown_to_html send( @mn, @content, @options ) # call 1st configured markdown engine e.g. kramdown_to_html( content ) end include Engine end # class Wrapper @@config = nil def self.lib=( value ) ## todo: lets you select your library end def self.lib if @@config.nil? @@config = Config.new end @@config.markdown_lib end def self.extnames if @@config.nil? @@config = Config.new end @@config.markdown_extnames end def self.new( content, options={} ) ## todo: allow options to pass in ## lets you change markdown engine/converter for every call ## e.g. lets you add config properties (as headers) to your document (for example) if @@config.nil? @@config = Config.new end lib = @@config.markdown_lib mn = @@config.markdown_to_html_method # lets you use differnt options/converters for a single markdown lib defaults = @@config.markdown_lib_defaults ## todo/fix: use mn / converter from defaults hash?? mn no longer needed?? props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' )) Wrapper.new( lib, mn, content, props ) end end # module Markdown
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
markdown-0.2.0 | lib/markdown/wrapper.rb |