ravicious-clothmark 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +25 -13
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/clothmark +60 -0
- data/clothmark.gemspec +4 -5
- data/lib/clothmark/module.rb +6 -2
- data/spec/clothmark/clothmark_spec.rb +8 -3
- metadata +4 -8
- data/bin/bbmark +0 -11
- data/bin/bluemark +0 -12
- data/bin/redmark +0 -13
data/README.rdoc
CHANGED
@@ -14,27 +14,39 @@ ClothMark uses three awesome gems:
|
|
14
14
|
|
15
15
|
== Usage
|
16
16
|
|
17
|
-
|
17
|
+
Basic usage:
|
18
18
|
|
19
|
-
|
20
|
-
* +bluemark+, which converts a file formatted with *Markdown* to HTML file.
|
21
|
-
* +redmark+, which converts a file formatted with *Textile* to HTML file.
|
19
|
+
$ clothmark [input file]
|
22
20
|
|
23
|
-
|
21
|
+
It converts an input file to HTML using *Markdown* preprocessor. But you probably want to specify an output file or used preprocessor. Of course you can do this. Look here:
|
24
22
|
|
25
|
-
$
|
26
|
-
|
27
|
-
It generates the my\_markdown\_formatted\_file\_clothmark.html file. All files will be created in the folder that contains the input file, e.g:
|
23
|
+
$ clothmark [input file] [-o output file] [-m markup language]
|
28
24
|
|
29
|
-
|
25
|
+
Quick example:
|
30
26
|
|
31
|
-
|
27
|
+
$ clothmark bb_code.txt -m bbcode -o forum_post.html
|
28
|
+
|
29
|
+
It converts the input file (bb_code.txt) to the HTML file (forum_post.html) using BBCode preprocessor.
|
30
|
+
|
31
|
+
Wanna see help? No problem.
|
32
32
|
|
33
|
-
|
33
|
+
$ clothmark -h
|
34
|
+
Usage: clothmark [options]
|
35
|
+
-h, --help Display this screen
|
36
|
+
-i, --input FILE Specify input file (if it aren't specified, then first argument will be used)
|
37
|
+
-o, --output FILE Specify output file
|
38
|
+
-m, --markup LANG Specify markup language (markdown, textile or bbcode, default is markdown)
|
34
39
|
|
35
|
-
|
40
|
+
So, there are three arguments:
|
41
|
+
* -i or --input which specifies input file. If it isn't typed, then first argument will be used as an input file. This argument is required.
|
42
|
+
* -o or --output which specifies output file. You don't have to specify it, because ClothMark generates filename for output file automatically.
|
43
|
+
* -m or --markup which specifies markup language. If you don't specify it, then Markdown will be used as a choosed language.
|
44
|
+
|
45
|
+
All files will be created in the folder that contains a input file, e.g:
|
46
|
+
|
47
|
+
$ clothmark posts/forum_post2 -m bbcode
|
36
48
|
|
37
|
-
|
49
|
+
In this case, the forum\_post2.html file will be created in the _posts_ folder.
|
38
50
|
|
39
51
|
== Note on Patches/Pull Requests
|
40
52
|
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ begin
|
|
15
15
|
gem.add_dependency('BlueCloth', '>=1.0.0')
|
16
16
|
gem.add_dependency('RedCloth', '>=4.2.2')
|
17
17
|
gem.add_development_dependency "rspec"
|
18
|
-
gem.executables = ['
|
18
|
+
gem.executables = ['clothmark']
|
19
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
20
|
end
|
21
21
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/clothmark
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/clothmark')
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
optparse = OptionParser.new do |opts|
|
9
|
+
|
10
|
+
opts.on('-h', '--help', 'Display this screen') do
|
11
|
+
puts opts
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
# If input aren't specified, then first arg will be used
|
16
|
+
options[:input] = ARGV.first
|
17
|
+
opts.on('-i', '--input FILE', 'Specify input file (if it aren\'t specified, then first argument will be used)') do |arg|
|
18
|
+
options[:input] = arg
|
19
|
+
end
|
20
|
+
|
21
|
+
# If output aren't specified, then it will be an empty string
|
22
|
+
options[:output] = ""
|
23
|
+
opts.on('-o', '--output FILE', 'Specify output file') do |arg|
|
24
|
+
options[:output] = arg || nil
|
25
|
+
end
|
26
|
+
|
27
|
+
options[:markup] = "markdown"
|
28
|
+
opts.on('-m', '--markup LANG', %w(markdown textile bbcode) ,'Specify markup language (markdown, textile or bbcode, default is markdown)') do |arg|
|
29
|
+
options[:markup] = arg.downcase || "markdown"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
optparse.parse!
|
36
|
+
rescue OptionParser::MissingArgument => e
|
37
|
+
puts e
|
38
|
+
puts "To see help, type:"
|
39
|
+
puts "$ ruby #{__FILE__} -h"
|
40
|
+
exit
|
41
|
+
rescue OptionParser::InvalidArgument => e
|
42
|
+
puts e
|
43
|
+
puts "To see accepted arguments, type:"
|
44
|
+
puts "$ ruby #{__FILE__} -h"
|
45
|
+
exit
|
46
|
+
end #begin
|
47
|
+
|
48
|
+
case options[:markup]
|
49
|
+
when 'markdown'
|
50
|
+
@cloth = BlueMark.new(options[:input], options[:output])
|
51
|
+
when 'textile'
|
52
|
+
@cloth = RedMark.new(options[:input], options[:output])
|
53
|
+
when 'bbcode'
|
54
|
+
@cloth = BBMark.new(options[:input], options[:output])
|
55
|
+
end
|
56
|
+
|
57
|
+
@cloth.convert
|
58
|
+
@cloth.save_to_file
|
59
|
+
|
60
|
+
puts "File converted and saved to #{File.expand_path(@cloth.output)}"
|
data/clothmark.gemspec
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{clothmark}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rafal Cieslak"]
|
12
12
|
s.date = %q{2009-08-19}
|
13
|
+
s.default_executable = %q{clothmark}
|
13
14
|
s.description = %q{With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.}
|
14
15
|
s.email = %q{ravicious@gmail.com}
|
15
|
-
s.executables = ["
|
16
|
+
s.executables = ["clothmark"]
|
16
17
|
s.extra_rdoc_files = [
|
17
18
|
"LICENSE",
|
18
19
|
"README.rdoc"
|
@@ -22,9 +23,7 @@ Gem::Specification.new do |s|
|
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
24
25
|
"VERSION",
|
25
|
-
"bin/
|
26
|
-
"bin/bluemark",
|
27
|
-
"bin/redmark",
|
26
|
+
"bin/clothmark",
|
28
27
|
"clothmark.gemspec",
|
29
28
|
"lib/clothmark.rb",
|
30
29
|
"lib/clothmark/markups.rb",
|
data/lib/clothmark/module.rb
CHANGED
@@ -44,7 +44,11 @@ module ClothMark
|
|
44
44
|
# ClothMark will generate a default filename if user don't want to save output to a specific file.
|
45
45
|
def initialize(file, output = nil)
|
46
46
|
@file = file
|
47
|
-
|
47
|
+
if (!output || output.empty?)
|
48
|
+
@output = "#{file.gsub(/(\.[a-z]{3,4})/, '')}_clothmark.html"
|
49
|
+
else
|
50
|
+
@output = output
|
51
|
+
end
|
48
52
|
@data_for_output = []
|
49
53
|
end
|
50
54
|
|
@@ -57,4 +61,4 @@ module ClothMark
|
|
57
61
|
file.puts FOOTER
|
58
62
|
end
|
59
63
|
end
|
60
|
-
end
|
64
|
+
end
|
@@ -2,13 +2,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe ClothMark do
|
4
4
|
before :each do
|
5
|
-
klass = Class.new { include ClothMark }
|
6
|
-
@foo = klass.new('nothing_special.txt')
|
5
|
+
@klass = Class.new { include ClothMark }
|
6
|
+
@foo = @klass.new('nothing_special.txt')
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should generate valid default 'output' filename" do
|
10
10
|
@foo.output.should == 'nothing_special_clothmark.html'
|
11
11
|
end
|
12
|
+
|
13
|
+
it "should gets output if it is specified" do
|
14
|
+
@bar = @klass.new('rails.txt', 'rubyonrails.txt')
|
15
|
+
@bar.output.should == 'rubyonrails.txt'
|
16
|
+
end
|
12
17
|
|
13
18
|
it "should save data for output to the output file" do
|
14
19
|
@foo.data_for_output = ['Donec ultrices tortor non lorem egestas ut pharetra diam vestibulum.',
|
@@ -41,4 +46,4 @@ describe ClothMark do
|
|
41
46
|
# Remove testfile (output)
|
42
47
|
FileUtils.rm(@foo.output)
|
43
48
|
end
|
44
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ravicious-clothmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafal Cieslak
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
|
12
12
|
date: 2009-08-19 00:00:00 -07:00
|
13
|
-
default_executable:
|
13
|
+
default_executable: clothmark
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bb-ruby
|
@@ -55,9 +55,7 @@ dependencies:
|
|
55
55
|
description: With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.
|
56
56
|
email: ravicious@gmail.com
|
57
57
|
executables:
|
58
|
-
-
|
59
|
-
- bluemark
|
60
|
-
- redmark
|
58
|
+
- clothmark
|
61
59
|
extensions: []
|
62
60
|
|
63
61
|
extra_rdoc_files:
|
@@ -68,9 +66,7 @@ files:
|
|
68
66
|
- README.rdoc
|
69
67
|
- Rakefile
|
70
68
|
- VERSION
|
71
|
-
- bin/
|
72
|
-
- bin/bluemark
|
73
|
-
- bin/redmark
|
69
|
+
- bin/clothmark
|
74
70
|
- clothmark.gemspec
|
75
71
|
- lib/clothmark.rb
|
76
72
|
- lib/clothmark/markups.rb
|
data/bin/bbmark
DELETED
data/bin/bluemark
DELETED
data/bin/redmark
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
|
5
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'clothmark'
|
7
|
-
|
8
|
-
input = ARGV[0]
|
9
|
-
output = ARGV[1] || nil
|
10
|
-
|
11
|
-
@redmark = RedMark.new(input, output)
|
12
|
-
@redmark.convert
|
13
|
-
@redmark.save_to_file
|