Module: Markdown

Defined in:
lib/markdown.rb,
lib/markdown/config.rb,
lib/markdown/server.rb,
lib/markdown/cli/gen.rb,
lib/markdown/version.rb,
lib/markdown/wrapper.rb,
lib/markdown/cli/opts.rb,
lib/markdown/cli/runner.rb,
lib/markdown/engines/maruku.rb,
lib/markdown/engines/kramdown.rb,
lib/markdown/engines/bluecloth.rb,
lib/markdown/engines/rdiscount.rb,
lib/markdown/engines/redcarpet.rb,
lib/markdown/engines/pandoc_ruby.rb,
lib/markdown/engines/rpeg_markdown.rb

Defined Under Namespace

Modules: Engine Classes: Config, Converter, Gen, Opts, Runner, Server, Wrapper

Constant Summary collapse

VERSION =
'1.1.1'
@@config =
nil

Class Method Summary collapse

Class Method Details

version string for generator meta tag (includes ruby version)



51
52
53
# File 'lib/markdown.rb', line 51

def self.banner
  "markdown #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end

.create_converter(lib) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/markdown/wrapper.rb', line 92

def self.create_converter( lib )
  if @@config.nil?
    @@config = Config.new
  end

  mn_to_html  = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib   
  mn_version  = @@config.markdown_version_method( lib )

  Converter.new( lib, mn_to_html, mn_version )
end

.dumpObject

dump settings for debug/verbose flag



84
85
86
87
88
89
# File 'lib/markdown/wrapper.rb', line 84

def self.dump   # dump settings for debug/verbose flag
  if @@config.nil?
    @@config = Config.new
  end
  @@config.dump
end

.extnamesObject



70
71
72
73
74
75
# File 'lib/markdown/wrapper.rb', line 70

def self.extnames
  if @@config.nil?
    @@config = Config.new
  end
  @@config.markdown_extnames
end

.filtersObject



77
78
79
80
81
82
# File 'lib/markdown/wrapper.rb', line 77

def self.filters
  if @@config.nil?
    @@config = Config.new
  end
  @@config.markdown_filters
end

.libObject



56
57
58
59
60
61
# File 'lib/markdown/wrapper.rb', line 56

def self.lib
  if @@config.nil?
    @@config = Config.new
  end
  @@config.markdown_lib
end

.lib=(lib) ⇒ Object



49
50
51
52
53
54
# File 'lib/markdown/wrapper.rb', line 49

def self.lib=( lib )
  if @@config.nil?
    @@config = Config.new
  end
  @@config.markdown_lib = lib
end

.libsObject



63
64
65
66
67
68
# File 'lib/markdown/wrapper.rb', line 63

def self.libs
  if @@config.nil?
    @@config = Config.new
  end
  @@config.markdown_libs
end

.mainObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/markdown.rb', line 59

def self.main
  
  # allow env variable to set RUBYOPT-style default command line options
  #   e.g. -o site 
  markdownopt = ENV[ 'MARKDOWNOPT' ]
  
  args = []
  args += markdownopt.split if markdownopt
  args += ARGV.dup
  
  Runner.new.run(args)
end

.new(content, options = {}) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/markdown/wrapper.rb', line 104

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)
  
  if @@config.nil?
    @@config = Config.new
  end

  lib      = @@config.markdown_lib
  mn       = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib   
  defaults = @@config.markdown_lib_defaults( lib )  ## 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

.rootObject



55
56
57
# File 'lib/markdown.rb', line 55

def self.root
  "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
end