lib/markdown/wrapper.rb in markdown-1.0.0 vs lib/markdown/wrapper.rb in markdown-1.1.0

- old
+ new

@@ -1,34 +1,37 @@ module Markdown class Wrapper def initialize( lib, mn, content, options={} ) - @lib = lib + @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 + end include Engine - + end # class Wrapper @@config = nil - - def self.lib=( value ) - ## todo: lets you select your library + + def self.lib=( lib ) + if @@config.nil? + @@config = Config.new + end + @@config.markdown_lib = lib end - + def self.lib if @@config.nil? @@config = Config.new end @@config.markdown_lib @@ -52,12 +55,22 @@ if @@config.nil? @@config = Config.new end @@config.dump end - - + + def self.new( content, options={} ) + + ## options + ## make sure keys are strings, that is, allow symbols for easy use + ## but internally only use string (yaml gets use strings) + + ## fix: use stringify_keys! from activesupport (include dependency ?? why? why not??) + options.keys.each do |key| + options[ key.to_s ] = options.delete(key) + end + ## 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) \ No newline at end of file