markdown 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,15 @@ lib/markdown/engines/pandoc_ruby.rb
15
15
  lib/markdown/engines/rdiscount.rb
16
16
  lib/markdown/engines/redcarpet.rb
17
17
  lib/markdown/engines/rpeg_markdown.rb
18
+ lib/markdown/server.rb
19
+ lib/markdown/server/public/style.css
20
+ lib/markdown/server/views/_debug.erb
21
+ lib/markdown/server/views/_version.erb
22
+ lib/markdown/server/views/debug.erb
23
+ lib/markdown/server/views/index.erb
24
+ lib/markdown/server/views/layout.erb
18
25
  lib/markdown/version.rb
19
26
  lib/markdown/wrapper.rb
27
+ test/helper.rb
20
28
  test/test_kramdown.rb
29
+ test/test_redcarpet.rb
@@ -1,6 +1,10 @@
1
1
  # Markdown Engine Wrapper - Use Your Markdown Library of Choice in Ruby
2
2
 
3
- * [geraldb.github.com/markdown](http://geraldb.github.com/markdown)
3
+ * home :: [github.com/geraldb/markdown](https://github.com/geraldb/markdown)
4
+ * bugs :: [github.com/geraldb/markdown/issues](https://github.com/geraldb/markdown/issues)
5
+ * gem :: [rubygems.org/gems/markdown](https://rubygems.org/gems/markdown)
6
+ * rdoc :: [rubydoc.info/gems/markdown](http://rubydoc.info/gems/markdown)
7
+
4
8
 
5
9
  The Markdown Engine Wrapper (`markdown`) Ruby gem lets you use
6
10
  your markdown library of choice. Preconfigured markdown libraries include
@@ -156,7 +160,7 @@ Just install the gem:
156
160
 
157
161
  ## Real World Usage
158
162
 
159
- The [`slideshow`](http://slideshow.rubyforge.org) (also known as Slide Show (S9)) gem
163
+ The [`slideshow`](http://slideshow-s9.github.io) (also known as Slide Show (S9)) gem
160
164
  that lets you create slide shows
161
165
  and author slides in plain text using a wiki-style markup language that's easy-to-write and easy-to-read.
162
166
 
data/Rakefile CHANGED
@@ -15,12 +15,20 @@ Hoe.spec 'markdown' do
15
15
 
16
16
  self.extra_deps = [
17
17
  ['props','>= 1.0.0'],
18
- ['textutils','>=0.2.0'],
19
- ['kramdown','>= 0.13.7']
18
+ ['textutils','>=0.6.4'],
19
+ ['kramdown','>= 1.0.2']
20
+
21
+ ## todo: add sinatra ?? - keep it optional for now
20
22
  ]
21
23
 
22
24
  # switch extension to .markdown for gihub formatting
23
25
  self.readme_file = 'README.markdown'
24
26
  self.history_file = 'History.markdown'
25
-
27
+
28
+ self.licenses = ['Public Domain']
29
+
30
+ self.spec_extras = {
31
+ :required_ruby_version => '>= 1.9.2'
32
+ }
33
+
26
34
  end
@@ -7,6 +7,7 @@
7
7
  # core and stlibs
8
8
 
9
9
  require 'yaml'
10
+ require 'json'
10
11
  require 'pp'
11
12
  require 'logger'
12
13
  require 'optparse'
@@ -51,6 +52,10 @@ module Markdown
51
52
  "markdown #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
52
53
  end
53
54
 
55
+ def self.root
56
+ "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
57
+ end
58
+
54
59
  def self.main
55
60
 
56
61
  # allow env variable to set RUBYOPT-style default command line options
@@ -149,9 +149,13 @@ Examples:
149
149
  markdown quickref.text # Process document using Markdown
150
150
  markdown -o site quickref # Output documents to site folder
151
151
 
152
+ Note:
153
+ markdown server # Starts builtin markdown server (alias for server include serve, service, s)
154
+
155
+
152
156
  Further information:
153
- http://geraldb.github.com/markdown
154
-
157
+ https://github.com/geraldb/markdown
158
+
155
159
  EOS
156
160
  exit
157
161
  end
@@ -169,18 +173,27 @@ EOS
169
173
 
170
174
  logger.debug "args.length: #{args.length}"
171
175
  logger.debug "args: >#{args.join(',')}<"
172
-
173
- # if no file args given; default to working folder (that is, .)
174
- args = ['.'] if args.length == 0
175
176
 
176
- args.each do |arg|
177
- files = find_files( arg )
178
- files.each do |file|
179
- Gen.new( logger, opts ).create_doc( file )
177
+ if args.length == 1 && ['server', 'serve', 'service', 's' ].include?( args[0] )
178
+ # start service/server
179
+ # NB: server (HTTP service) not included in standard default require
180
+ require 'markdown/server'
181
+
182
+ Markdown::Server.run!
183
+ else
184
+
185
+ # if no file args given; default to working folder (that is, .)
186
+ args = ['.'] if args.length == 0
187
+
188
+ args.each do |arg|
189
+ files = find_files( arg )
190
+ files.each do |file|
191
+ Gen.new( logger, opts ).create_doc( file )
192
+ end
180
193
  end
181
194
  end
182
-
183
- puts "Done."
195
+
196
+ puts 'Done. Bye.'
184
197
 
185
198
  end # method run
186
199
 
@@ -110,9 +110,7 @@ DEFAULTS = { 'libs' => [
110
110
  end
111
111
  end
112
112
 
113
-
114
113
  def require_markdown_libs
115
-
116
114
  # check for available markdown libs/gems
117
115
  # try to require each lib and remove any not installed
118
116
 
@@ -127,6 +125,25 @@ DEFAULTS = { 'libs' => [
127
125
  end
128
126
  end
129
127
 
128
+ def markdown_lib=( lib )
129
+
130
+ # fix/todo: check if @libs.first == lib => do nothing; return
131
+
132
+ # check if value exists in libs array
133
+ # if yes put it into first position
134
+ # otherwise issue warning/error - better throw exception; engine not found
135
+
136
+ # try to delete
137
+ obj = @libs.delete( lib )
138
+ if obj.nil? # nothing deleted; no obj found
139
+ # try to require; will raise load error exception if not found; know what your're doing! no fallback; sorry; better fail fast
140
+ require lib
141
+ end
142
+
143
+ # add it back; make it first entry
144
+ @libs.unshift( lib )
145
+ end
146
+
130
147
  def markdown_lib
131
148
  @libs.first
132
149
  end
@@ -2,10 +2,10 @@ module Markdown
2
2
  module Engine
3
3
 
4
4
  def bluecloth_to_html( content, options={} )
5
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library bluecloth..."
5
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library bluecloth..."
6
6
 
7
7
  BlueCloth.new( content ).to_html
8
8
  end
9
9
 
10
10
  end # module Engine
11
- end # module Markdown
11
+ end # module Markdown
@@ -6,46 +6,51 @@ module Markdown
6
6
  h = {}
7
7
 
8
8
  # todo: find an easier (more generic?) way to setup hash - possible?
9
- h[ :auto_ids ] = options.fetch( 'auto_ids', nil ) if options.fetch( 'auto_ids', nil )
9
+ h[ :auto_ids ] = options.fetch( 'auto_ids', nil ) if options.fetch( 'auto_ids', nil )
10
10
  h[ :footnote_nr ] = options.fetch( 'footnote_nr',nil ) if options.fetch( 'footnote_nr', nil )
11
11
  h[ :entity_output ] = options.fetch( 'entity_output',nil ) if options.fetch( 'entity_output', nil )
12
12
  h[ :toc_levels ] = options.fetch( 'toc_levels',nil ) if options.fetch( 'toc_levels', nil )
13
13
  h[ :smart_quotes ] = options.fetch( 'smart_quotes',nil ) if options.fetch( 'smart_quotes', nil )
14
-
15
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library kramdown (#{Kramdown::VERSION})"
16
- puts " using options:"
17
- pp h # todo: use inspect? or to_json?
18
14
 
15
+ show_banner = options.fetch( 'banner', true)
16
+
17
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library kramdown (#{Kramdown::VERSION})"
18
+ puts " using options: #{h.to_json}"
19
+
19
20
  ## allow fenced blocks a la github flavored markup
20
21
  # -- thanks zenweb for inspiration:
21
22
  # https://github.com/seattlerb/zenweb/blob/master/lib/zenweb/plugins/markdown.rb
22
-
23
+
23
24
  content = content.
24
25
  gsub(/^``` *(\w+)/) { "{:lang=\"#$1\"}\n~~~" }.
25
26
  gsub(/^```/, '~~~')
26
27
 
27
28
  content = Kramdown::Document.new( content, h ).to_html
28
29
 
29
- # todo: check content size and newlines
30
- # check banner option?
31
- # only add banner if some newlines and size > treshold?
30
+ if show_banner
31
+
32
+ # todo: check content size and newlines
33
+ # check banner option?
34
+ # only add banner if some newlines and size > treshold?
32
35
 
33
36
  banner_begin =<<EOS
34
37
  <!-- === begin markdown block =====================================================
35
38
 
36
39
  generated by #{Markdown.banner}
37
40
  on #{Time.now} with Markdown engine kramdown (#{Kramdown::VERSION})
38
- using options { !to be done! }
41
+ using options #{h.to_json}
39
42
  -->
40
43
  EOS
41
44
 
42
45
  banner_end =<<EOS
43
46
  <!-- === end markdown block ===================================================== -->
44
47
  EOS
48
+ content = banner_begin + content + banner_end
49
+ end # if show_banner
50
+
51
+ content
45
52
 
46
- content = banner_begin + content + banner_end
47
-
48
53
  end
49
54
 
50
55
  end # module Engine
51
- end # module Markdown
56
+ end # module Markdown
@@ -2,10 +2,10 @@ module Markdown
2
2
  module Engine
3
3
 
4
4
  def maruku_to_html( content, options={} )
5
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library maruku..."
5
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library maruku..."
6
6
 
7
7
  Maruku.new( content, {:on_error => :raise} ).to_html
8
8
  end
9
9
 
10
10
  end # module Engine
11
- end # module Markdown
11
+ end # module Markdown
@@ -2,11 +2,11 @@ module Markdown
2
2
  module Engine
3
3
 
4
4
  def pandoc_ruby_to_html( content, options={} )
5
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library pandoc_ruby..."
5
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library pandoc_ruby..."
6
6
 
7
7
  content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
8
8
  end
9
-
9
+
10
10
  def pandoc_ruby_to_html_incremental( content, options={} )
11
11
  content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
12
12
  content = content.gsub(/<(ul|ol)/) do |match|
@@ -14,12 +14,12 @@ module Markdown
14
14
  end
15
15
  content
16
16
  end
17
-
17
+
18
18
  # sample how to use your own converter
19
19
  # configure in markdown.yml
20
20
  # pandoc-ruby:
21
21
  # converter: pandoc-ruby-to-s5
22
-
22
+
23
23
  def pandoc_ruby_to_s5( content, options={} )
24
24
  content = PandocRuby.new( content, {:from => :markdown, :to => :s5}, :smart ).convert
25
25
  content = content.gsub(/class="incremental"/,'class="step"')
@@ -2,7 +2,7 @@ module Markdown
2
2
  module Engine
3
3
 
4
4
  def rdiscount_to_html( content, options={} )
5
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library rdiscount..."
5
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rdiscount..."
6
6
 
7
7
  RDiscount.new( content ).to_html
8
8
  end
@@ -8,39 +8,43 @@ module Markdown
8
8
  # see https://github.com/tanoku/redcarpet
9
9
 
10
10
  extensions_ary = options.fetch( 'extensions', [] )
11
-
11
+ show_banner = options.fetch( 'banner', true )
12
+
12
13
  extensions_hash = {}
13
14
  extensions_ary.each do |e|
14
15
  extensions_hash[ e.to_sym ] = true
15
16
  end
16
17
 
17
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render"
18
- puts " using extensions: [#{extensions_ary.join(', ')}]"
18
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render"
19
+ puts " using extensions: #{extensions_ary.to_json}"
19
20
 
20
21
  redcarpet = Redcarpet::Markdown.new( Redcarpet::Render::HTML, extensions_hash )
21
22
  content = redcarpet.render( content )
22
23
 
23
- # todo: check content size and newlines
24
- # check banner option?
25
- # only add banner if some newlines and size > treshold?
24
+ if show_banner
25
+ # todo: check content size and newlines
26
+ # check banner option?
27
+ # only add banner if some newlines and size > treshold?
26
28
 
27
29
  banner_begin =<<EOS
28
30
  <!-- === begin markdown block =====================================================
29
31
 
30
32
  generated by #{Markdown.banner}
31
33
  on #{Time.now} with Markdown engine redcarpet (#{Redcarpet::VERSION}) w/ HTML render
32
- using extensions: [#{extensions_ary.join(', ')}]
34
+ using extensions: #{extensions_ary.to_json}
33
35
  -->
34
36
  EOS
35
37
 
36
- banner_end =<<EOS
38
+ banner_end =<<EOS
37
39
  <!-- === end markdown block ===================================================== -->
38
40
  EOS
39
41
 
40
- content = banner_begin + content + banner_end
41
-
42
+ content = banner_begin + content + banner_end
43
+ end # if show_banner
44
+
45
+ content
42
46
 
43
47
  end
44
48
 
45
49
  end # module Engine
46
- end # module Markdown
50
+ end # module Markdown
@@ -2,10 +2,10 @@ module Markdown
2
2
  module Engine
3
3
 
4
4
  def rpeg_markdown_to_html( content, options={} )
5
- puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library rpeg_markdown..."
5
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rpeg_markdown..."
6
6
 
7
7
  PEGMarkdown.new( content ).to_html
8
8
  end
9
9
 
10
10
  end # module Engine
11
- end # module Markdown
11
+ end # module Markdown
@@ -0,0 +1,126 @@
1
+ ######
2
+ # NB: use rackup to startup Sinatra service (see config.ru)
3
+ #
4
+ # e.g. config.ru:
5
+ # require './boot'
6
+ # run Markdown::Server
7
+
8
+
9
+ # 3rd party libs/gems
10
+
11
+ require 'sinatra/base'
12
+
13
+
14
+ # our own code
15
+
16
+ # require 'logutils'
17
+ # require 'logutils/db'
18
+
19
+
20
+
21
+ module Markdown
22
+
23
+ class Server < Sinatra::Base
24
+
25
+ def self.banner
26
+ "markdown-service #{Markdown::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})"
27
+ end
28
+
29
+ PUBLIC_FOLDER = "#{Markdown.root}/lib/markdown/server/public"
30
+ VIEWS_FOLDER = "#{Markdown.root}/lib/markdown/server/views"
31
+
32
+ puts "[debug] markdown-service - setting public folder to: #{PUBLIC_FOLDER}"
33
+ puts "[debug] markdown-service - setting views folder to: #{VIEWS_FOLDER}"
34
+
35
+ set :public_folder, PUBLIC_FOLDER # set up the static dir (with images/js/css inside)
36
+ set :views, VIEWS_FOLDER # set up the views dir
37
+
38
+ set :static, true # set up static file routing
39
+
40
+
41
+ ##################
42
+ # Helpers
43
+
44
+ helpers do
45
+ def path_prefix
46
+ request.env['SCRIPT_NAME']
47
+ end
48
+ end
49
+
50
+ ##############################################
51
+ # Controllers / Routing / Request Handlers
52
+
53
+ get '/' do
54
+ erb :index
55
+ end
56
+
57
+ ## todo: use 3rd party services from markdown.yml (lets you configure)
58
+ # e.g. http://johnmacfarlane.net/cgi-bin/pandoc-dingus?text=hi
59
+
60
+ ## return html
61
+ get '/html' do
62
+
63
+ # fix: use activesupport -> .present?
64
+ if params[:lib].nil? == false && params[:lib].empty? == false
65
+ Markdown.lib = params[:lib]
66
+ end
67
+
68
+ md = Markdown.new( params[:text] )
69
+ html = md.to_html
70
+ html
71
+ end
72
+
73
+ ## return html wrapped in json (follows babelfish2 dingus service api)
74
+ get '/dingus' do
75
+
76
+ # fix: use activesupport -> .present?
77
+ if params[:lib].nil? == false && params[:lib].empty? == false
78
+ Markdown.lib = params[:lib]
79
+ end
80
+
81
+ md = Markdown.new( params[:text] )
82
+ html = md.to_html
83
+
84
+ ### todo: add/fill up version
85
+ ## ass helper <lib>_version to engine
86
+ # {"name":"Pandoc","html":"<p>hi</p>","version":"1.9.4.2"}
87
+ data = {
88
+ name: Markdown.lib,
89
+ html: html,
90
+ version: 'x.x.x' # to be done
91
+ }
92
+
93
+ json_or_jsonp( data.to_json )
94
+ end
95
+
96
+
97
+ get '/d*' do
98
+ erb :debug
99
+ end
100
+
101
+
102
+ ### helper for json or jsonp response (depending on callback para)
103
+
104
+ private
105
+ def json_or_jsonp( json )
106
+ callback = params.delete('callback')
107
+ response = ''
108
+
109
+ if callback
110
+ content_type :js
111
+ response = "#{callback}(#{json})"
112
+ else
113
+ content_type :json
114
+ response = json
115
+ end
116
+
117
+ response
118
+ end
119
+
120
+
121
+ end # class Server
122
+ end # module Markdown
123
+
124
+
125
+ # say hello
126
+ puts Markdown::Server.banner
@@ -0,0 +1,36 @@
1
+ body {
2
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
3
+
4
+ a {
5
+ color: black;
6
+ text-decoration: none; }
7
+ a:hover {
8
+ color: black;
9
+ background-color: aqua;
10
+ text-decoration: underline; }
11
+ a:visited {
12
+ color: black; }
13
+
14
+ .params {
15
+ color: green;
16
+ font-style: italic;
17
+ font-weight: bold; }
18
+
19
+ pre {
20
+ background-color: #F3F3F3;
21
+ border-bottom: 1px solid #BBBBBB;
22
+ border-top: 1px solid #BBBBBB;
23
+ padding: 4px; }
24
+
25
+
26
+ /**********
27
+ * version / powered by
28
+ */
29
+
30
+ .version {
31
+ text-align: center;
32
+ margin-top: 10px;
33
+ color: grey; }
34
+ .version a, .version span {
35
+ font-size: 12px;
36
+ color: grey; }
@@ -0,0 +1,17 @@
1
+
2
+ <h3>Debug</h3>
3
+
4
+ <pre>
5
+ request.scheme <%= request.scheme %>
6
+ request.script_name <%= request.script_name %>
7
+ request.path_info <%= request.path_info %>
8
+ request.port <%= request.port %>
9
+ request.request_method <%= request.request_method %>
10
+ request.query_string <%= request.query_string %>
11
+ request.host <%= request.host %>
12
+ request.referrer <%= request.referrer %>
13
+ request.user_agent <%= request.user_agent %>
14
+ request.url <%= request.url %>
15
+ request.path <%= request.path %>
16
+ request.ip <%= request.ip %>
17
+ </pre>
@@ -0,0 +1,6 @@
1
+ <div class='version'>
2
+ <a href="http://groups.google.com/group/webslideshow">Questions? Comments?</a> |
3
+ <a href="https://github.com/geraldb/markdown">markdown/<%= Markdown::VERSION %></a> -
4
+ <span>Ruby/<%= "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" %> on</span>
5
+ <span>Sinatra/<%= Sinatra::VERSION %> (<%= ENV['RACK_ENV'] %>)</span>
6
+ </div>
@@ -0,0 +1,3 @@
1
+
2
+ <%= erb :'_debug' %>
3
+
@@ -0,0 +1,23 @@
1
+
2
+ <h1>Markdown JSON(P) API</h1>
3
+
4
+
5
+ <hr>
6
+
7
+ <p>
8
+ <code>
9
+ <a href='<%= url("/html?text=hello_world") %>'>
10
+ /html?<span class='params'>text</span>=hello_world
11
+ </a>
12
+ </code>
13
+ </p>
14
+
15
+ <p>
16
+ <code>
17
+ <a href='<%= url("/dingus?text=hello_world") %>'>
18
+ /dingus?<span class='params'>text</span>=hello_world
19
+ </a>
20
+ </code>
21
+ </p>
22
+
23
+ <%= erb :'_debug' %>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <title>markdown web service / HTTP JSON API</title>
6
+ <link href="<%= url('/style.css') %>" rel='stylesheet'>
7
+ </head>
8
+ <body>
9
+
10
+ <%= yield %>
11
+
12
+ <%= erb :'_version' %>
13
+
14
+ </body>
15
+ </html>
@@ -1,3 +1,3 @@
1
1
  module Markdown
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -3,30 +3,33 @@ module Markdown
3
3
  class Wrapper
4
4
 
5
5
  def initialize( lib, mn, content, options={} )
6
- @lib = lib
6
+ @lib = lib
7
7
  @mn = mn
8
8
  @content = content
9
9
  @options = options
10
10
  end
11
-
11
+
12
12
  def to_html
13
13
  # call markdown filter; turn markdown lib name into method_name (mn)
14
14
  # eg. rpeg-markdown => rpeg_markdown_to_html
15
15
  send( @mn, @content, @options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
16
- end
16
+ end
17
17
 
18
18
  include Engine
19
-
19
+
20
20
  end # class Wrapper
21
21
 
22
22
 
23
23
 
24
24
  @@config = nil
25
-
26
- def self.lib=( value )
27
- ## todo: lets you select your library
25
+
26
+ def self.lib=( lib )
27
+ if @@config.nil?
28
+ @@config = Config.new
29
+ end
30
+ @@config.markdown_lib = lib
28
31
  end
29
-
32
+
30
33
  def self.lib
31
34
  if @@config.nil?
32
35
  @@config = Config.new
@@ -54,10 +57,20 @@ module Markdown
54
57
  end
55
58
  @@config.dump
56
59
  end
57
-
58
-
60
+
61
+
59
62
  def self.new( content, options={} )
60
63
 
64
+ ## options
65
+ ## make sure keys are strings, that is, allow symbols for easy use
66
+ ## but internally only use string (yaml gets use strings)
67
+
68
+ ## fix: use stringify_keys! from activesupport (include dependency ?? why? why not??)
69
+ options.keys.each do |key|
70
+ options[ key.to_s ] = options.delete(key)
71
+ end
72
+
73
+
61
74
  ## todo: allow options to pass in
62
75
  ## lets you change markdown engine/converter for every call
63
76
  ## e.g. lets you add config properties (as headers) to your document (for example)
@@ -0,0 +1,20 @@
1
+
2
+ ## $:.unshift(File.dirname(__FILE__))
3
+
4
+ ## minitest setup
5
+
6
+ # require 'minitest/unit'
7
+ require 'minitest/autorun'
8
+
9
+ # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
10
+
11
+ require 'logger'
12
+ require 'pp'
13
+
14
+
15
+
16
+ ## our own code
17
+
18
+ require 'markdown'
19
+
20
+
@@ -1,35 +1,44 @@
1
1
  ###
2
2
  # NB: for local testing run like:
3
3
  #
4
- # 1.8.x: ruby -Ilib -rrubygems test/test_kramdown.rb
5
4
  # 1.9.x: ruby -Ilib test/test_kramdown.rb
6
5
 
7
6
  # core and stlibs
8
7
 
9
- require 'test/unit'
10
- require 'logger'
11
- require 'pp'
8
+ require 'helper'
12
9
 
13
- # our own code
14
10
 
15
- require 'lib/markdown'
16
11
 
17
-
18
- class TestKramdown < Test::Unit::TestCase
12
+ class TestKramdown < MiniTest::Unit::TestCase
19
13
 
20
14
  def setup
15
+ puts 'enter setup'
16
+ lib = Markdown.lib
17
+ puts ' set lib=kramdown'
21
18
  Markdown.lib = 'kramdown'
22
19
  end
23
-
20
+
24
21
  def test_lib
25
22
  lib = Markdown.lib
26
- assert_equal( 'kramdown', lib )
23
+ assert_equal( 'kramdown', lib )
27
24
  end
28
-
29
- def test_to_html
30
- html = Markdown.new( 'Hello World!' ).to_html
31
- assert_equal( "<p>Hello World!</p>\n", html )
25
+
26
+ def test_to_html_banner_false
27
+ md = Markdown.new( 'Hello World!', banner: false )
28
+
29
+ assert_equal( "<p>Hello World!</p>\n", md.to_html )
30
+ assert_equal( "<p>Hello World!</p>\n", md.to_html )
31
+ assert_equal( "<p>Hello World!</p>\n", md.to_html )
32
+ end
33
+
34
+ def test_to_html_banner_true
35
+ md = Markdown.new( 'Hello World!', banner: true )
36
+ html1 = md.to_html
37
+ html2 = md.to_html
38
+ assert( html1 =~ /^<!-- === begin markdown block ===/ )
39
+ assert( html1.include?( "<p>Hello World!</p>\n" ))
40
+ assert( html2.include?( "<p>Hello World!</p>\n" ))
41
+ assert( html1 =~ /============ -->$/ )
32
42
  end
33
43
 
34
-
35
- end # class TestKramdown
44
+ end # class TestKramdown
@@ -0,0 +1,38 @@
1
+ ###
2
+ # NB: for local testing run like:
3
+ #
4
+ # 1.9.x: ruby -Ilib test/test_redcarpet.rb
5
+
6
+ # core and stlibs
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestRedcarpet < MiniTest::Unit::TestCase
12
+
13
+ def setup
14
+ puts 'enter setup'
15
+ lib = Markdown.lib
16
+ puts ' set lib=redcarpet'
17
+ Markdown.lib = 'redcarpet'
18
+ end
19
+
20
+ def test_lib
21
+ lib = Markdown.lib
22
+ assert_equal( 'redcarpet', lib )
23
+ end
24
+
25
+ def test_to_html_banner_false
26
+ html = Markdown.new( 'Hello World!', banner: false ).to_html
27
+ assert_equal( "<p>Hello World!</p>\n", html )
28
+ end
29
+
30
+ def test_to_html_banner_true
31
+ html = Markdown.new( 'Hello World!', banner: true ).to_html
32
+ assert( html =~ /^<!-- === begin markdown block ===/ )
33
+ assert( html.include?( "<p>Hello World!</p>\n" ))
34
+ assert( html =~ /============ -->$/ )
35
+ end
36
+
37
+
38
+ end # class TestRedcarpet
metadata CHANGED
@@ -1,109 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: markdown
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gerald Bauer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-23 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: props
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &87448610 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 1
31
- - 0
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: textutils
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *87448610
25
+ - !ruby/object:Gem::Dependency
26
+ name: textutils
27
+ requirement: &87448390 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 23
45
- segments:
46
- - 0
47
- - 2
48
- - 0
49
- version: 0.2.0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.6.4
50
33
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: kramdown
54
34
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *87448390
36
+ - !ruby/object:Gem::Dependency
37
+ name: kramdown
38
+ requirement: &87448170 !ruby/object:Gem::Requirement
56
39
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 37
61
- segments:
62
- - 0
63
- - 13
64
- - 7
65
- version: 0.13.7
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.2
66
44
  type: :runtime
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: rdoc
70
45
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *87448170
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: &87447950 !ruby/object:Gem::Requirement
72
50
  none: false
73
- requirements:
51
+ requirements:
74
52
  - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 19
77
- segments:
78
- - 3
79
- - 10
80
- version: "3.10"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.10'
81
55
  type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: hoe
85
56
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *87447950
58
+ - !ruby/object:Gem::Dependency
59
+ name: hoe
60
+ requirement: &87447730 !ruby/object:Gem::Requirement
87
61
  none: false
88
- requirements:
62
+ requirements:
89
63
  - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 7
92
- segments:
93
- - 3
94
- - 0
95
- version: "3.0"
64
+ - !ruby/object:Gem::Version
65
+ version: '3.3'
96
66
  type: :development
97
- version_requirements: *id005
67
+ prerelease: false
68
+ version_requirements: *87447730
98
69
  description: Markdown Engine Wrapper - Use Your Markdown Library of Choice
99
70
  email: webslideshow@googlegroups.com
100
- executables:
71
+ executables:
101
72
  - markdown
102
73
  extensions: []
103
-
104
- extra_rdoc_files:
74
+ extra_rdoc_files:
105
75
  - Manifest.txt
106
- files:
76
+ files:
107
77
  - History.markdown
108
78
  - Manifest.txt
109
79
  - README.markdown
@@ -121,43 +91,46 @@ files:
121
91
  - lib/markdown/engines/rdiscount.rb
122
92
  - lib/markdown/engines/redcarpet.rb
123
93
  - lib/markdown/engines/rpeg_markdown.rb
94
+ - lib/markdown/server.rb
95
+ - lib/markdown/server/public/style.css
96
+ - lib/markdown/server/views/_debug.erb
97
+ - lib/markdown/server/views/_version.erb
98
+ - lib/markdown/server/views/debug.erb
99
+ - lib/markdown/server/views/index.erb
100
+ - lib/markdown/server/views/layout.erb
124
101
  - lib/markdown/version.rb
125
102
  - lib/markdown/wrapper.rb
103
+ - test/helper.rb
126
104
  - test/test_kramdown.rb
105
+ - test/test_redcarpet.rb
127
106
  - .gemtest
128
107
  homepage: http://geraldb.github.com/markdown
129
- licenses: []
130
-
108
+ licenses:
109
+ - Public Domain
131
110
  post_install_message:
132
- rdoc_options:
111
+ rdoc_options:
133
112
  - --main
134
113
  - README.markdown
135
- require_paths:
114
+ require_paths:
136
115
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
116
+ required_ruby_version: !ruby/object:Gem::Requirement
138
117
  none: false
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
- version: "0"
146
- required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: 1.9.2
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
123
  none: false
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- hash: 3
152
- segments:
153
- - 0
154
- version: "0"
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
155
128
  requirements: []
156
-
157
129
  rubyforge_project: markdown
158
- rubygems_version: 1.8.24
130
+ rubygems_version: 1.8.17
159
131
  signing_key:
160
132
  specification_version: 3
161
133
  summary: Markdown Engine Wrapper - Use Your Markdown Library of Choice
162
- test_files:
134
+ test_files:
163
135
  - test/test_kramdown.rb
136
+ - test/test_redcarpet.rb