markdown_doctor 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +26 -0
- data/Rakefile +14 -0
- data/bin/markdown_doctor +26 -7
- data/markdown_doctor.gemspec +6 -7
- metadata +34 -8
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
markdown_doctor (0.3.0)
|
5
|
+
nokogiri (~> 1.5.0)
|
6
|
+
pygments.rb (~> 0.2.4)
|
7
|
+
redcarpet (~> 2.1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
blankslate (2.1.2.4)
|
13
|
+
ffi (1.0.11)
|
14
|
+
nokogiri (1.5.0)
|
15
|
+
pygments.rb (0.2.4)
|
16
|
+
rubypython (~> 0.5.3)
|
17
|
+
redcarpet (2.1.0)
|
18
|
+
rubypython (0.5.3)
|
19
|
+
blankslate (>= 2.1.2.3)
|
20
|
+
ffi (~> 1.0.7)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
markdown_doctor!
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
desc "remove built gems"
|
2
|
+
task :clean do
|
3
|
+
sh "rm markdown_doctor-*" rescue true
|
4
|
+
end
|
5
|
+
|
6
|
+
desc "build gem"
|
7
|
+
task :build do
|
8
|
+
sh "gem build markdown_doctor.gemspec"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "install gem"
|
12
|
+
task :install => [:clean, :build] do
|
13
|
+
sh "gem install `ls markdown_doctor-*`"
|
14
|
+
end
|
data/bin/markdown_doctor
CHANGED
@@ -2,18 +2,22 @@
|
|
2
2
|
|
3
3
|
require "rubygems"
|
4
4
|
require "redcarpet"
|
5
|
+
require "nokogiri"
|
6
|
+
require "pygments.rb"
|
5
7
|
|
6
8
|
HEADER = <<EOF
|
7
|
-
<link href="
|
8
|
-
|
9
|
+
<link href="http://assets.github.com/stylesheets/bundles/github-92243db0daab07aa944d353c1ba062b9581bd321.css"
|
10
|
+
type="text/css" rel="stylesheet" />
|
11
|
+
<link href="http://assets.github.com/stylesheets/bundles/github2-b4eff0bfa63304403db18c61e84e5af78b005dab.css"
|
12
|
+
type="text/css" rel="stylesheet" />
|
9
13
|
<style type="text/css">
|
10
|
-
#
|
14
|
+
#main-wrapper {
|
11
15
|
width: 920px;
|
12
16
|
margin: 0 auto;
|
13
17
|
}
|
14
18
|
</style>
|
15
|
-
<div id="
|
16
|
-
<div class="
|
19
|
+
<div id="main-wrapper">
|
20
|
+
<div class="markdown-body">
|
17
21
|
EOF
|
18
22
|
|
19
23
|
FOOTER = <<EOF
|
@@ -21,8 +25,23 @@ FOOTER = <<EOF
|
|
21
25
|
</div>
|
22
26
|
EOF
|
23
27
|
|
28
|
+
def pygmentize_code_blocks(html)
|
29
|
+
doc = Nokogiri::HTML(html)
|
30
|
+
code_blocks = doc.css("pre code[class]").map(&:parent)
|
31
|
+
|
32
|
+
code_blocks.each do |code|
|
33
|
+
language = code.child.attribute("class").value
|
34
|
+
pygmentized_html = Pygments.highlight(code.child.text, :lexer => language, :encoding => "utf-8",
|
35
|
+
:nowrap => true, :stripnl => false, :stripall => false)
|
36
|
+
new_node = Nokogiri::HTML.fragment(pygmentized_html)
|
37
|
+
code.replace(new_node)
|
38
|
+
end
|
39
|
+
|
40
|
+
doc.to_html
|
41
|
+
end
|
42
|
+
|
24
43
|
text = ARGF.read
|
25
|
-
markdown_options = { :
|
44
|
+
markdown_options = { :fenced_code_blocks => true, :tables => true, :space_after_headers => true }
|
26
45
|
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, markdown_options)
|
27
|
-
output = HEADER + markdown.render(text) + FOOTER
|
46
|
+
output = HEADER + pygmentize_code_blocks(markdown.render(text)) + FOOTER
|
28
47
|
puts output
|
data/markdown_doctor.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "markdown_doctor"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.3.0"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">=0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
@@ -14,10 +14,9 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubyforge_project = "markdown_doctor"
|
15
15
|
|
16
16
|
s.executables = %w(markdown_doctor)
|
17
|
-
s.files =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
)
|
22
|
-
s.add_dependency("redcarpet", ">= 2.0.0b5")
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
|
19
|
+
s.add_dependency("nokogiri", "~> 1.5.0")
|
20
|
+
s.add_dependency("pygments.rb", "~> 0.2.4")
|
21
|
+
s.add_dependency("redcarpet", "~> 2.1.0")
|
23
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_doctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,19 +10,41 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-02-12 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
requirement: &2169151320 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2169151320
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: pygments.rb
|
28
|
+
requirement: &2169150860 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2169150860
|
15
37
|
- !ruby/object:Gem::Dependency
|
16
38
|
name: redcarpet
|
17
|
-
requirement: &
|
39
|
+
requirement: &2169150400 !ruby/object:Gem::Requirement
|
18
40
|
none: false
|
19
41
|
requirements:
|
20
|
-
- -
|
42
|
+
- - ~>
|
21
43
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0
|
44
|
+
version: 2.1.0
|
23
45
|
type: :runtime
|
24
46
|
prerelease: false
|
25
|
-
version_requirements: *
|
47
|
+
version_requirements: *2169150400
|
26
48
|
description: An absurdly simple script for rendering markdown with github styles.
|
27
49
|
email:
|
28
50
|
- dmacdougall@gmail.com
|
@@ -32,9 +54,13 @@ executables:
|
|
32
54
|
extensions: []
|
33
55
|
extra_rdoc_files: []
|
34
56
|
files:
|
57
|
+
- .gitignore
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
35
60
|
- README.md
|
36
|
-
-
|
61
|
+
- Rakefile
|
37
62
|
- bin/markdown_doctor
|
63
|
+
- markdown_doctor.gemspec
|
38
64
|
homepage: https://github.com/dmacdougall/markdown_doctor
|
39
65
|
licenses: []
|
40
66
|
post_install_message:
|
@@ -55,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
81
|
version: '0'
|
56
82
|
requirements: []
|
57
83
|
rubyforge_project: markdown_doctor
|
58
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.7
|
59
85
|
signing_key:
|
60
86
|
specification_version: 2
|
61
87
|
summary: An absurdly simple script for rendering markdown with github styles.
|