markdown 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +7 -0
- data/README.markdown +33 -13
- data/lib/markdown/cli/runner.rb +2 -1
- data/lib/markdown/config.rb +76 -39
- data/lib/markdown/engines/bluecloth.rb +4 -0
- data/lib/markdown/engines/kramdown.rb +6 -2
- data/lib/markdown/engines/maruku.rb +5 -1
- data/lib/markdown/engines/rdiscount.rb +6 -1
- data/lib/markdown/engines/redcarpet.rb +6 -2
- data/lib/markdown/server.rb +90 -21
- data/lib/markdown/server/public/style.css +84 -8
- data/lib/markdown/server/views/_about.erb +23 -0
- data/lib/markdown/server/views/_debug.erb +10 -0
- data/lib/markdown/server/views/_libs.erb +14 -0
- data/lib/markdown/server/views/_libs_service.erb +27 -0
- data/lib/markdown/server/views/_notepad.erb +96 -0
- data/lib/markdown/server/views/_service.erb +75 -0
- data/lib/markdown/server/views/index.erb +12 -17
- data/lib/markdown/server/views/layout.erb +2 -1
- data/lib/markdown/server/views/notepad.erb +8 -0
- data/lib/markdown/server/views/service.erb +10 -0
- data/lib/markdown/version.rb +1 -1
- data/lib/markdown/wrapper.rb +48 -6
- data/test/test_kramdown.rb +1 -1
- data/test/test_redcarpet.rb +1 -1
- metadata +19 -12
data/Manifest.txt
CHANGED
@@ -17,11 +17,18 @@ lib/markdown/engines/redcarpet.rb
|
|
17
17
|
lib/markdown/engines/rpeg_markdown.rb
|
18
18
|
lib/markdown/server.rb
|
19
19
|
lib/markdown/server/public/style.css
|
20
|
+
lib/markdown/server/views/_about.erb
|
20
21
|
lib/markdown/server/views/_debug.erb
|
22
|
+
lib/markdown/server/views/_libs.erb
|
23
|
+
lib/markdown/server/views/_libs_service.erb
|
24
|
+
lib/markdown/server/views/_notepad.erb
|
25
|
+
lib/markdown/server/views/_service.erb
|
21
26
|
lib/markdown/server/views/_version.erb
|
22
27
|
lib/markdown/server/views/debug.erb
|
23
28
|
lib/markdown/server/views/index.erb
|
24
29
|
lib/markdown/server/views/layout.erb
|
30
|
+
lib/markdown/server/views/notepad.erb
|
31
|
+
lib/markdown/server/views/service.erb
|
25
32
|
lib/markdown/version.rb
|
26
33
|
lib/markdown/wrapper.rb
|
27
34
|
test/helper.rb
|
data/README.markdown
CHANGED
@@ -17,6 +17,7 @@ your markdown library of choice. Preconfigured markdown libraries include
|
|
17
17
|
* `rdiscount`
|
18
18
|
* `pandoc-ruby`
|
19
19
|
|
20
|
+
|
20
21
|
## Usage - Ruby Code
|
21
22
|
|
22
23
|
require 'markdown'
|
@@ -26,25 +27,44 @@ your markdown library of choice. Preconfigured markdown libraries include
|
|
26
27
|
# => "<p>Hello World</p>\n"
|
27
28
|
|
28
29
|
|
30
|
+
## Usage - Web Service / HTTP (JSON) API - `GET /markdown`
|
31
|
+
|
32
|
+
Try the `markdown` HTTP (JSON) API running
|
33
|
+
on Heroku [`hypertext.herokuapp.com`](http://hypertext.herokuapp.com).
|
34
|
+
|
35
|
+
Example:
|
36
|
+
|
37
|
+
GET /markdown?text=Hello+World!
|
38
|
+
|
39
|
+
<p>Hello World!</p>
|
40
|
+
|
41
|
+
|
42
|
+
To start your own server/service use `markdown serve`. See command line below.
|
43
|
+
|
44
|
+
|
29
45
|
## Usage - Command Line
|
30
46
|
|
31
47
|
The `markdown` gem includes a little command line tool. Try `markdown -h` for details:
|
32
48
|
|
33
|
-
```
|
34
|
-
markdown - Lets you convert plain text documents to hypertext with your Markdown engine of choice
|
35
|
-
and preprocessing text filters.
|
36
|
-
|
37
|
-
Usage: markdown [options] files_or_dirs
|
38
|
-
-o, --output PATH Output Path
|
39
|
-
-v, --verbose Show debug trace
|
40
49
|
|
50
|
+
markdown - Lets you convert plain text documents to hypertext with your Markdown engine of choice
|
51
|
+
and preprocessing text filters.
|
52
|
+
|
53
|
+
Usage: markdown [options] files_or_dirs
|
54
|
+
-o, --output PATH Output Path
|
55
|
+
-v, --verbose Show debug trace
|
56
|
+
|
57
|
+
|
58
|
+
Examples:
|
59
|
+
markdown # Process all documents in working folder (that is, .)
|
60
|
+
markdown quickref # Process document or folder using Markdown
|
61
|
+
markdown quickref.text # Process document using Markdown
|
62
|
+
markdown -o site quickref # Output documents to site folder
|
63
|
+
|
64
|
+
Note:
|
65
|
+
markdown server # Starts builtin markdown server
|
66
|
+
# (aliases for server include serve, service, s)
|
41
67
|
|
42
|
-
Examples:
|
43
|
-
markdown # Process all documents in working folder (that is, .)
|
44
|
-
markdown quickref # Process document or folder using Markdown
|
45
|
-
markdown quickref.text # Process document using Markdown
|
46
|
-
markdown -o site quickref # Output documents to site folder
|
47
|
-
```
|
48
68
|
|
49
69
|
## Configuration - Markdown Engine Loading Order
|
50
70
|
|
data/lib/markdown/cli/runner.rb
CHANGED
@@ -150,7 +150,8 @@ Examples:
|
|
150
150
|
markdown -o site quickref # Output documents to site folder
|
151
151
|
|
152
152
|
Note:
|
153
|
-
markdown server # Starts builtin markdown server
|
153
|
+
markdown server # Starts builtin markdown server
|
154
|
+
# (aliases for server include serve, service, s)
|
154
155
|
|
155
156
|
|
156
157
|
Further information:
|
data/lib/markdown/config.rb
CHANGED
@@ -9,40 +9,51 @@ module Markdown
|
|
9
9
|
# also note for now the first present markdown library gets used
|
10
10
|
# the search order is first come, first serve, that is: rdiscount, rpeg-markdown, maruku, bluecloth, kramdown (fallback, always present)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
'strikethrough' ] }, # todo/fix: merge nested hash??
|
40
|
-
'filters' => [
|
41
|
-
'comments-percent-style' ] # optional (preprocessing) text filters: e.g. comments-percent-style, skip-end-directive, etc. (see textutils gem)
|
12
|
+
|
13
|
+
DEFAULT_EXTNAMES = [
|
14
|
+
'.markdown',
|
15
|
+
'.m',
|
16
|
+
'.mark',
|
17
|
+
'.mkdn',
|
18
|
+
'.md',
|
19
|
+
'.mdown',
|
20
|
+
'.markdn',
|
21
|
+
'.txt',
|
22
|
+
'.text' ] # todo: check - add .wiki??? ext
|
23
|
+
|
24
|
+
DEFAULT_REDCARPET = {
|
25
|
+
'extensions' => [
|
26
|
+
'no_intra_emphasis',
|
27
|
+
'fenced_code_blocks',
|
28
|
+
'tables',
|
29
|
+
'strikethrough' ] }
|
30
|
+
|
31
|
+
DEFAULT_FILTERS = [
|
32
|
+
'comments-percent-style' ] # optional (preprocessing) text filters: e.g. comments-percent-style, skip-end-directive, etc. (see textutils gem)
|
33
|
+
|
34
|
+
|
35
|
+
DEFAULTS = { 'libs' => [ 'kramdown' ], # note: make kramdown default engine
|
36
|
+
'extnames' => DEFAULT_EXTNAMES,
|
37
|
+
'redcarpet' => DEFAULT_REDCARPET, # todo/fix: merge nested hash??
|
38
|
+
'filters' => DEFAULT_FILTERS
|
42
39
|
}
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
#
|
42
|
+
# pandoc-ruby - how to include - gemfile cannot install binary ??
|
43
|
+
# rpeg-markdown - build failure - still active, anyway?
|
44
|
+
# rdiscount - # compilation error on heroku; sorry excluded for now
|
45
|
+
|
46
|
+
DEFAULTS_SERVICE = { 'libs' => [
|
47
|
+
'kramdown', # note: make kramdown default engine
|
48
|
+
'maruku',
|
49
|
+
'bluecloth',
|
50
|
+
'redcarpet'
|
51
|
+
],
|
52
|
+
'extnames' => DEFAULT_EXTNAMES,
|
53
|
+
'redcarpet' => DEFAULT_REDCARPET
|
54
|
+
}
|
55
|
+
|
56
|
+
def load_props
|
46
57
|
@props = @props_default = Props.new( DEFAULTS, 'DEFAULTS' )
|
47
58
|
|
48
59
|
# check for user settings (markdown.yml) in home folder
|
@@ -50,7 +61,7 @@ DEFAULTS = { 'libs' => [
|
|
50
61
|
## todo: use .markdown.yml?? or differnt name ??
|
51
62
|
props_home_file = File.join( Env.home, 'markdown.yml' )
|
52
63
|
if File.exists?( props_home_file )
|
53
|
-
puts "Loading settings from '#{props_home_file}'..."
|
64
|
+
puts "Loading home settings from '#{props_home_file}'..."
|
54
65
|
@props = @props_home = Props.load_file( props_home_file, @props )
|
55
66
|
end
|
56
67
|
|
@@ -58,10 +69,25 @@ DEFAULTS = { 'libs' => [
|
|
58
69
|
|
59
70
|
props_work_file = File.join( '.', 'markdown.yml' )
|
60
71
|
if File.exists?( props_work_file )
|
61
|
-
puts "Loading settings from '#{props_work_file}'..."
|
72
|
+
puts "Loading work settings from '#{props_work_file}'..."
|
62
73
|
@props = @props_work = Props.load_file( props_work_file, @props )
|
63
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_props_service
|
78
|
+
puts "Loading service settings..."
|
79
|
+
@props = @props_default = Props.new( DEFAULTS_SERVICE, 'DEFAULTS' )
|
80
|
+
end
|
81
|
+
|
82
|
+
def initialize
|
64
83
|
|
84
|
+
# for an example see ./boot.rb
|
85
|
+
if $MARKDOWN_USE_SERVICE_CONFIG == true
|
86
|
+
load_props_service
|
87
|
+
else
|
88
|
+
load_props
|
89
|
+
end
|
90
|
+
|
65
91
|
@libs = []
|
66
92
|
|
67
93
|
require_markdown_libs()
|
@@ -148,13 +174,24 @@ DEFAULTS = { 'libs' => [
|
|
148
174
|
@libs.first
|
149
175
|
end
|
150
176
|
|
151
|
-
def
|
152
|
-
|
153
|
-
opts = @props.fetch( @libs.first, {} )
|
177
|
+
def markdown_libs
|
178
|
+
@libs # NB: return all libs - should we return a clone?
|
154
179
|
end
|
155
180
|
|
156
|
-
def
|
157
|
-
lib
|
181
|
+
def markdown_lib_defaults( lib=nil )
|
182
|
+
lib = @libs.first if lib.nil?
|
183
|
+
## todo: return props ? that acts like a hash?? (lets us support section lookup without deep merge???)
|
184
|
+
opts = @props.fetch( lib, {} )
|
185
|
+
end
|
186
|
+
|
187
|
+
def markdown_version_method( lib=nil )
|
188
|
+
lib = @libs.first if lib.nil?
|
189
|
+
method = "#{lib.downcase}_version" # default to <lib>_to_html if converter prop not found
|
190
|
+
method.tr('-','_').to_sym
|
191
|
+
end
|
192
|
+
|
193
|
+
def markdown_to_html_method( lib=nil )
|
194
|
+
lib = @libs.first if lib.nil?
|
158
195
|
method = @props.fetch_from_section( lib, 'converter', "#{lib.downcase}_to_html" ) # default to <lib>_to_html if converter prop not found
|
159
196
|
method.tr('-','_').to_sym
|
160
197
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Markdown
|
2
2
|
module Engine
|
3
3
|
|
4
|
+
def kramdown_version
|
5
|
+
Kramdown::VERSION
|
6
|
+
end
|
7
|
+
|
4
8
|
def kramdown_to_html( content, options={} )
|
5
9
|
|
6
10
|
h = {}
|
@@ -34,7 +38,7 @@ module Markdown
|
|
34
38
|
# only add banner if some newlines and size > treshold?
|
35
39
|
|
36
40
|
banner_begin =<<EOS
|
37
|
-
<!-- === begin markdown block
|
41
|
+
<!-- === begin markdown block ===
|
38
42
|
|
39
43
|
generated by #{Markdown.banner}
|
40
44
|
on #{Time.now} with Markdown engine kramdown (#{Kramdown::VERSION})
|
@@ -43,7 +47,7 @@ module Markdown
|
|
43
47
|
EOS
|
44
48
|
|
45
49
|
banner_end =<<EOS
|
46
|
-
<!-- === end markdown block
|
50
|
+
<!-- === end markdown block === -->
|
47
51
|
EOS
|
48
52
|
content = banner_begin + content + banner_end
|
49
53
|
end # if show_banner
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module Markdown
|
2
2
|
module Engine
|
3
|
-
|
3
|
+
|
4
|
+
def rdiscount_version
|
5
|
+
RDiscount::VERSION
|
6
|
+
end
|
7
|
+
|
4
8
|
def rdiscount_to_html( content, options={} )
|
5
9
|
puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rdiscount..."
|
6
10
|
|
7
11
|
RDiscount.new( content ).to_html
|
8
12
|
end
|
9
13
|
|
14
|
+
|
10
15
|
end # module Engine
|
11
16
|
end # module Markdown
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Markdown
|
2
2
|
module Engine
|
3
3
|
|
4
|
+
def redcarpet_version
|
5
|
+
Redcarpet::VERSION
|
6
|
+
end
|
7
|
+
|
4
8
|
def redcarpet_to_html( content, options={} )
|
5
9
|
|
6
10
|
## NB: uses redcarpet2
|
@@ -27,7 +31,7 @@ module Markdown
|
|
27
31
|
# only add banner if some newlines and size > treshold?
|
28
32
|
|
29
33
|
banner_begin =<<EOS
|
30
|
-
<!-- === begin markdown block
|
34
|
+
<!-- === begin markdown block ===
|
31
35
|
|
32
36
|
generated by #{Markdown.banner}
|
33
37
|
on #{Time.now} with Markdown engine redcarpet (#{Redcarpet::VERSION}) w/ HTML render
|
@@ -36,7 +40,7 @@ module Markdown
|
|
36
40
|
EOS
|
37
41
|
|
38
42
|
banner_end =<<EOS
|
39
|
-
<!-- === end markdown block
|
43
|
+
<!-- === end markdown block === -->
|
40
44
|
EOS
|
41
45
|
|
42
46
|
content = banner_begin + content + banner_end
|
data/lib/markdown/server.rb
CHANGED
@@ -50,44 +50,111 @@ class Server < Sinatra::Base
|
|
50
50
|
##############################################
|
51
51
|
# Controllers / Routing / Request Handlers
|
52
52
|
|
53
|
+
|
54
|
+
def welcome_markdown
|
55
|
+
<<EOS
|
56
|
+
# Header 1
|
57
|
+
|
58
|
+
## Header 2
|
59
|
+
|
60
|
+
### Header 3
|
61
|
+
|
62
|
+
Welcome to [Markdown](#{request.url}). We hope you **really** enjoy using this.
|
63
|
+
|
64
|
+
Just type some [markdown](http://daringfireball.net/projects/markdown) on the left and see it on the right. *Simple as that.*
|
65
|
+
|
66
|
+
> Quote goes here.
|
67
|
+
|
68
|
+
A list:
|
69
|
+
|
70
|
+
- One
|
71
|
+
- Two
|
72
|
+
- Three
|
73
|
+
|
74
|
+
Some inline code `to_html` and a preformatted code block:
|
75
|
+
|
76
|
+
```
|
77
|
+
Markdown.new( 'Hello Markdown!' ).to_html
|
78
|
+
```
|
79
|
+
EOS
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
get %r{/(service|services|srv|s)} do
|
84
|
+
erb :service
|
85
|
+
end
|
86
|
+
|
87
|
+
get %r{/(notepad|note|notes|n)} do
|
88
|
+
@welcome_markdown = welcome_markdown
|
89
|
+
@welcome_html = Markdown.new( @welcome_markdown ).to_html
|
90
|
+
|
91
|
+
erb :notepad
|
92
|
+
end
|
93
|
+
|
53
94
|
get '/' do
|
95
|
+
@welcome_markdown = welcome_markdown
|
96
|
+
@welcome_html = Markdown.new( @welcome_markdown ).to_html
|
97
|
+
|
54
98
|
erb :index
|
55
99
|
end
|
56
100
|
|
101
|
+
|
57
102
|
## todo: use 3rd party services from markdown.yml (lets you configure)
|
58
103
|
# e.g. http://johnmacfarlane.net/cgi-bin/pandoc-dingus?text=hi
|
59
104
|
|
60
|
-
|
61
|
-
|
105
|
+
|
106
|
+
def markdownify( params, opts={} )
|
107
|
+
pp params
|
108
|
+
text = params[:text]
|
109
|
+
lib = params[:lib] # optional
|
110
|
+
pp text
|
111
|
+
pp lib
|
62
112
|
|
63
113
|
# fix: use activesupport -> .present?
|
64
|
-
if
|
65
|
-
Markdown.lib =
|
114
|
+
if lib.nil? == false && lib.empty? == false
|
115
|
+
Markdown.lib = lib
|
66
116
|
end
|
67
117
|
|
68
|
-
|
69
|
-
html = md.to_html
|
70
|
-
html
|
118
|
+
Markdown.new( text, opts ).to_html
|
71
119
|
end
|
72
120
|
|
73
|
-
## return html wrapped in json (follows babelfish2 dingus service api)
|
74
|
-
get '/dingus' do
|
75
121
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
122
|
+
# return hypertext (html)
|
123
|
+
get '/markdown' do
|
124
|
+
content_type 'text/html'
|
125
|
+
markdownify( params )
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
# return babelmark2/dingus-style json
|
130
|
+
get '/markdown/dingus' do
|
131
|
+
html = markdownify( params )
|
132
|
+
|
133
|
+
## todo: use converter for markdownify
|
134
|
+
lib = Markdown.lib
|
135
|
+
conv = Markdown.create_converter( lib )
|
136
|
+
|
137
|
+
data = {
|
138
|
+
name: lib,
|
139
|
+
html: html,
|
140
|
+
version: conv.version
|
141
|
+
}
|
83
142
|
|
84
|
-
|
85
|
-
|
86
|
-
|
143
|
+
json_or_jsonp( data.to_json )
|
144
|
+
end
|
145
|
+
|
146
|
+
# return html wrapped in json (follows babelfish2 dingus service api)
|
147
|
+
get '/dingus' do
|
148
|
+
html = markdownify( params, banner: false )
|
149
|
+
|
150
|
+
## todo: use converter for markdownify
|
151
|
+
lib = Markdown.lib
|
152
|
+
conv = Markdown.create_converter( lib )
|
153
|
+
|
87
154
|
data = {
|
88
|
-
name:
|
155
|
+
name: lib,
|
89
156
|
html: html,
|
90
|
-
version:
|
157
|
+
version: conv.version
|
91
158
|
}
|
92
159
|
|
93
160
|
json_or_jsonp( data.to_json )
|
@@ -124,3 +191,5 @@ end # module Markdown
|
|
124
191
|
|
125
192
|
# say hello
|
126
193
|
puts Markdown::Server.banner
|
194
|
+
puts " default markdown engine: #{Markdown.lib}" # force loading of settings/config
|
195
|
+
puts " markdown engines: #{Markdown.libs.inspect}"
|
@@ -1,15 +1,14 @@
|
|
1
1
|
body {
|
2
2
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
|
3
3
|
|
4
|
-
a {
|
5
|
-
color:
|
4
|
+
a, a:visited {
|
5
|
+
color: #8B0000;
|
6
6
|
text-decoration: none; }
|
7
|
+
|
7
8
|
a:hover {
|
8
|
-
color:
|
9
|
-
background-color:
|
9
|
+
color: #8B0000;
|
10
|
+
background-color: gold;
|
10
11
|
text-decoration: underline; }
|
11
|
-
a:visited {
|
12
|
-
color: black; }
|
13
12
|
|
14
13
|
.params {
|
15
14
|
color: green;
|
@@ -23,6 +22,19 @@ pre {
|
|
23
22
|
padding: 4px; }
|
24
23
|
|
25
24
|
|
25
|
+
h3 {
|
26
|
+
border-bottom: 1px solid black;
|
27
|
+
}
|
28
|
+
|
29
|
+
/****************
|
30
|
+
* api
|
31
|
+
*/
|
32
|
+
|
33
|
+
.api a, .api a:visited {
|
34
|
+
color: black;
|
35
|
+
}
|
36
|
+
|
37
|
+
|
26
38
|
/**********
|
27
39
|
* version / powered by
|
28
40
|
*/
|
@@ -31,6 +43,70 @@ pre {
|
|
31
43
|
text-align: center;
|
32
44
|
margin-top: 10px;
|
33
45
|
color: grey; }
|
34
|
-
.version a,
|
46
|
+
.version a,
|
47
|
+
.version a:visited,
|
48
|
+
.version span {
|
35
49
|
font-size: 12px;
|
36
|
-
color: grey; }
|
50
|
+
color: grey; }
|
51
|
+
|
52
|
+
|
53
|
+
/************************
|
54
|
+
* markdown
|
55
|
+
*
|
56
|
+
* todo: use sass/scss and nest everything inside class .markdown
|
57
|
+
*/
|
58
|
+
|
59
|
+
.markdown h3 {
|
60
|
+
border-bottom: none;
|
61
|
+
}
|
62
|
+
|
63
|
+
.markdown a,
|
64
|
+
.markdown a:visited {
|
65
|
+
color: #2e80d3;
|
66
|
+
text-decoration: underline;
|
67
|
+
}
|
68
|
+
|
69
|
+
.markdown em {
|
70
|
+
background-color: #fffeca;
|
71
|
+
padding: 0 0.08em;
|
72
|
+
}
|
73
|
+
|
74
|
+
.markdown abbr {
|
75
|
+
border-bottom: 1px dashed;
|
76
|
+
cursor: help;
|
77
|
+
}
|
78
|
+
|
79
|
+
.markdown blockquote {
|
80
|
+
border-left: 5px solid #ddd;
|
81
|
+
color: #555;
|
82
|
+
margin: 0 0 1em;
|
83
|
+
padding-left: 0.6em;
|
84
|
+
}
|
85
|
+
|
86
|
+
.markdown pre {
|
87
|
+
background-color: #f8f8ff;
|
88
|
+
border: 1px solid #dedede;
|
89
|
+
color: #444;
|
90
|
+
font-family: "Bitstream Vera Sans Mono", Courier, monospace;
|
91
|
+
font-size: 0.8em;
|
92
|
+
line-height: 1.5em;
|
93
|
+
margin: 0 0 2em;
|
94
|
+
overflow: auto;
|
95
|
+
padding: 0.5em;
|
96
|
+
}
|
97
|
+
|
98
|
+
.markdown pre code {
|
99
|
+
background-color: #f8f8ff;
|
100
|
+
border: medium none;
|
101
|
+
font-size: 1em;
|
102
|
+
padding: 0;
|
103
|
+
}
|
104
|
+
|
105
|
+
.markdown code {
|
106
|
+
background-color: #f8f8ff;
|
107
|
+
border: 1px solid #dedede;
|
108
|
+
color: #444;
|
109
|
+
padding: 0 0.2em;
|
110
|
+
font-family: "Bitstream Vera Sans Mono", Courier, monospace;
|
111
|
+
font-size: 0.8em;
|
112
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<h3>Markdown Gem / About</h3>
|
4
|
+
|
5
|
+
<p><b>
|
6
|
+
What's the <code>markdown</code> gem?
|
7
|
+
</b>
|
8
|
+
|
9
|
+
The Markdown Engine Wrapper (<code>markdown</code>) Ruby gem lets you use
|
10
|
+
your markdown library of choice in Ruby.
|
11
|
+
<a href='https://github.com/geraldb/markdown'>Find out more »</a>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<b>Questions? Comments?</b>
|
16
|
+
Send them along to the <a href='http://groups.google.com/group/webslideshow'>Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List</a>.
|
17
|
+
Thanks!
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<p><b>License</b>
|
21
|
+
The markdown scripts are dedicated to the public domain.
|
22
|
+
Use it as you please with no restrictions whatsoever.
|
23
|
+
</p>
|
@@ -1,6 +1,15 @@
|
|
1
1
|
|
2
2
|
<h3>Debug</h3>
|
3
3
|
|
4
|
+
<h4>Params</h4>
|
5
|
+
|
6
|
+
<pre>
|
7
|
+
<%= params.inspect %>
|
8
|
+
</pre>
|
9
|
+
|
10
|
+
|
11
|
+
<h4>Request</h4>
|
12
|
+
|
4
13
|
<pre>
|
5
14
|
request.scheme <%= request.scheme %>
|
6
15
|
request.script_name <%= request.script_name %>
|
@@ -15,3 +24,4 @@
|
|
15
24
|
request.path <%= request.path %>
|
16
25
|
request.ip <%= request.ip %>
|
17
26
|
</pre>
|
27
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
<h3>Markdown Libs / Live Examples</h3>
|
3
|
+
|
4
|
+
<table class='api'>
|
5
|
+
<% Markdown.libs.each do |lib|
|
6
|
+
conv = Markdown.create_converter( lib )
|
7
|
+
%>
|
8
|
+
<tr>
|
9
|
+
<td><%= lib %></td>
|
10
|
+
<td> / <%= conv.version %></td>
|
11
|
+
<td> -
|
12
|
+
<code>GET
|
13
|
+
<a href='view-source:<%= url("/markdown?lib=#{lib}&text=Hello+World!") %>'>
|
14
|
+
/markdown?<span class='params'>lib=<em><%= lib %></em></span>&text=<em>Hello+World!</em>
|
15
|
+
</a>
|
16
|
+
</code>
|
17
|
+
</td>
|
18
|
+
<td>
|
19
|
+
<code>• GET
|
20
|
+
<a href='<%= url("/dingus?lib=#{lib}&text=Hello+World!") %>'>
|
21
|
+
/dingus?<span class='params'>lib=<em><%= lib %></em></span>&text=<em>Hello+World!</em>
|
22
|
+
</a>
|
23
|
+
</code>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</table>
|
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
<script>
|
3
|
+
|
4
|
+
var show_html = false;
|
5
|
+
|
6
|
+
function toggle_output() {
|
7
|
+
var $toggle_output = $( '#toggle-output' );
|
8
|
+
var $output = $( '#output' );
|
9
|
+
var $output_source = $( '#output-source' );
|
10
|
+
|
11
|
+
show_html = !show_html;
|
12
|
+
|
13
|
+
if( show_html ) {
|
14
|
+
$toggle_output.html( '[ Hide HTML ]' );
|
15
|
+
$output.hide();
|
16
|
+
$output_source.show();
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
$toggle_output.html( '[ Show HTML ]' );
|
20
|
+
$output.show();
|
21
|
+
$output_source.hide();
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
function process_markdown() {
|
26
|
+
var params = $( '#notepad, #notepad-lib' ).serialize();
|
27
|
+
|
28
|
+
// window.alert( params );
|
29
|
+
|
30
|
+
$.get( '/markdown', params, function( data ){
|
31
|
+
|
32
|
+
var $output = $( '#output' );
|
33
|
+
var $output_source = $( '#output-source' );
|
34
|
+
// window.alert( html );
|
35
|
+
|
36
|
+
// todo: check if data.html present? or content type js/json
|
37
|
+
// allow dingus-style { 'html': 'dddddd' }
|
38
|
+
$output.html( data );
|
39
|
+
$output_source.html( data );
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
</script>
|
44
|
+
|
45
|
+
|
46
|
+
<table width='100%'>
|
47
|
+
<colgroup>
|
48
|
+
<col width='50%'>
|
49
|
+
<col width='50%'>
|
50
|
+
</colgroup>
|
51
|
+
<tr>
|
52
|
+
<td>
|
53
|
+
<!-- first column -->
|
54
|
+
|
55
|
+
<div id='input'>
|
56
|
+
<textarea id='notepad' name='text' style='width: 100%; min-height: 500px;'><%= @welcome_markdown %></textarea>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</td>
|
60
|
+
<td style='vertical-align: top;'>
|
61
|
+
<!-- second column -->
|
62
|
+
|
63
|
+
<div id='output' class='markdown' style='width:100%; padding-left: 10px;'>
|
64
|
+
<%= @welcome_html %>
|
65
|
+
</div>
|
66
|
+
|
67
|
+
<textarea id='output-source' style='display: none; width: 100%; min-height: 500px;'><%= @welcome_html %></textarea>
|
68
|
+
|
69
|
+
<div id='loading' style='display: none;'></div>
|
70
|
+
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td>
|
75
|
+
<!-- first column -->
|
76
|
+
<span>
|
77
|
+
Use
|
78
|
+
<select id='notepad-lib' name='lib'>
|
79
|
+
<% Markdown.libs.each_with_index do |lib,i| %>
|
80
|
+
<option value='<%= lib %>'
|
81
|
+
<% if i == 0 %>
|
82
|
+
selected='selected'
|
83
|
+
<% end %> >
|
84
|
+
<%= lib %></option>
|
85
|
+
<% end %>
|
86
|
+
</select>
|
87
|
+
</span>
|
88
|
+
|
89
|
+
<a href='#' onclick='process_markdown();'>[ Update ]</a>
|
90
|
+
|
91
|
+
</td>
|
92
|
+
<td><!-- second column -->
|
93
|
+
<a id='toggle-output' href='#' onclick='toggle_output();'>[ Show HTML ]</a>
|
94
|
+
</td>
|
95
|
+
</tr>
|
96
|
+
</table>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
<h3>Markdown Web Service / HTTP JSON(P) API</h1>
|
3
|
+
|
4
|
+
<h4>Render Markdown</h4>
|
5
|
+
|
6
|
+
<pre><code>GET /markdown
|
7
|
+
</code></pre>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
Input:
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<ul>
|
14
|
+
<li><b>text</b> - <em>Required</em> string - The Markdown text to render</li>
|
15
|
+
<li><b>lib</b> - <em>Optional</em> string - The Markdown library/engine to use
|
16
|
+
(e.g. <code>kramdown</code>, <code>redcarpet</code>, etc)</li>
|
17
|
+
</ul>
|
18
|
+
|
19
|
+
<p class='api'>
|
20
|
+
Example:
|
21
|
+
<code>GET
|
22
|
+
<a href='view-source:<%= url("/markdown?text=Hello+World!") %>'>
|
23
|
+
/markdown?<span class='params'>text=<em>Hello+World!</em></span>
|
24
|
+
</a>
|
25
|
+
</code>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<p>
|
29
|
+
Response:
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<pre><code>Status: 200 OK
|
33
|
+
Content-Type: text/html
|
34
|
+
|
35
|
+
<p>Hello World!<p>
|
36
|
+
</code></pre>
|
37
|
+
|
38
|
+
|
39
|
+
<h4>Render Markdown (Babelmark2-Style)</h4>
|
40
|
+
|
41
|
+
<pre><code>GET /dingus
|
42
|
+
</code></pre>
|
43
|
+
|
44
|
+
<p>
|
45
|
+
Input:
|
46
|
+
</p>
|
47
|
+
|
48
|
+
<ul>
|
49
|
+
<li><b>text</b> - <em>Required</em> string - The Markdown text to render</li>
|
50
|
+
<li><b>lib</b> - <em>Optional</em> string - The Markdown library/engine to use
|
51
|
+
(e.g. <code>kramdown</code>, <code>redcarpet</code>, etc)</li>
|
52
|
+
</ul>
|
53
|
+
|
54
|
+
|
55
|
+
<p class='api'>Example:
|
56
|
+
<code>GET
|
57
|
+
<a href='<%= url("/dingus?text=Hello+World!") %>'>
|
58
|
+
/dingus?<span class='params'>text=<em>Hello+World!</em></span>
|
59
|
+
</a>
|
60
|
+
</code>
|
61
|
+
</p>
|
62
|
+
|
63
|
+
<p>
|
64
|
+
Response:
|
65
|
+
</p>
|
66
|
+
|
67
|
+
<pre><code>Status: 200 OK
|
68
|
+
Content-Type: application/json
|
69
|
+
|
70
|
+
{
|
71
|
+
'name': 'kramdown',
|
72
|
+
'html': '<p>Hello World!<p>',
|
73
|
+
'version': '1.0.2'
|
74
|
+
}
|
75
|
+
</code></pre>
|
@@ -1,23 +1,18 @@
|
|
1
1
|
|
2
|
-
<h1>Markdown JSON(P) API</h1>
|
3
2
|
|
3
|
+
<%= erb :'_notepad' %>
|
4
4
|
|
5
|
-
<hr>
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
<a href='<%= url("/dingus?text=hello_world") %>'>
|
18
|
-
/dingus?<span class='params'>text</span>=hello_world
|
19
|
-
</a>
|
20
|
-
</code>
|
21
|
-
</p>
|
6
|
+
<%= erb :'_libs' %>
|
7
|
+
|
8
|
+
|
9
|
+
<%= erb :'_service' %>
|
10
|
+
|
11
|
+
|
12
|
+
<%= erb :'_about' %>
|
13
|
+
|
14
|
+
<!--
|
15
|
+
<hr>
|
22
16
|
|
23
17
|
<%= erb :'_debug' %>
|
18
|
+
-->
|
@@ -2,8 +2,9 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta charset='UTF-8'>
|
5
|
-
<title>markdown
|
5
|
+
<title>markdown ruby gem - use your markdown library of choice in ruby</title>
|
6
6
|
<link href="<%= url('/style.css') %>" rel='stylesheet'>
|
7
|
+
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
|
7
8
|
</head>
|
8
9
|
<body>
|
9
10
|
|
data/lib/markdown/version.rb
CHANGED
data/lib/markdown/wrapper.rb
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
module Markdown
|
2
|
-
|
2
|
+
|
3
|
+
## todo: use Converter inside Wrapper to avoid duplication
|
4
|
+
|
5
|
+
class Converter
|
6
|
+
def initialize( lib, mn_to_html, mn_version )
|
7
|
+
@lib = lib
|
8
|
+
@mn_to_html = mn_to_html
|
9
|
+
@mn_version = mn_version
|
10
|
+
end
|
11
|
+
|
12
|
+
def convert( text, options={} )
|
13
|
+
# call markdown filter; turn markdown lib name into method_name (mn)
|
14
|
+
# eg. rpeg-markdown => rpeg_markdown_to_html
|
15
|
+
send( @mn_to_html, text, options ) # call 1st configured markdown engine e.g. kramdown_to_html( content )
|
16
|
+
end
|
17
|
+
|
18
|
+
def version
|
19
|
+
send( @mn_version ) # call 1st configured markdown engine e.g. kramdown_version
|
20
|
+
end
|
21
|
+
|
22
|
+
include Engine
|
23
|
+
end
|
24
|
+
|
25
|
+
|
3
26
|
class Wrapper
|
4
27
|
|
5
28
|
def initialize( lib, mn, content, options={} )
|
@@ -36,21 +59,28 @@ module Markdown
|
|
36
59
|
end
|
37
60
|
@@config.markdown_lib
|
38
61
|
end
|
39
|
-
|
62
|
+
|
63
|
+
def self.libs
|
64
|
+
if @@config.nil?
|
65
|
+
@@config = Config.new
|
66
|
+
end
|
67
|
+
@@config.markdown_libs
|
68
|
+
end
|
69
|
+
|
40
70
|
def self.extnames
|
41
71
|
if @@config.nil?
|
42
72
|
@@config = Config.new
|
43
73
|
end
|
44
74
|
@@config.markdown_extnames
|
45
75
|
end
|
46
|
-
|
76
|
+
|
47
77
|
def self.filters
|
48
78
|
if @@config.nil?
|
49
79
|
@@config = Config.new
|
50
80
|
end
|
51
81
|
@@config.markdown_filters
|
52
82
|
end
|
53
|
-
|
83
|
+
|
54
84
|
def self.dump # dump settings for debug/verbose flag
|
55
85
|
if @@config.nil?
|
56
86
|
@@config = Config.new
|
@@ -59,6 +89,18 @@ module Markdown
|
|
59
89
|
end
|
60
90
|
|
61
91
|
|
92
|
+
def self.create_converter( lib )
|
93
|
+
if @@config.nil?
|
94
|
+
@@config = Config.new
|
95
|
+
end
|
96
|
+
|
97
|
+
mn_to_html = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
|
98
|
+
mn_version = @@config.markdown_version_method( lib )
|
99
|
+
|
100
|
+
Converter.new( lib, mn_to_html, mn_version )
|
101
|
+
end
|
102
|
+
|
103
|
+
|
62
104
|
def self.new( content, options={} )
|
63
105
|
|
64
106
|
## options
|
@@ -80,8 +122,8 @@ module Markdown
|
|
80
122
|
end
|
81
123
|
|
82
124
|
lib = @@config.markdown_lib
|
83
|
-
mn = @@config.markdown_to_html_method # lets you use differnt options/converters for a single markdown lib
|
84
|
-
defaults = @@config.markdown_lib_defaults ## todo/fix: use mn / converter from defaults hash?? mn no longer needed??
|
125
|
+
mn = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib
|
126
|
+
defaults = @@config.markdown_lib_defaults( lib ) ## todo/fix: use mn / converter from defaults hash?? mn no longer needed??
|
85
127
|
|
86
128
|
props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' ))
|
87
129
|
|
data/test/test_kramdown.rb
CHANGED
@@ -38,7 +38,7 @@ class TestKramdown < MiniTest::Unit::TestCase
|
|
38
38
|
assert( html1 =~ /^<!-- === begin markdown block ===/ )
|
39
39
|
assert( html1.include?( "<p>Hello World!</p>\n" ))
|
40
40
|
assert( html2.include?( "<p>Hello World!</p>\n" ))
|
41
|
-
assert( html1 =~
|
41
|
+
assert( html1 =~ /=== -->$/ )
|
42
42
|
end
|
43
43
|
|
44
44
|
end # class TestKramdown
|
data/test/test_redcarpet.rb
CHANGED
@@ -31,7 +31,7 @@ class TestRedcarpet < MiniTest::Unit::TestCase
|
|
31
31
|
html = Markdown.new( 'Hello World!', banner: true ).to_html
|
32
32
|
assert( html =~ /^<!-- === begin markdown block ===/ )
|
33
33
|
assert( html.include?( "<p>Hello World!</p>\n" ))
|
34
|
-
assert( html =~
|
34
|
+
assert( html =~ /=== -->$/ )
|
35
35
|
end
|
36
36
|
|
37
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: props
|
16
|
-
requirement: &
|
16
|
+
requirement: &77334260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77334260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: textutils
|
27
|
-
requirement: &
|
27
|
+
requirement: &77334040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.6.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77334040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: kramdown
|
38
|
-
requirement: &
|
38
|
+
requirement: &77333820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *77333820
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &77333600 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.10'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *77333600
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe
|
60
|
-
requirement: &
|
60
|
+
requirement: &77333380 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '3.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *77333380
|
69
69
|
description: Markdown Engine Wrapper - Use Your Markdown Library of Choice
|
70
70
|
email: webslideshow@googlegroups.com
|
71
71
|
executables:
|
@@ -93,11 +93,18 @@ files:
|
|
93
93
|
- lib/markdown/engines/rpeg_markdown.rb
|
94
94
|
- lib/markdown/server.rb
|
95
95
|
- lib/markdown/server/public/style.css
|
96
|
+
- lib/markdown/server/views/_about.erb
|
96
97
|
- lib/markdown/server/views/_debug.erb
|
98
|
+
- lib/markdown/server/views/_libs.erb
|
99
|
+
- lib/markdown/server/views/_libs_service.erb
|
100
|
+
- lib/markdown/server/views/_notepad.erb
|
101
|
+
- lib/markdown/server/views/_service.erb
|
97
102
|
- lib/markdown/server/views/_version.erb
|
98
103
|
- lib/markdown/server/views/debug.erb
|
99
104
|
- lib/markdown/server/views/index.erb
|
100
105
|
- lib/markdown/server/views/layout.erb
|
106
|
+
- lib/markdown/server/views/notepad.erb
|
107
|
+
- lib/markdown/server/views/service.erb
|
101
108
|
- lib/markdown/version.rb
|
102
109
|
- lib/markdown/wrapper.rb
|
103
110
|
- test/helper.rb
|