markdown 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
- module Engine
5
-
6
- def maruku_version
7
- Maruku::VERSION
8
- end
9
-
10
- def maruku_to_html( content, options={} )
11
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library maruku..."
12
-
13
- Maruku.new( content, {:on_error => :raise} ).to_html
14
- end
15
-
16
- end # module Engine
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+ module Engine
5
+
6
+ def maruku_version
7
+ Maruku::VERSION
8
+ end
9
+
10
+ def maruku_to_html( content, options={} )
11
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library maruku..."
12
+
13
+ Maruku.new( content, {:on_error => :raise} ).to_html
14
+ end
15
+
16
+ end # module Engine
17
17
  end # module Markdown
@@ -1,38 +1,38 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
- module Engine
5
-
6
- def pandoc_ruby_to_html( content, options={} )
7
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library pandoc_ruby..."
8
-
9
- content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
10
- end
11
-
12
- def pandoc_ruby_to_html_incremental( content, options={} )
13
- content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
14
- content = content.gsub(/<(ul|ol)/) do |match|
15
- "#{Regexp.last_match(0)} class='step'"
16
- end
17
- content
18
- end
19
-
20
- # sample how to use your own converter
21
- # configure in markdown.yml
22
- # pandoc-ruby:
23
- # converter: pandoc-ruby-to-s5
24
-
25
- def pandoc_ruby_to_s5( content, options={} )
26
- content = PandocRuby.new( content, {:from => :markdown, :to => :s5}, :smart ).convert
27
- content = content.gsub(/class="incremental"/,'class="step"')
28
- content = content.to_a[13..-1].join # remove the layout div
29
- end
30
-
31
- def pandoc_ruby_to_s5_incremental( content, options={} )
32
- content = PandocRuby.new( content, {:from => :markdown, :to => :s5 }, :incremental, :smart ).convert
33
- content = content.gsub(/class="incremental"/,'class="step"')
34
- content = content.to_a[13..-1].join # remove the layout div
35
- end
36
-
37
- end # module Engine
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+ module Engine
5
+
6
+ def pandoc_ruby_to_html( content, options={} )
7
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library pandoc_ruby..."
8
+
9
+ content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
10
+ end
11
+
12
+ def pandoc_ruby_to_html_incremental( content, options={} )
13
+ content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
14
+ content = content.gsub(/<(ul|ol)/) do |match|
15
+ "#{Regexp.last_match(0)} class='step'"
16
+ end
17
+ content
18
+ end
19
+
20
+ # sample how to use your own converter
21
+ # configure in markdown.yml
22
+ # pandoc-ruby:
23
+ # converter: pandoc-ruby-to-s5
24
+
25
+ def pandoc_ruby_to_s5( content, options={} )
26
+ content = PandocRuby.new( content, {:from => :markdown, :to => :s5}, :smart ).convert
27
+ content = content.gsub(/class="incremental"/,'class="step"')
28
+ content = content.to_a[13..-1].join # remove the layout div
29
+ end
30
+
31
+ def pandoc_ruby_to_s5_incremental( content, options={} )
32
+ content = PandocRuby.new( content, {:from => :markdown, :to => :s5 }, :incremental, :smart ).convert
33
+ content = content.gsub(/class="incremental"/,'class="step"')
34
+ content = content.to_a[13..-1].join # remove the layout div
35
+ end
36
+
37
+ end # module Engine
38
38
  end # module Markdown
@@ -1,18 +1,18 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
- module Engine
5
-
6
- def rdiscount_version
7
- RDiscount::VERSION
8
- end
9
-
10
- def rdiscount_to_html( content, options={} )
11
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rdiscount..."
12
-
13
- RDiscount.new( content ).to_html
14
- end
15
-
16
-
17
- end # module Engine
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+ module Engine
5
+
6
+ def rdiscount_version
7
+ RDiscount::VERSION
8
+ end
9
+
10
+ def rdiscount_to_html( content, options={} )
11
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rdiscount..."
12
+
13
+ RDiscount.new( content ).to_html
14
+ end
15
+
16
+
17
+ end # module Engine
18
18
  end # module Markdown
@@ -1,56 +1,56 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
- module Engine
5
-
6
- def redcarpet_version
7
- Redcarpet::VERSION
8
- end
9
-
10
- def redcarpet_to_html( content, options={} )
11
-
12
- ## NB: uses redcarpet2
13
- #
14
- # see https://github.com/tanoku/redcarpet
15
-
16
- extensions_ary = options.fetch( 'extensions', [] )
17
- show_banner = options.fetch( 'banner', true )
18
-
19
- extensions_hash = {}
20
- extensions_ary.each do |e|
21
- extensions_hash[ e.to_sym ] = true
22
- end
23
-
24
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render"
25
- puts " using extensions: #{extensions_ary.to_json}"
26
-
27
- redcarpet = Redcarpet::Markdown.new( Redcarpet::Render::HTML, extensions_hash )
28
- content = redcarpet.render( content )
29
-
30
- if show_banner
31
- # todo: check content size and newlines
32
- # check banner option?
33
- # only add banner if some newlines and size > treshold?
34
-
35
- banner_begin =<<EOS
36
- <!-- === begin markdown block ===
37
-
38
- generated by #{Markdown.banner}
39
- on #{Time.now} with Markdown engine redcarpet (#{Redcarpet::VERSION}) w/ HTML render
40
- using extensions: #{extensions_ary.to_json}
41
- -->
42
- EOS
43
-
44
- banner_end =<<EOS
45
- <!-- === end markdown block === -->
46
- EOS
47
-
48
- content = banner_begin + content + banner_end
49
- end # if show_banner
50
-
51
- content
52
-
53
- end
54
-
55
- end # module Engine
56
- end # module Markdown
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+ module Engine
5
+
6
+ def redcarpet_version
7
+ Redcarpet::VERSION
8
+ end
9
+
10
+ def redcarpet_to_html( content, options={} )
11
+
12
+ ## NB: uses redcarpet2
13
+ #
14
+ # see https://github.com/tanoku/redcarpet
15
+
16
+ extensions_ary = options.fetch( 'extensions', [] )
17
+ show_banner = options.fetch( 'banner', true )
18
+
19
+ extensions_hash = {}
20
+ extensions_ary.each do |e|
21
+ extensions_hash[ e.to_sym ] = true
22
+ end
23
+
24
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render"
25
+ puts " using extensions: #{extensions_ary.to_json}"
26
+
27
+ redcarpet = Redcarpet::Markdown.new( Redcarpet::Render::HTML, extensions_hash )
28
+ content = redcarpet.render( content )
29
+
30
+ if show_banner
31
+ # todo: check content size and newlines
32
+ # check banner option?
33
+ # only add banner if some newlines and size > treshold?
34
+
35
+ banner_begin =<<EOS
36
+ <!-- === begin markdown block ===
37
+
38
+ generated by #{Markdown.banner}
39
+ on #{Time.now} with Markdown engine redcarpet (#{Redcarpet::VERSION}) w/ HTML render
40
+ using extensions: #{extensions_ary.to_json}
41
+ -->
42
+ EOS
43
+
44
+ banner_end =<<EOS
45
+ <!-- === end markdown block === -->
46
+ EOS
47
+
48
+ content = banner_begin + content + banner_end
49
+ end # if show_banner
50
+
51
+ content
52
+
53
+ end
54
+
55
+ end # module Engine
56
+ end # module Markdown
@@ -1,13 +1,13 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
- module Engine
5
-
6
- def rpeg_markdown_to_html( content, options={} )
7
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rpeg_markdown..."
8
-
9
- PEGMarkdown.new( content ).to_html
10
- end
11
-
12
- end # module Engine
13
- end # module Markdown
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+ module Engine
5
+
6
+ def rpeg_markdown_to_html( content, options={} )
7
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rpeg_markdown..."
8
+
9
+ PEGMarkdown.new( content ).to_html
10
+ end
11
+
12
+ end # module Engine
13
+ end # module Markdown
@@ -4,21 +4,21 @@ module Markdown
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 2
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
11
11
  VERSION
12
12
  end
13
13
 
14
-
14
+
15
15
  # version string for generator meta tag (includes ruby version)
16
16
  def self.banner
17
- "markdown/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17
+ "markdown/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
18
18
  end
19
19
 
20
20
  def self.root
21
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
22
22
  end
23
23
 
24
24
  end # module Markdown
@@ -1,135 +1,135 @@
1
- # encoding: utf-8
2
-
3
- module Markdown
4
-
5
- ## todo: use Converter inside Wrapper to avoid duplication
6
-
7
- class Converter
8
- def initialize( lib, mn_to_html, mn_version )
9
- @lib = lib
10
- @mn_to_html = mn_to_html
11
- @mn_version = mn_version
12
- end
13
-
14
- def convert( text, options={} )
15
- # call markdown filter; turn markdown lib name into method_name (mn)
16
- # eg. rpeg-markdown => rpeg_markdown_to_html
17
- send( @mn_to_html, text, options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
18
- end
19
-
20
- def version
21
- send( @mn_version ) # call 1st configured markdown engine e.g. kramdown_version
22
- end
23
-
24
- include Engine
25
- end
26
-
27
-
28
- class Wrapper
29
-
30
- def initialize( lib, mn, content, options={} )
31
- @lib = lib
32
- @mn = mn
33
- @content = content
34
- @options = options
35
- end
36
-
37
- def to_html
38
- # call markdown filter; turn markdown lib name into method_name (mn)
39
- # eg. rpeg-markdown => rpeg_markdown_to_html
40
- send( @mn, @content, @options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
41
- end
42
-
43
- include Engine
44
-
45
- end # class Wrapper
46
-
47
-
48
-
49
- @@config = nil
50
-
51
- def self.lib=( lib )
52
- if @@config.nil?
53
- @@config = Config.new
54
- end
55
- @@config.markdown_lib = lib
56
- end
57
-
58
- def self.lib
59
- if @@config.nil?
60
- @@config = Config.new
61
- end
62
- @@config.markdown_lib
63
- end
64
-
65
- def self.libs
66
- if @@config.nil?
67
- @@config = Config.new
68
- end
69
- @@config.markdown_libs
70
- end
71
-
72
- def self.extnames
73
- if @@config.nil?
74
- @@config = Config.new
75
- end
76
- @@config.markdown_extnames
77
- end
78
-
79
- def self.filters
80
- if @@config.nil?
81
- @@config = Config.new
82
- end
83
- @@config.markdown_filters
84
- end
85
-
86
- def self.dump # dump settings for debug/verbose flag
87
- if @@config.nil?
88
- @@config = Config.new
89
- end
90
- @@config.dump
91
- end
92
-
93
-
94
- def self.create_converter( lib )
95
- if @@config.nil?
96
- @@config = Config.new
97
- end
98
-
99
- mn_to_html = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
100
- mn_version = @@config.markdown_version_method( lib )
101
-
102
- Converter.new( lib, mn_to_html, mn_version )
103
- end
104
-
105
-
106
- def self.new( content, options={} )
107
-
108
- ## options
109
- ## make sure keys are strings, that is, allow symbols for easy use
110
- ## but internally only use string (yaml gets use strings)
111
-
112
- ## fix: use stringify_keys! from activesupport (include dependency ?? why? why not??)
113
- options.keys.each do |key|
114
- options[ key.to_s ] = options.delete(key)
115
- end
116
-
117
-
118
- ## todo: allow options to pass in
119
- ## lets you change markdown engine/converter for every call
120
- ## e.g. lets you add config properties (as headers) to your document (for example)
121
-
122
- if @@config.nil?
123
- @@config = Config.new
124
- end
125
-
126
- lib = @@config.markdown_lib
127
- mn = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
128
- defaults = @@config.markdown_lib_defaults( lib ) ## todo/fix: use mn / converter from defaults hash?? mn no longer needed??
129
-
130
- props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' ))
131
-
132
- Wrapper.new( lib, mn, content, props )
133
- end
134
-
135
- end # module Markdown
1
+ # encoding: utf-8
2
+
3
+ module Markdown
4
+
5
+ ## todo: use Converter inside Wrapper to avoid duplication
6
+
7
+ class Converter
8
+ def initialize( lib, mn_to_html, mn_version )
9
+ @lib = lib
10
+ @mn_to_html = mn_to_html
11
+ @mn_version = mn_version
12
+ end
13
+
14
+ def convert( text, options={} )
15
+ # call markdown filter; turn markdown lib name into method_name (mn)
16
+ # eg. rpeg-markdown => rpeg_markdown_to_html
17
+ send( @mn_to_html, text, options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
18
+ end
19
+
20
+ def version
21
+ send( @mn_version ) # call 1st configured markdown engine e.g. kramdown_version
22
+ end
23
+
24
+ include Engine
25
+ end
26
+
27
+
28
+ class Wrapper
29
+
30
+ def initialize( lib, mn, content, options={} )
31
+ @lib = lib
32
+ @mn = mn
33
+ @content = content
34
+ @options = options
35
+ end
36
+
37
+ def to_html
38
+ # call markdown filter; turn markdown lib name into method_name (mn)
39
+ # eg. rpeg-markdown => rpeg_markdown_to_html
40
+ send( @mn, @content, @options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
41
+ end
42
+
43
+ include Engine
44
+
45
+ end # class Wrapper
46
+
47
+
48
+
49
+ @@config = nil
50
+
51
+ def self.lib=( lib )
52
+ if @@config.nil?
53
+ @@config = Config.new
54
+ end
55
+ @@config.markdown_lib = lib
56
+ end
57
+
58
+ def self.lib
59
+ if @@config.nil?
60
+ @@config = Config.new
61
+ end
62
+ @@config.markdown_lib
63
+ end
64
+
65
+ def self.libs
66
+ if @@config.nil?
67
+ @@config = Config.new
68
+ end
69
+ @@config.markdown_libs
70
+ end
71
+
72
+ def self.extnames
73
+ if @@config.nil?
74
+ @@config = Config.new
75
+ end
76
+ @@config.markdown_extnames
77
+ end
78
+
79
+ def self.filters
80
+ if @@config.nil?
81
+ @@config = Config.new
82
+ end
83
+ @@config.markdown_filters
84
+ end
85
+
86
+ def self.dump # dump settings for debug/verbose flag
87
+ if @@config.nil?
88
+ @@config = Config.new
89
+ end
90
+ @@config.dump
91
+ end
92
+
93
+
94
+ def self.create_converter( lib )
95
+ if @@config.nil?
96
+ @@config = Config.new
97
+ end
98
+
99
+ mn_to_html = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
100
+ mn_version = @@config.markdown_version_method( lib )
101
+
102
+ Converter.new( lib, mn_to_html, mn_version )
103
+ end
104
+
105
+
106
+ def self.new( content, options={} )
107
+
108
+ ## options
109
+ ## make sure keys are strings, that is, allow symbols for easy use
110
+ ## but internally only use string (yaml gets use strings)
111
+
112
+ ## fix: use stringify_keys! from activesupport (include dependency ?? why? why not??)
113
+ options.keys.each do |key|
114
+ options[ key.to_s ] = options.delete(key)
115
+ end
116
+
117
+
118
+ ## todo: allow options to pass in
119
+ ## lets you change markdown engine/converter for every call
120
+ ## e.g. lets you add config properties (as headers) to your document (for example)
121
+
122
+ if @@config.nil?
123
+ @@config = Config.new
124
+ end
125
+
126
+ lib = @@config.markdown_lib
127
+ mn = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
128
+ defaults = @@config.markdown_lib_defaults( lib ) ## todo/fix: use mn / converter from defaults hash?? mn no longer needed??
129
+
130
+ props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' ))
131
+
132
+ Wrapper.new( lib, mn, content, props )
133
+ end
134
+
135
+ end # module Markdown
data/lib/markdown.rb CHANGED
@@ -1,43 +1,41 @@
1
- # encoding: utf-8
2
-
3
- # core and stlibs
4
-
5
- require 'yaml'
6
- require 'json'
7
- require 'pp'
8
- require 'logger'
9
- require 'optparse'
10
- require 'fileutils'
11
-
12
-
13
- # gems
14
-
15
- require 'props' # manage properties/settings/env
16
-
17
- class Env
18
- def self.markdown_lib
19
- ENV['MARKDOWN_LIB']
20
- end
21
- end # class Env
22
-
23
-
24
- require 'textutils' # text filters and helpers
25
-
26
-
27
- # our own code
28
-
29
- require 'markdown/version' # Note: let version always go first
30
- require 'markdown/config'
31
- require 'markdown/engines/bluecloth'
32
- require 'markdown/engines/kramdown'
33
- require 'markdown/engines/maruku'
34
- require 'markdown/engines/pandoc_ruby'
35
- require 'markdown/engines/rdiscount'
36
- require 'markdown/engines/redcarpet'
37
- require 'markdown/engines/rpeg_markdown'
38
- require 'markdown/wrapper'
39
-
40
-
41
-
42
- # say hello
43
- puts Markdown.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
1
+ # core and stlibs
2
+
3
+ require 'yaml'
4
+ require 'json'
5
+ require 'pp'
6
+ require 'logger'
7
+ require 'optparse'
8
+ require 'fileutils'
9
+
10
+
11
+ # gems
12
+
13
+ require 'props' # manage properties/settings/env
14
+
15
+ class Env
16
+ def self.markdown_lib
17
+ ENV['MARKDOWN_LIB']
18
+ end
19
+ end # class Env
20
+
21
+
22
+ require 'textutils' # text filters and helpers
23
+
24
+
25
+ # our own code
26
+
27
+ require_relative 'markdown/version' # Note: let version always go first
28
+ require_relative 'markdown/config'
29
+ require_relative 'markdown/engines/bluecloth'
30
+ require_relative 'markdown/engines/kramdown'
31
+ require_relative 'markdown/engines/maruku'
32
+ require_relative 'markdown/engines/pandoc_ruby'
33
+ require_relative 'markdown/engines/rdiscount'
34
+ require_relative 'markdown/engines/redcarpet'
35
+ require_relative 'markdown/engines/rpeg_markdown'
36
+ require_relative 'markdown/wrapper'
37
+
38
+
39
+
40
+ # say hello
41
+ puts Markdown.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)