Module: Markdown

Defined in:
lib/markdown/config.rb,
lib/markdown/version.rb,
lib/markdown/wrapper.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, Wrapper

Constant Summary collapse

MAJOR =
1
MINOR =
2
PATCH =
1
VERSION =
[MAJOR,MINOR,PATCH].join('.')
@@config =
nil

Class Method Summary collapse

Class Method Details

version string for generator meta tag (includes ruby version)



16
17
18
# File 'lib/markdown/version.rb', line 16

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

.create_converter(lib) ⇒ Object



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

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



86
87
88
89
90
91
# File 'lib/markdown/wrapper.rb', line 86

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

.extnamesObject



72
73
74
75
76
77
# File 'lib/markdown/wrapper.rb', line 72

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

.filtersObject



79
80
81
82
83
84
# File 'lib/markdown/wrapper.rb', line 79

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

.libObject



58
59
60
61
62
63
# File 'lib/markdown/wrapper.rb', line 58

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

.lib=(lib) ⇒ Object



51
52
53
54
55
56
# File 'lib/markdown/wrapper.rb', line 51

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

.libsObject



65
66
67
68
69
70
# File 'lib/markdown/wrapper.rb', line 65

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

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



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
132
133
# File 'lib/markdown/wrapper.rb', line 106

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



20
21
22
# File 'lib/markdown/version.rb', line 20

def self.root
  File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
end

.versionObject



10
11
12
# File 'lib/markdown/version.rb', line 10

def self.version
  VERSION
end