markdown 0.0.1 → 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/Manifest.txt CHANGED
@@ -2,7 +2,15 @@ History.markdown
2
2
  Manifest.txt
3
3
  README.markdown
4
4
  Rakefile
5
- lib/markdown_select.rb
6
- lib/markdown_select/config.rb
7
- lib/markdown_select/engine.rb
8
- lib/markdown_select/markdown_select.rb
5
+ bin/markdown
6
+ lib/markdown.rb
7
+ lib/markdown/config.rb
8
+ lib/markdown/engines/bluecloth.rb
9
+ lib/markdown/engines/kramdown.rb
10
+ lib/markdown/engines/maruku.rb
11
+ lib/markdown/engines/pandoc_ruby.rb
12
+ lib/markdown/engines/rdiscount.rb
13
+ lib/markdown/engines/rpeg_markdown.rb
14
+ lib/markdown/gen.rb
15
+ lib/markdown/wrapper.rb
16
+ test/test_kramdown.rb
data/README.markdown CHANGED
@@ -1,11 +1,11 @@
1
- # Markdown Select - Use Your Markdown Library of Choice
1
+ # Markdown Engine Wrapper - Use Your Markdown Library of Choice
2
2
 
3
- * [geraldb.github.com/markdown_select](http://geraldb.github.com/markdown_select)
3
+ * [geraldb.github.com/markdown](http://geraldb.github.com/markdown)
4
4
 
5
5
  ## Description
6
6
 
7
- The Markdown Select (`markdown_select`) Ruby gem lets you use your markdown library of choice.
8
- Preconfigured markdown libraries include:
7
+ The Markdown Engine Wrapper (`markdown`) Ruby gem lets you use
8
+ your markdown library of choice. Preconfigured markdown libraries include:
9
9
 
10
10
  * `kramdown`
11
11
  * `bluecloth`
@@ -17,16 +17,74 @@ Preconfigured markdown libraries include:
17
17
 
18
18
  ## Usage
19
19
 
20
- require 'markdown_select'
20
+ require 'markdown'
21
21
 
22
- MarkdownSelect.new( 'Hello World' ).to_html
22
+ Markdown.new( 'Hello World' ).to_html
23
23
 
24
24
 
25
25
  ## Install
26
26
 
27
27
  Just install the gem:
28
28
 
29
- $ gem install markdown_select
29
+ $ gem install markdown
30
+
31
+
32
+ ## Configuration - Markdown Engine Loading Order
33
+
34
+ The default fallback loading order is:
35
+
36
+ `pandoc-ruby`, `kramdown`, `bluecloth`, `maruku`, `rpeg-markdown`, `rdiscount`
37
+
38
+ To use your markdown engine of choice configure the wrapper. The wrapper
39
+ uses the following lookup order to find the markdown engine to configure:
40
+
41
+ 1) `MARKDOWN_LIB` environment variable
42
+
43
+ Example:
44
+
45
+ set MARKDOWN_LIB=kramdown
46
+
47
+ 2) `lib` property (in `./markdown.yml` or `~/markdown.yml`)
48
+
49
+ Example:
50
+
51
+ lib: kramdown
52
+
53
+ 3) `libs` property (in `./markdown.yml` or `~/markdown.yml`) - first-come first-serve markdown engine loading list (defaults to builtin list).
54
+
55
+ Example:
56
+
57
+ libs:
58
+ - rdiscount
59
+ - kramdown
60
+
61
+
62
+ ## Converters
63
+
64
+ The Markdown Wrapper lets you configure different converter methods for each markdown engine. By default
65
+ the converter method *<lib>*_to_html gets used
66
+ (for example, the default converter for `kramdown` is `kramdown_to_html`).
67
+
68
+ ...
69
+
70
+ Example:
71
+
72
+ pandoc-ruby:
73
+ converter: pandoc-ruby-to-s5
74
+
75
+
76
+
77
+ ## Real World Usage
78
+
79
+ The [`slideshow`](http://slideshow.rubyforge.org) (also known as Slide Show (S9)) gem
80
+ that lets you create slide shows
81
+ and author slides in plain text using a wiki-style markup language that's easy-to-write and easy-to-read
82
+ ships with the `markdown` gem.
83
+
84
+
85
+ ## Alternatives
86
+
87
+ [`multi_markdown`](https://github.com/postmodern/multi_markdown) gem by Hal Brodigan
30
88
 
31
89
 
32
90
  ## Questions? Comments?
@@ -38,5 +96,5 @@ Thanks!
38
96
 
39
97
  ## License
40
98
 
41
- The `markdown_select` scripts are dedicated to the public domain.
99
+ The `markdown` scripts are dedicated to the public domain.
42
100
  Use it as you please with no restrictions whatsoever.
data/Rakefile CHANGED
@@ -1,12 +1,14 @@
1
1
  require 'hoe'
2
- require './lib/markdown_select.rb'
2
+ require './lib/markdown.rb'
3
3
 
4
4
  Hoe.spec 'markdown' do
5
5
 
6
- self.version = MarkdownSelect::VERSION
6
+ self.version = Markdown::VERSION
7
7
 
8
- self.summary = 'Markdown - Use Your Markdown Library of Choice'
9
- self.url = 'http://geraldb.github.com/markdown_select'
8
+ self.summary = 'Markdown Engine Wrapper - Use Your Markdown Library of Choice'
9
+ self.description = summary
10
+
11
+ self.urls = ['http://geraldb.github.com/markdown']
10
12
 
11
13
  self.author = 'Gerald Bauer'
12
14
  self.email = 'webslideshow@googlegroups.com'
data/bin/markdown ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/markdown
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/markdown
13
+ #
14
+
15
+
16
+ require 'rubygems'
17
+ require 'markdown'
18
+
19
+ Markdown.main
data/lib/markdown.rb ADDED
@@ -0,0 +1,54 @@
1
+ ###
2
+ # NB: for local testing run like:
3
+ #
4
+ # 1.8.x: ruby -Ilib -rrubygems lib/markdown.rb
5
+ # 1.9.x: ruby -Ilib lib/markdown.rb
6
+
7
+ # core and stlibs
8
+
9
+ require 'yaml'
10
+ require 'pp'
11
+ require 'logger'
12
+ require 'optparse'
13
+ require 'fileutils'
14
+
15
+
16
+ # our own code
17
+
18
+ require 'markdown/config'
19
+ require 'markdown/engines/bluecloth'
20
+ require 'markdown/engines/kramdown'
21
+ require 'markdown/engines/maruku'
22
+ require 'markdown/engines/pandoc_ruby'
23
+ require 'markdown/engines/rdiscount'
24
+ require 'markdown/engines/rpeg_markdown'
25
+ require 'markdown/wrapper'
26
+ require 'markdown/gen'
27
+
28
+
29
+ module Markdown
30
+
31
+ VERSION = '0.1.0.beta1'
32
+
33
+ # version string for generator meta tag (includes ruby version)
34
+ def self.banner
35
+ "Markdown #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
36
+ end
37
+
38
+ def self.main
39
+
40
+ # allow env variable to set RUBYOPT-style default command line options
41
+ # e.g. -o site
42
+ markdownopt = ENV[ 'MARKDOWNOPT' ]
43
+
44
+ args = []
45
+ args += markdownopt.split if markdownopt
46
+ args += ARGV.dup
47
+
48
+ Gen.new.run(args)
49
+ end
50
+
51
+ end # module Markdown
52
+
53
+
54
+ Markdown.main if __FILE__ == $0
@@ -0,0 +1,168 @@
1
+ module Markdown
2
+
3
+ class Env
4
+ def self.home
5
+ path = if( ENV['HOME'] || ENV['USERPROFILE'] )
6
+ ENV['HOME'] || ENV['USERPROFILE']
7
+ elsif( ENV['HOMEDRIVE'] && ENV['HOMEPATH'] )
8
+ "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
9
+ else
10
+ begin
11
+ File.expand_path('~')
12
+ rescue
13
+ if File::ALT_SEPARATOR
14
+ 'C:/'
15
+ else
16
+ '/'
17
+ end
18
+ end
19
+ end
20
+
21
+ puts "env home=>#{path}<"
22
+ path
23
+ end
24
+
25
+ def self.markdown_lib
26
+ ENV['MARKDOWN_LIB']
27
+ end
28
+ end # class Env
29
+
30
+ class Props
31
+
32
+ attr_reader :path
33
+ attr_reader :parent
34
+
35
+ def initialize( hash, path, parent=nil)
36
+ @hash = hash
37
+ @path = path
38
+ @parent = parent
39
+ end
40
+
41
+ def self.load_file( path, parent=nil )
42
+ h = YAML.load_file( path )
43
+ puts "dump of >#{path}<:"
44
+ pp h # todo: add debug flag (turn off for default)
45
+ Props.new( h, path, parent )
46
+ end
47
+
48
+ def [](key) get( key ); end
49
+
50
+ def fetch(key, default)
51
+ value = get( key )
52
+ value.nil? ? default : value
53
+ end
54
+
55
+ private
56
+ def get( key )
57
+ value = @hash[ key.to_s ]
58
+ # if not found try lookup in parent hash
59
+ (value.nil? && parent) ? parent[key] : value
60
+ end
61
+
62
+ end # class props
63
+
64
+
65
+ class Config
66
+
67
+ # note: only kramdown is listed as a dependency in gem specs (because it's Ruby only and, thus, easy to install)
68
+ # if you want to use other markdown libs install the required/desired lib e.g.
69
+ # use gem install rdiscount for rdiscount and so on
70
+ #
71
+ # also note for now the first present markdown library gets used
72
+ # the search order is first come, first serve, that is: rdiscount, rpeg-markdown, maruku, bluecloth, kramdown (fallback, always present)
73
+
74
+ # DEFAULTS = {
75
+ # 'libs' => [ 'pandoc-ruby',
76
+ # 'rdiscount',
77
+ # 'rpeg-markdown',
78
+ # 'maruku',
79
+ # 'bluecloth',
80
+ # 'kramdown' ] }
81
+
82
+ # note: make kramdown default engine
83
+ DEFAULTS = { 'libs' => [ 'kramdown' ] }
84
+
85
+
86
+ def initialize
87
+ @props = @props_default = Props.new( DEFAULTS, 'DEFAULTS' )
88
+
89
+ # check for user settings (markdown.yml) in home folder
90
+
91
+ ## todo/fix: use join path???
92
+ ## todo: use .markdown.yml?? or differnt name ??
93
+ props_home_file = "#{Env.home}/markdown.yml"
94
+ if File.exists?( props_home_file )
95
+ puts "Loading settings from '#{props_home_file}'..."
96
+ @props = @props_home = Props.load_file( props_home_file, @props )
97
+ end
98
+
99
+ # check for user settings (markdown.yml) in working folder
100
+
101
+ props_work_file = "./markdown.yml"
102
+ if File.exists?( props_work_file )
103
+ puts "Loading settings from '#{props_work_file}'..."
104
+ @props = @props_work = Props.load_file( props_work_file, @props )
105
+ end
106
+
107
+ @libs = []
108
+ @mn = nil # markdown converter method name (mn) e.g. kramdown_to_html
109
+
110
+ require_markdown_libs()
111
+ end
112
+
113
+ def known_markdown_libs
114
+ # returns an array of known markdown engines e.g.
115
+ # [ 'pandoc-ruby', 'rdiscount', 'rpeg-markdown', 'maruku', 'bluecloth', 'kramdown' ]
116
+
117
+ ## todo: allow single lib para instead of libs
118
+ ## todo: allow ENV setting markdown_[select]_lib=xxxx
119
+
120
+ ## todo/fix: use lookup with config parent cascade
121
+
122
+
123
+ ## lookup order
124
+ ## 1) env variable MARKDOWN_LIB
125
+ ## 2) lib property (single markdown engine)
126
+ ## 3) libs property (first-come first-serve markdown engine list)
127
+
128
+ user_lib = Env.markdown_lib || @props.fetch( 'lib', nil )
129
+
130
+ if user_lib.nil?
131
+ user_libs = @props.fetch( 'libs', nil )
132
+ else
133
+ [ user_lib ] # return as array (wrap single lib entry)
134
+ end
135
+ end
136
+
137
+
138
+ def require_markdown_libs
139
+
140
+ # check for available markdown libs/gems
141
+ # try to require each lib and remove any not installed
142
+
143
+ known_markdown_libs.each do |lib|
144
+ begin
145
+ require lib
146
+ @libs << lib
147
+ rescue LoadError => ex
148
+ ## todo: use logger.debug instead of puts
149
+ puts "Markdown library #{lib} not found. Use gem install #{lib} to install."
150
+ end
151
+ end
152
+
153
+ puts " Found #{@libs.length} Markdown libraries: #{@libs.join(', ')}"
154
+ end
155
+
156
+ def markdown_lib
157
+ @libs.first
158
+ end
159
+
160
+ def markdown_to_html_method
161
+ lib = @libs.first
162
+ opts = @props.fetch( lib, {} )
163
+ method = opts.fetch( 'converter', "#{lib.downcase}_to_html" ) # default to <lib>_to_html if converter prop not found
164
+ method.tr('-','_').to_sym
165
+ end
166
+
167
+ end # class Config
168
+ end # module Markdown
@@ -0,0 +1,9 @@
1
+ module Markdown
2
+ module Engine
3
+
4
+ def bluecloth_to_html( content )
5
+ BlueCloth.new( content ).to_html
6
+ end
7
+
8
+ end # module Engine
9
+ end # module Markdown
@@ -0,0 +1,9 @@
1
+ module Markdown
2
+ module Engine
3
+
4
+ def kramdown_to_html( content )
5
+ Kramdown::Document.new( content ).to_html
6
+ end
7
+
8
+ end # module Engine
9
+ end # module Markdown
@@ -0,0 +1,9 @@
1
+ module Markdown
2
+ module Engine
3
+
4
+ def maruku_to_html( content )
5
+ Maruku.new( content, {:on_error => :raise} ).to_html
6
+ end
7
+
8
+ end # module Engine
9
+ end # module Markdown
@@ -1,4 +1,4 @@
1
- module MarkdownSelect
1
+ module Markdown
2
2
  module Engine
3
3
 
4
4
  def pandoc_ruby_to_html( content )
@@ -30,30 +30,5 @@ module MarkdownSelect
30
30
  content = content.to_a[13..-1].join # remove the layout div
31
31
  end
32
32
 
33
-
34
- def rdiscount_to_html( content )
35
- RDiscount.new( content ).to_html
36
- end
37
-
38
-
39
- def rpeg_markdown_to_html( content )
40
- PEGMarkdown.new( content ).to_html
41
- end
42
-
43
-
44
- def maruku_to_html( content )
45
- Maruku.new( content, {:on_error => :raise} ).to_html
46
- end
47
-
48
-
49
- def bluecloth_to_html( content )
50
- BlueCloth.new( content ).to_html
51
- end
52
-
53
-
54
- def kramdown_to_html( content )
55
- Kramdown::Document.new( content ).to_html
56
- end
57
-
58
33
  end # module Engine
59
- end # module MarkdownSelect
34
+ end # module Markdown
@@ -0,0 +1,9 @@
1
+ module Markdown
2
+ module Engine
3
+
4
+ def rdiscount_to_html( content )
5
+ RDiscount.new( content ).to_html
6
+ end
7
+
8
+ end # module Engine
9
+ end # module Markdown
@@ -0,0 +1,9 @@
1
+ module Markdown
2
+ module Engine
3
+
4
+ def rpeg_markdown_to_html( content )
5
+ PEGMarkdown.new( content ).to_html
6
+ end
7
+
8
+ end # module Engine
9
+ end # module Markdown
@@ -0,0 +1,151 @@
1
+ module Markdown
2
+
3
+
4
+ class Opts
5
+
6
+ def initialize
7
+ @hash = {}
8
+ end
9
+
10
+ def put( key, value )
11
+ @hash[ key.to_s ] = value
12
+ end
13
+
14
+ def output_path
15
+ @hash.fetch( 'output', '.' )
16
+ end
17
+
18
+ end # class Opts
19
+
20
+
21
+
22
+ class Gen
23
+
24
+ attr_reader :logger
25
+ attr_reader :opts
26
+
27
+ def initialize
28
+ @logger = Logger.new(STDOUT)
29
+ @logger.level = Logger::INFO
30
+ @opts = Opts.new
31
+ end
32
+
33
+ def with_output_path( dest, output_path )
34
+ dest_full = File.expand_path( dest, output_path )
35
+ logger.debug "dest_full=#{dest_full}"
36
+
37
+ # make sure dest path exists
38
+ dest_path = File.dirname( dest_full )
39
+ logger.debug "dest_path=#{dest_path}"
40
+ FileUtils.makedirs( dest_path ) unless File.directory? dest_path
41
+ dest_full
42
+ end
43
+
44
+ def create_doc( fn )
45
+
46
+ # expand output path in current dir and make sure output path exists
47
+ outpath = File.expand_path( opts.output_path )
48
+ logger.debug "outpath=#{outpath}"
49
+ FileUtils.makedirs( outpath ) unless File.directory? outpath
50
+
51
+ dirname = File.dirname( fn )
52
+ basename = File.basename( fn, '.*' )
53
+ extname = File.extname( fn )
54
+ logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
55
+
56
+ # change working dir to sourcefile dir
57
+ # todo: add a -c option to commandline? to let you set cwd?
58
+
59
+ newcwd = File.expand_path( dirname )
60
+ oldcwd = File.expand_path( Dir.pwd )
61
+
62
+ unless newcwd == oldcwd then
63
+ logger.debug "oldcwd=#{oldcwd}"
64
+ logger.debug "newcwd=#{newcwd}"
65
+ Dir.chdir newcwd
66
+ end
67
+
68
+ if extname.empty? then
69
+ extname = ".markdown" # default to .markdown
70
+
71
+ [ '.markdown', '.m', '.mark', '.mkdn', '.md', '.txt', '.text' ].each do |e|
72
+ logger.debug "File.exists? #{dirname}/#{basename}#{e}"
73
+ if File.exists?( "#{dirname}/#{basename}#{e}" ) then
74
+ extname = e
75
+ logger.debug "extname=#{extname}"
76
+ break
77
+ end
78
+ end # each extension (e)
79
+ end
80
+
81
+ inname = "#{dirname}/#{basename}#{extname}"
82
+
83
+ puts "Reading document '#{basename}#{extname}'..."
84
+
85
+
86
+ logger.debug "inname=#{inname}"
87
+
88
+ content = File.read( inname )
89
+
90
+ # convert light-weight markup to hypertext
91
+
92
+ content = Markdown.new( content ).to_html
93
+
94
+ outname = "#{basename}.html"
95
+ puts "Preparing #{outname}..."
96
+
97
+ out = File.new( with_output_path( outname, outpath ), "w+" )
98
+ out << "<!-- ======================================================================\n"
99
+ out << " generated by #{Markdown.banner}\n"
100
+ out << " on #{Time.now} with Markdown engine '#{Markdown.lib}'\n"
101
+ out << " ====================================================================== -->\n"
102
+ out << content
103
+ out.flush
104
+ out.close
105
+
106
+ end # method create_doc
107
+
108
+
109
+ def run( args )
110
+ opt=OptionParser.new do |cmd|
111
+
112
+ cmd.banner = "Usage: markdown [options] name"
113
+
114
+ cmd.on( '-o', '--output PATH', 'Output Path' ) { |s| opts.put( 'output', s ) }
115
+
116
+ # todo: find different letter for debug trace switch (use v for version?)
117
+ cmd.on( "-v", "--verbose", "Show debug trace" ) do
118
+ logger.datetime_format = "%H:%H:%S"
119
+ logger.level = Logger::DEBUG
120
+ end
121
+
122
+ cmd.on_tail( "-h", "--help", "Show this message" ) do
123
+ puts
124
+ puts "Markdown is ..."
125
+ puts
126
+ puts cmd.help
127
+ puts
128
+ puts "Examples:"
129
+ puts " markdown microformats"
130
+ puts " markdown microformats.text # Process slides using Markdown"
131
+ puts " markdown -o site microformats # Output slideshow to slides folder"
132
+ puts
133
+ puts "Further information:"
134
+ puts " http://geraldb.github.com/markdown"
135
+ exit
136
+ end
137
+ end
138
+
139
+ opt.parse!( args )
140
+
141
+ puts Markdown.banner
142
+
143
+ args.each { |fn| create_doc( fn ) }
144
+
145
+ puts "Done."
146
+
147
+ end # method run
148
+
149
+ end # class Gen
150
+
151
+ end # module Markdown
@@ -0,0 +1,55 @@
1
+ module Markdown
2
+
3
+ class Wrapper
4
+
5
+ def initialize( lib, mn, content, options={} )
6
+ @lib = lib
7
+ @mn = mn
8
+ @content = content
9
+ @options = options
10
+ end
11
+
12
+ def to_html
13
+ # call markdown filter; turn markdown lib name into method_name (mn)
14
+ # eg. rpeg-markdown => rpeg_markdown_to_html
15
+
16
+ puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library '#{@lib}' calling '#{@mn}'..."
17
+
18
+ send( @mn, @content ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
19
+ end
20
+
21
+ include Engine
22
+
23
+ end # class Wrapper
24
+
25
+
26
+
27
+ @@config = nil
28
+
29
+ def self.lib( value = nil )
30
+ if value.nil?
31
+ if @@config.nil?
32
+ @@config = Config.new
33
+ end
34
+ @@config.markdown_lib
35
+ else
36
+ ## todo: lets you select your library
37
+ end
38
+ end
39
+
40
+ def self.new( content, options={} )
41
+
42
+ ## todo: allow options to pass in
43
+ ## lets you change markdown engine/converter for every call
44
+ ## e.g. lets you add config properties (as headers) to your document (for example)
45
+
46
+ if @@config.nil?
47
+ @@config = Config.new
48
+ end
49
+
50
+ lib = @@config.markdown_lib
51
+ mn = @@config.markdown_to_html_method # lets you use differnt options/converters for a single markdown lib
52
+ Wrapper.new( lib, mn, content, options )
53
+ end
54
+
55
+ end # module Markdown
@@ -0,0 +1,35 @@
1
+ ###
2
+ # NB: for local testing run like:
3
+ #
4
+ # 1.8.x: ruby -Ilib -rrubygems test/test_kramdown.rb
5
+ # 1.9.x: ruby -Ilib test/test_kramdown.rb
6
+
7
+ # core and stlibs
8
+
9
+ require 'test/unit'
10
+ require 'logger'
11
+ require 'pp'
12
+
13
+ # our own code
14
+
15
+ require 'lib/markdown'
16
+
17
+
18
+ class TestKramdown < Test::Unit::TestCase
19
+
20
+ def setup
21
+ Markdown.lib( 'kramdown' )
22
+ end
23
+
24
+ def test_lib
25
+ lib = Markdown.lib
26
+ assert_equal( 'kramdown', lib )
27
+ end
28
+
29
+ def test_to_html
30
+ html = Markdown.new( 'Hello World!' ).to_html
31
+ assert_equal( "<p>Hello World!</p>\n", html )
32
+ end
33
+
34
+
35
+ end # class TestKramdown
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
4
+ hash: 321068176
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
10
+ - beta
9
11
  - 1
10
- version: 0.0.1
12
+ version: 0.1.0.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Gerald Bauer
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-05-30 00:00:00 Z
20
+ date: 2012-06-02 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: kramdown
@@ -56,26 +58,17 @@ dependencies:
56
58
  requirements:
57
59
  - - ~>
58
60
  - !ruby/object:Gem::Version
59
- hash: 29
61
+ hash: 7
60
62
  segments:
61
- - 2
62
- - 15
63
- version: "2.15"
63
+ - 3
64
+ - 0
65
+ version: "3.0"
64
66
  type: :development
65
67
  version_requirements: *id003
66
- description: |-
67
- The Markdown Select (`markdown_select`) Ruby gem lets you use your markdown library of choice.
68
- Preconfigured markdown libraries include:
69
-
70
- * `kramdown`
71
- * `bluecloth`
72
- * `maruku`
73
- * `rpeg-markdown`
74
- * `rdiscount`
75
- * `pandoc-ruby`
68
+ description: Markdown Engine Wrapper - Use Your Markdown Library of Choice
76
69
  email: webslideshow@googlegroups.com
77
- executables: []
78
-
70
+ executables:
71
+ - markdown
79
72
  extensions: []
80
73
 
81
74
  extra_rdoc_files:
@@ -85,11 +78,20 @@ files:
85
78
  - Manifest.txt
86
79
  - README.markdown
87
80
  - Rakefile
88
- - lib/markdown_select.rb
89
- - lib/markdown_select/config.rb
90
- - lib/markdown_select/engine.rb
91
- - lib/markdown_select/markdown_select.rb
92
- homepage: http://geraldb.github.com/markdown_select
81
+ - bin/markdown
82
+ - lib/markdown.rb
83
+ - lib/markdown/config.rb
84
+ - lib/markdown/engines/bluecloth.rb
85
+ - lib/markdown/engines/kramdown.rb
86
+ - lib/markdown/engines/maruku.rb
87
+ - lib/markdown/engines/pandoc_ruby.rb
88
+ - lib/markdown/engines/rdiscount.rb
89
+ - lib/markdown/engines/rpeg_markdown.rb
90
+ - lib/markdown/gen.rb
91
+ - lib/markdown/wrapper.rb
92
+ - test/test_kramdown.rb
93
+ - .gemtest
94
+ homepage: http://geraldb.github.com/markdown
93
95
  licenses: []
94
96
 
95
97
  post_install_message:
@@ -110,18 +112,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
112
  required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  none: false
112
114
  requirements:
113
- - - ">="
115
+ - - ">"
114
116
  - !ruby/object:Gem::Version
115
- hash: 3
117
+ hash: 25
116
118
  segments:
117
- - 0
118
- version: "0"
119
+ - 1
120
+ - 3
121
+ - 1
122
+ version: 1.3.1
119
123
  requirements: []
120
124
 
121
125
  rubyforge_project: markdown
122
126
  rubygems_version: 1.8.17
123
127
  signing_key:
124
128
  specification_version: 3
125
- summary: Markdown - Use Your Markdown Library of Choice
126
- test_files: []
127
-
129
+ summary: Markdown Engine Wrapper - Use Your Markdown Library of Choice
130
+ test_files:
131
+ - test/test_kramdown.rb
@@ -1,22 +0,0 @@
1
-
2
- $LOAD_PATH.unshift( File.expand_path( File.dirname(__FILE__) ) )
3
-
4
- # core and stlibs
5
-
6
- require 'yaml'
7
-
8
-
9
- # our own code
10
-
11
- require 'markdown_select/config'
12
- require 'markdown_select/engine'
13
- require 'markdown_select/markdown_select'
14
-
15
-
16
- ## todo: add main for bin (see slideshow)
17
-
18
- module MarkdownSelect
19
-
20
- VERSION = '0.0.1'
21
-
22
- end
@@ -1,64 +0,0 @@
1
- module MarkdownSelect
2
-
3
- class Config
4
-
5
- def initialize
6
- @hash = {}
7
- end
8
-
9
-
10
- def load
11
- # todo/fix: check more locations; merge config files
12
-
13
- # check for user settings in working folder (check for slideshow.yml)
14
-
15
- config_user_file = "./markdown.yml"
16
- if File.exists?( config_user_file )
17
- puts "Loading settings from '#{config_user_file}'..."
18
- @hash[ 'user' ] = YAML.load_file( config_user_file )
19
- end
20
- end
21
-
22
-
23
- def markdown_to_html_method( lib )
24
- method = @hash.fetch( 'user', {} ).fetch( lib, {} ).fetch( 'converter', nil )
25
-
26
- # use default name
27
- if method.nil?
28
- method = "#{lib.downcase}_to_html"
29
- end
30
-
31
- method.tr('-','_').to_sym
32
- end
33
-
34
-
35
- # note: only kramdown is listed as a dependency in gem specs (because it's Ruby only and, thus, easy to install)
36
- # if you want to use other markdown libs install the required/desired lib e.g.
37
- # use gem install rdiscount for rdiscount and so on
38
- #
39
- # also note for now the first present markdown library gets used
40
- # the search order is first come, first serve, that is: rdiscount, rpeg-markdown, maruku, bluecloth, kramdown (fallback, always present)
41
-
42
- BUILTIN_LIBS = [
43
- 'pandoc-ruby',
44
- 'rdiscount',
45
- 'rpeg-markdown',
46
- 'maruku',
47
- 'bluecloth',
48
- 'kramdown'
49
- ]
50
-
51
- def known_markdown_libs
52
- # returns an array of known markdown engines e.g.
53
- # [ pandoc-ruby, rdiscount, rpeg-markdown, maruku, bluecloth, kramdown ]
54
-
55
- ## todo: allow single lib para instead of libs
56
- ## todo: allow ENV setting markdown_[select]_lib=xxxx
57
-
58
- user_libs = @hash.fetch( 'user', {} ).fetch( 'libs', [] )
59
-
60
- user_libs.length > 0 ? user_libs : BUILTIN_LIBS
61
- end
62
-
63
- end # class Config
64
- end # module MarkdownSelect
@@ -1,80 +0,0 @@
1
- module MarkdownSelect
2
-
3
- class Proxy
4
-
5
- def initialize( lib, mn, content, options={} )
6
- @lib = lib
7
- @mn = mn
8
- @content = content
9
- @options = options
10
- end
11
-
12
- def to_html
13
- # call markdown filter; turn markdown lib name into method_name (mn)
14
- # eg. rpeg-markdown => rpeg_markdown_to_html
15
-
16
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library '#{@lib}' calling '#{@mn}'..."
17
-
18
- send( @mn, @content ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
19
- end
20
-
21
- include Engine
22
-
23
- end # class Proxy
24
-
25
- @@markdown_config = nil
26
- @@markdown_libs = []
27
- @@markdown_mn = nil
28
-
29
- def self.load_markdown_libs
30
-
31
- # check for available markdown libs/gems
32
- # try to require each lib and remove any not installed
33
-
34
- @@markdown_config.known_markdown_libs.each do |lib|
35
- begin
36
- require lib
37
- @@markdown_libs << lib
38
- rescue LoadError => ex
39
- ## todo: use logger.debug instead of puts
40
- puts "Markdown library #{lib} not found. Use gem install #{lib} to install."
41
- end
42
- end
43
-
44
- puts " Found #{@@markdown_libs.length} Markdown libraries: #{@@markdown_libs.join(', ')}"
45
- end
46
-
47
- def self.lib
48
- if @@markdown_config.nil?
49
- @@markdown_config = Config.new
50
- @@markdown_config.load
51
-
52
- load_markdown_libs
53
-
54
- # lets you use differnt options/converters for a single markdown lib
55
- @@markdown_mn = @@markdown_config.markdown_to_html_method( @@markdown_libs.first )
56
- end
57
-
58
- @@markdown_libs.first
59
- end
60
-
61
- def self.new( content, options={} )
62
-
63
- ## todo: allow options to pass in
64
- ## lets you change markdown engine/converter for every call
65
- ## e.g. lets you add config properties (as headers) to your document (for example)
66
-
67
- if @@markdown_config.nil?
68
- @@markdown_config = Config.new
69
- @@markdown_config.load
70
-
71
- load_markdown_libs
72
-
73
- # lets you use differnt options/converters for a single markdown lib
74
- @@markdown_mn = @@markdown_config.markdown_to_html_method( @@markdown_libs.first )
75
- end
76
-
77
- Proxy.new( @@markdown_libs.first, @@markdown_mn, content, options )
78
- end
79
-
80
- end # module MarkdownSelect