textile2html 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/textile2html +18 -0
- data/lib/textile2html.rb +72 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/textile2html_spec.rb +7 -0
- data/textile2html.gemspec +73 -0
- metadata +163 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "RedCloth", ">=4.2.3"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.1.0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.5.1"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 akimatter
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= textile2html
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to textile2html
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 akimatter. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "textile2html"
|
16
|
+
gem.homepage = "http://github.com/akm/textile2html"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{textile2html generate html from textile}
|
19
|
+
gem.description = %Q{textile2html generate html from textile with ERB template by using RedCloth}
|
20
|
+
gem.email = "akm2000@gmail.com"
|
21
|
+
gem.authors = ["akimatter"]
|
22
|
+
|
23
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
24
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
25
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
26
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
27
|
+
|
28
|
+
gem.add_runtime_dependency 'RedCloth' # , '>= 4.2.3'
|
29
|
+
end
|
30
|
+
Jeweler::RubygemsDotOrgTasks.new
|
31
|
+
|
32
|
+
require 'rspec/core'
|
33
|
+
require 'rspec/core/rake_task'
|
34
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
35
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
39
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
40
|
+
spec.rcov = true
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :spec
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "textile2html #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bin/textile2html
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require "optparse"
|
3
|
+
require 'rubygems'
|
4
|
+
require 'textile2html'
|
5
|
+
|
6
|
+
textile2html = Textile2Html.new
|
7
|
+
options = textile2html.options
|
8
|
+
|
9
|
+
OptionParser.new do |opt|
|
10
|
+
opt.on("-l", "--layout=#{options[:layout]}"){|v| options[:layout] = v}
|
11
|
+
opt.on("-s", "--src-dir=#{options[:src_dir]}"){|v| options[:src_dir] = v}
|
12
|
+
opt.on("-d", "--dest-dir=#{options[:dest_dir]}"){|v| options[:dest_dir] = v}
|
13
|
+
opt.on("-n", "--noop"){ options[:noop] = true}
|
14
|
+
opt.on("-v", "--verbose"){ options[:verbose] = true}
|
15
|
+
opt.parse!(ARGV)
|
16
|
+
end
|
17
|
+
|
18
|
+
textile2html.execute
|
data/lib/textile2html.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'RedCloth'
|
5
|
+
|
6
|
+
class Textile2Html
|
7
|
+
|
8
|
+
DEFAULT_OPTIONS = {
|
9
|
+
:layout => File.expand_path("./textile2html_layout.html.erb", File.dirname(__FILE__)),
|
10
|
+
:src_dir => File.expand_path("."),
|
11
|
+
:dest_dir => File.expand_path("."),
|
12
|
+
:noop => false,
|
13
|
+
:verbose => false,
|
14
|
+
}
|
15
|
+
|
16
|
+
attr_reader :options
|
17
|
+
def initialize
|
18
|
+
@options = DEFAULT_OPTIONS.dup
|
19
|
+
end
|
20
|
+
|
21
|
+
def binding_for_yield
|
22
|
+
binding
|
23
|
+
end
|
24
|
+
|
25
|
+
def pickup_headers(body)
|
26
|
+
links = []
|
27
|
+
result = body.gsub(/(<h[1-6]>)(.*?)<\/h[1-6]>/) do |*args|
|
28
|
+
# puts "args: #{args.inspect}"
|
29
|
+
tag, desc = $1, $2
|
30
|
+
depth = tag.gsub(/\D/, '').to_i
|
31
|
+
links << [depth, desc]
|
32
|
+
"<h#{depth}><a name=\"#{desc}\">#{desc}</a></h#{depth}>"
|
33
|
+
end
|
34
|
+
return result, links
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_page_outlines(links)
|
38
|
+
src = links.map{|(depth, desc)| "#" * depth << ' "' << desc << '":#' << desc }.join("\n")
|
39
|
+
RedCloth.new(src).to_html
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute
|
43
|
+
src_dir = File.expand_path(options[:src_dir])
|
44
|
+
src_files = Dir["#{src_dir}/**/*.textile"]
|
45
|
+
src_files.each do |src_file|
|
46
|
+
src = File.read(src_file)
|
47
|
+
html_body = RedCloth.new(src).to_html
|
48
|
+
|
49
|
+
html_body, links = pickup_headers(html_body)
|
50
|
+
|
51
|
+
b = binding_for_yield do|*args|
|
52
|
+
arg = args.first
|
53
|
+
case arg
|
54
|
+
when nil then html_body
|
55
|
+
when :page_outline then build_page_outlines(links)
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
erb = ERB.new(File.read(options[:layout]))
|
62
|
+
html = erb.result(b)
|
63
|
+
rel_path = src_file.sub("#{Regexp.escape(src_dir)}/", '')
|
64
|
+
dest_rel_path = rel_path.sub(/\.textile$/, '.html')
|
65
|
+
dest_path = File.expand_path(dest_rel_path, options[:dest_dir])
|
66
|
+
dest_dir = File.dirname(dest_path)
|
67
|
+
FileUtils.mkdir_p(dest_dir)
|
68
|
+
File.open(dest_path, "w"){|f| f.puts(html)}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'textile2html'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{textile2html}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["akimatter"]
|
12
|
+
s.date = %q{2010-12-17}
|
13
|
+
s.default_executable = %q{textile2html}
|
14
|
+
s.description = %q{textile2html generate html from textile with ERB template by using RedCloth}
|
15
|
+
s.email = %q{akm2000@gmail.com}
|
16
|
+
s.executables = ["textile2html"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/textile2html",
|
30
|
+
"lib/textile2html.rb",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/textile2html_spec.rb",
|
33
|
+
"textile2html.gemspec"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/akm/textile2html}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{textile2html generate html from textile}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"spec/textile2html_spec.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<RedCloth>, [">= 4.2.3"])
|
51
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
54
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<RedCloth>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.3"])
|
58
|
+
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
s.add_dependency(%q<RedCloth>, [">= 0"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.3"])
|
66
|
+
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
|
67
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
69
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
70
|
+
s.add_dependency(%q<RedCloth>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: textile2html
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- akimatter
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-17 00:00:00 +09:00
|
18
|
+
default_executable: textile2html
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: RedCloth
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 4
|
29
|
+
- 2
|
30
|
+
- 3
|
31
|
+
version: 4.2.3
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 2
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
version: 2.1.0
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: bundler
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 0
|
60
|
+
- 0
|
61
|
+
version: 1.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: jeweler
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 5
|
75
|
+
- 1
|
76
|
+
version: 1.5.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rcov
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id005
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: RedCloth
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *id006
|
106
|
+
description: textile2html generate html from textile with ERB template by using RedCloth
|
107
|
+
email: akm2000@gmail.com
|
108
|
+
executables:
|
109
|
+
- textile2html
|
110
|
+
extensions: []
|
111
|
+
|
112
|
+
extra_rdoc_files:
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.rdoc
|
115
|
+
files:
|
116
|
+
- .document
|
117
|
+
- .rspec
|
118
|
+
- Gemfile
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.rdoc
|
121
|
+
- Rakefile
|
122
|
+
- VERSION
|
123
|
+
- bin/textile2html
|
124
|
+
- lib/textile2html.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/textile2html_spec.rb
|
127
|
+
- textile2html.gemspec
|
128
|
+
has_rdoc: true
|
129
|
+
homepage: http://github.com/akm/textile2html
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 292681208699901645
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
154
|
+
requirements: []
|
155
|
+
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 1.3.7
|
158
|
+
signing_key:
|
159
|
+
specification_version: 3
|
160
|
+
summary: textile2html generate html from textile
|
161
|
+
test_files:
|
162
|
+
- spec/spec_helper.rb
|
163
|
+
- spec/textile2html_spec.rb
|