ravicious-clothmark 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +51 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/bin/bbmark +11 -0
- data/bin/bluemark +12 -0
- data/bin/redmark +13 -0
- data/clothmark.gemspec +73 -0
- data/lib/clothmark.rb +7 -0
- data/lib/clothmark/markups.rb +35 -0
- data/lib/clothmark/module.rb +60 -0
- data/spec/clothmark/bbmark_spec.rb +36 -0
- data/spec/clothmark/bluemark_spec.rb +36 -0
- data/spec/clothmark/clothmark_spec.rb +44 -0
- data/spec/clothmark/redmark_spec.rb +34 -0
- data/spec/spec_helper.rb +10 -0
- metadata +115 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Rafal Cieslak
|
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,51 @@
|
|
1
|
+
= ClothMark
|
2
|
+
|
3
|
+
With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.
|
4
|
+
|
5
|
+
ClothMark uses three awesome gems:
|
6
|
+
* RedCloth[http://redcloth.org/]
|
7
|
+
* BlueCloth[http://www.deveiate.org/projects/BlueCloth]
|
8
|
+
* bb-ruby[http://github.com/cpjolicoeur/bb-ruby/]
|
9
|
+
|
10
|
+
== Installation
|
11
|
+
|
12
|
+
gem sources -a http://gems.github.com
|
13
|
+
sudo gem install ravicious-clothmark
|
14
|
+
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
There are three commands:
|
18
|
+
|
19
|
+
* +bbmark+, which converts a file formatted with *BBCode* to HTML file.
|
20
|
+
* +bluemark+, which converts a file formatted with *Markdown* to HTML file.
|
21
|
+
* +redmark+, which converts a file formatted with *Textile* to HTML file.
|
22
|
+
|
23
|
+
For example:
|
24
|
+
|
25
|
+
$ bluemark my_markdown_formatted_file.txt
|
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:
|
28
|
+
|
29
|
+
$ bbmark posts/forum_post2
|
30
|
+
|
31
|
+
In this case, the forum\_post2.html file will be created in the _posts_ folder.
|
32
|
+
|
33
|
+
You can *specify* *an* *output* *file*, just add the second argument:
|
34
|
+
|
35
|
+
$ redmark textile_rlz new_blog_post.html
|
36
|
+
|
37
|
+
It generates the new\_blog\_post.html file.
|
38
|
+
|
39
|
+
== Note on Patches/Pull Requests
|
40
|
+
|
41
|
+
* Fork the project.
|
42
|
+
* Make your feature addition or bug fix.
|
43
|
+
* Add tests for it (RSpec). This is important so I don't break it in a
|
44
|
+
future version unintentionally.
|
45
|
+
* Commit, do not mess with rakefile, version, or history.
|
46
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
47
|
+
* Send me a pull request. Bonus points for topic branches.
|
48
|
+
|
49
|
+
== Copyright
|
50
|
+
|
51
|
+
Copyright (c) 2009 Rafal Cieslak. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "clothmark"
|
8
|
+
gem.summary = %Q{With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.}
|
9
|
+
gem.description = %Q{With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.}
|
10
|
+
gem.email = "ravicious@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/ravicious/clothmark"
|
12
|
+
gem.authors = ["Rafal Cieslak"]
|
13
|
+
gem.files = FileList['lib/**/*.rb', 'bin/*', '[A-Z]*', 'spec/**/*'].to_a
|
14
|
+
gem.add_dependency('bb-ruby', '>=0.9.3')
|
15
|
+
gem.add_dependency('BlueCloth', '>=1.0.0')
|
16
|
+
gem.add_dependency('RedCloth', '>=4.2.2')
|
17
|
+
gem.add_development_dependency "rspec"
|
18
|
+
gem.executables = ['bbmark', 'bluemark', 'redmark']
|
19
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.spec_opts = %w(-fs)
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
30
|
+
end
|
31
|
+
|
32
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
33
|
+
spec.libs << 'lib' << 'spec'
|
34
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
35
|
+
spec.rcov = true
|
36
|
+
spec.rcov_opts = ['--exclude', "spec"]
|
37
|
+
end
|
38
|
+
|
39
|
+
task :spec => :check_dependencies
|
40
|
+
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
if File.exist?('VERSION')
|
46
|
+
version = File.read('VERSION')
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "ClothMark #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*', 'LICENSE')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/bbmark
ADDED
data/bin/bluemark
ADDED
data/bin/redmark
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
data/clothmark.gemspec
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
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{clothmark}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rafal Cieslak"]
|
12
|
+
s.date = %q{2009-08-19}
|
13
|
+
s.description = %q{With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.}
|
14
|
+
s.email = %q{ravicious@gmail.com}
|
15
|
+
s.executables = ["bbmark", "bluemark", "redmark"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/bbmark",
|
26
|
+
"bin/bluemark",
|
27
|
+
"bin/redmark",
|
28
|
+
"clothmark.gemspec",
|
29
|
+
"lib/clothmark.rb",
|
30
|
+
"lib/clothmark/markups.rb",
|
31
|
+
"lib/clothmark/module.rb",
|
32
|
+
"spec/clothmark/bbmark_spec.rb",
|
33
|
+
"spec/clothmark/bluemark_spec.rb",
|
34
|
+
"spec/clothmark/clothmark_spec.rb",
|
35
|
+
"spec/clothmark/redmark_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.has_rdoc = true
|
39
|
+
s.homepage = %q{http://github.com/ravicious/clothmark}
|
40
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = %q{1.3.1}
|
43
|
+
s.summary = %q{With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.}
|
44
|
+
s.test_files = [
|
45
|
+
"spec/clothmark/bbmark_spec.rb",
|
46
|
+
"spec/clothmark/bluemark_spec.rb",
|
47
|
+
"spec/clothmark/clothmark_spec.rb",
|
48
|
+
"spec/clothmark/redmark_spec.rb",
|
49
|
+
"spec/spec_helper.rb"
|
50
|
+
]
|
51
|
+
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
+
s.specification_version = 2
|
55
|
+
|
56
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_runtime_dependency(%q<bb-ruby>, [">= 0.9.3"])
|
58
|
+
s.add_runtime_dependency(%q<BlueCloth>, [">= 1.0.0"])
|
59
|
+
s.add_runtime_dependency(%q<RedCloth>, [">= 4.2.2"])
|
60
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<bb-ruby>, [">= 0.9.3"])
|
63
|
+
s.add_dependency(%q<BlueCloth>, [">= 1.0.0"])
|
64
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.2"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<bb-ruby>, [">= 0.9.3"])
|
69
|
+
s.add_dependency(%q<BlueCloth>, [">= 1.0.0"])
|
70
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.2"])
|
71
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
72
|
+
end
|
73
|
+
end
|
data/lib/clothmark.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class BlueMark
|
2
|
+
include ClothMark
|
3
|
+
|
4
|
+
# Converts all lines from input file from Markdown format to HTML
|
5
|
+
# and pushes them to an array data_for_output.
|
6
|
+
def convert
|
7
|
+
File.open(@file) do |file|
|
8
|
+
file.each_line {|line| @data_for_output << BlueCloth.new(line).to_html}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class RedMark
|
14
|
+
include ClothMark
|
15
|
+
|
16
|
+
# Converts all lines from input file from Textile format to HTML
|
17
|
+
# and pushes them to an array data_for_output.
|
18
|
+
def convert
|
19
|
+
File.open(@file) do |file|
|
20
|
+
file.each_line {|line| @data_for_output << RedCloth.new(line).to_html}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class BBMark
|
26
|
+
include ClothMark
|
27
|
+
|
28
|
+
# Converts all lines from input file from BBCode format to HTML
|
29
|
+
# and pushes them to an array data_for_output.
|
30
|
+
def convert
|
31
|
+
File.open(@file) do |file|
|
32
|
+
file.each_line {|line| @data_for_output << line.bbcode_to_html}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ClothMark
|
2
|
+
attr_accessor :data_for_output, :file, :output
|
3
|
+
|
4
|
+
# Header for an output file.
|
5
|
+
HEADER = <<-EOF
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<style type="text/css">
|
9
|
+
#wrapper {
|
10
|
+
width: 600px; margin: 0 auto;
|
11
|
+
font-family: "Trebuchet MS", Verdana, sans-serif;
|
12
|
+
border-top: 1px solid black;
|
13
|
+
border-bottom: 1px solid black;
|
14
|
+
line-height: 1.5em;
|
15
|
+
}
|
16
|
+
pre {
|
17
|
+
font-size:90%;
|
18
|
+
line-height:1.5em !important;
|
19
|
+
overflow:auto;
|
20
|
+
margin:1em 0;
|
21
|
+
padding:0.5em;
|
22
|
+
}
|
23
|
+
|
24
|
+
pre, code {
|
25
|
+
font-family:Monaco, "Courier New", monospace;
|
26
|
+
color:#444;
|
27
|
+
background-color:#F8F8FF;
|
28
|
+
border:1px solid #DEDEDE;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
<title>ClothMark file preview</title>
|
32
|
+
</head>
|
33
|
+
<body>
|
34
|
+
<div id="wrapper">
|
35
|
+
EOF
|
36
|
+
|
37
|
+
# Footer for an output file.
|
38
|
+
FOOTER = <<-EOF
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
42
|
+
EOF
|
43
|
+
|
44
|
+
# ClothMark will generate a default filename if user don't want to save output to a specific file.
|
45
|
+
def initialize(file, output = nil)
|
46
|
+
@file = file
|
47
|
+
@output = output || "#{file.gsub(/(\.[a-z]{3,4})/, '')}_clothmark.html"
|
48
|
+
@data_for_output = []
|
49
|
+
end
|
50
|
+
|
51
|
+
# Saves output to a file (one paragraph per line).
|
52
|
+
def save_to_file
|
53
|
+
File.open(@output, 'w+') do |file|
|
54
|
+
file.puts HEADER
|
55
|
+
file.puts @data_for_output.join("\n")
|
56
|
+
# @data_for_output.each {|line| file.puts "#{line} \n"}
|
57
|
+
file.puts FOOTER
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe BBMark do
|
4
|
+
before :all do
|
5
|
+
@testfile = 'testfile.txt'
|
6
|
+
|
7
|
+
File.open(@testfile, 'w+') do |file|
|
8
|
+
file.puts "[b]O HAI![/b]
|
9
|
+
|
10
|
+
Lorem [i]ipsum[/i] dolor sit amet, [b]consectetur[/b] adipiscing elit. Sed iaculis rutrum lobortis. Integer vitae magna dolor, luctus venenatis lorem. Etiam magna urna, porta non scelerisque ut, porttitor non purus. Nunc et tortor at eros venenatis molestie. Maecenas ut nulla ac leo congue porttitor. Phasellus vitae sem dolor, vitae elementum diam. Phasellus adipiscing augue nec dui fermentum bibendum. Donec ultrices tortor non lorem egestas ut pharetra diam vestibulum.
|
11
|
+
|
12
|
+
[quote]Blaargh![/quote]
|
13
|
+
|
14
|
+
In ullamcorper placerat justo, ut dictum lorem sollicitudin a. Pellentesque dictum volutpat nisl, non rutrum dolor pharetra ut. Curabitur a elementum mi. Duis eu tellus eu justo ultrices tincidunt. Mauris blandit dui ac eros varius quis lacinia velit semper. Vivamus eu augue elit. Quisque lacinia sapien vel purus eleifend scelerisque feugiat quam sollicitudin. Pellentesque accumsan adipiscing leo, ut porttitor felis adipiscing id. Fusce cursus, lorem quis mollis commodo, dolor ipsum mattis lacus, ut suscipit augue lorem malesuada felis."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
@bbmark = BBMark.new(@testfile)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should convert data from input file to HTML (BBCode -> HTML)" do
|
23
|
+
|
24
|
+
@bbmark.convert
|
25
|
+
|
26
|
+
@bbmark.data_for_output.should_not be_empty
|
27
|
+
|
28
|
+
@bbmark.data_for_output.join("\n").should match(/<.+>/) # <.+> is the HTML tag
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
after :all do
|
33
|
+
# Remove testfile (input)
|
34
|
+
FileUtils.rm(@bbmark.file)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe BlueMark do
|
4
|
+
before :all do
|
5
|
+
@testfile = 'testfile.txt'
|
6
|
+
|
7
|
+
File.open(@testfile, 'w+') do |file|
|
8
|
+
file.puts "# O HAI!
|
9
|
+
|
10
|
+
Lorem **ipsum** dolor sit amet, *consectetur* adipiscing elit. Sed iaculis rutrum lobortis. Integer vitae magna dolor, luctus venenatis lorem. Etiam magna urna, porta non scelerisque ut, porttitor non purus. Nunc et tortor at eros venenatis molestie. Maecenas ut nulla ac leo congue porttitor. Phasellus vitae sem dolor, vitae elementum diam. Phasellus adipiscing augue nec dui fermentum bibendum. Donec ultrices tortor non lorem egestas ut pharetra diam vestibulum.
|
11
|
+
|
12
|
+
> Blaargh!
|
13
|
+
|
14
|
+
In ullamcorper placerat justo, ut dictum lorem sollicitudin a. Pellentesque dictum volutpat nisl, non rutrum dolor pharetra ut. Curabitur a elementum mi. Duis eu tellus eu justo ultrices tincidunt. Mauris blandit dui ac eros varius quis lacinia velit semper. Vivamus eu augue elit. Quisque lacinia sapien vel purus eleifend scelerisque feugiat quam sollicitudin. Pellentesque accumsan adipiscing leo, ut porttitor felis adipiscing id. Fusce cursus, lorem quis mollis commodo, dolor ipsum mattis lacus, ut suscipit augue lorem malesuada felis."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
@bluemark = BlueMark.new(@testfile)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should convert data from input file to HTML (Markdown -> HTML)" do
|
23
|
+
|
24
|
+
@bluemark.convert
|
25
|
+
|
26
|
+
@bluemark.data_for_output.should_not be_empty
|
27
|
+
|
28
|
+
@bluemark.data_for_output.join("\n").should match(/<.+>/) # <.+> is the HTML tag
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
after :all do
|
33
|
+
# Remove testfile (input)
|
34
|
+
FileUtils.rm(@bluemark.file)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe ClothMark do
|
4
|
+
before :each do
|
5
|
+
klass = Class.new { include ClothMark }
|
6
|
+
@foo = klass.new('nothing_special.txt')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should generate valid default 'output' filename" do
|
10
|
+
@foo.output.should == 'nothing_special_clothmark.html'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should save data for output to the output file" do
|
14
|
+
@foo.data_for_output = ['Donec ultrices tortor non lorem egestas ut pharetra diam vestibulum.',
|
15
|
+
'Etiam magna urna, porta non scelerisque ut, porttitor non purus.',
|
16
|
+
'Mauris blandit dui ac eros varius quis lacinia velit semper.']
|
17
|
+
|
18
|
+
@foo.save_to_file
|
19
|
+
|
20
|
+
counter = 0
|
21
|
+
test_string = ''
|
22
|
+
|
23
|
+
File.open(@foo.output, 'r') do |file|
|
24
|
+
# There's more than one paragraph in 'input file' (data_for_output),
|
25
|
+
# so we wan't a few paragraphs also in 'output' file.
|
26
|
+
file.each_line do |line|
|
27
|
+
counter += 1 unless line.empty?
|
28
|
+
test_string << "#{line} \n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# File should have at least two paragraphs
|
33
|
+
counter.should > 1
|
34
|
+
|
35
|
+
test_string.should match(/<html/)
|
36
|
+
test_string.should match(/<head/)
|
37
|
+
test_string.should match(/<body/)
|
38
|
+
end
|
39
|
+
|
40
|
+
after :all do
|
41
|
+
# Remove testfile (output)
|
42
|
+
FileUtils.rm(@foo.output)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe RedMark do
|
4
|
+
before :all do
|
5
|
+
@testfile = 'testfile.txt'
|
6
|
+
|
7
|
+
File.open(@testfile, 'w+') do |file|
|
8
|
+
file.puts "h1. O HAI!
|
9
|
+
|
10
|
+
Lorem *ipsum* dolor sit amet, _consectetur_ adipiscing elit. Sed iaculis rutrum lobortis. Integer vitae magna dolor, luctus venenatis lorem. Etiam magna urna, porta non scelerisque ut, porttitor non purus. Nunc et tortor at eros venenatis molestie. Maecenas ut nulla ac leo congue porttitor. Phasellus vitae sem dolor, vitae elementum diam. Phasellus adipiscing augue nec dui fermentum bibendum. Donec ultrices tortor non lorem egestas ut pharetra diam \"vestibulum\":http://google.com in your face.
|
11
|
+
|
12
|
+
In ullamcorper placerat justo, ut dictum lorem sollicitudin a. Pellentesque dictum volutpat nisl, non rutrum dolor pharetra ut. Curabitur a elementum mi. Duis eu tellus eu justo ultrices tincidunt. Mauris blandit dui ac eros varius quis lacinia velit semper. Vivamus eu augue elit. Quisque lacinia sapien vel purus eleifend scelerisque feugiat quam sollicitudin. Pellentesque accumsan adipiscing leo, ut porttitor felis adipiscing id. Fusce cursus, lorem quis mollis commodo, dolor ipsum mattis lacus, ut suscipit augue lorem malesuada felis."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@redmark = RedMark.new(@testfile)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should convert data from input file to HTML (Textile -> HTML)" do
|
21
|
+
|
22
|
+
@redmark.convert
|
23
|
+
|
24
|
+
@redmark.data_for_output.should_not be_empty
|
25
|
+
|
26
|
+
@redmark.data_for_output.join("\n").should match(/<.+>/) # <.+> is the HTML tag
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
after :all do
|
31
|
+
# Remove testfile (input)
|
32
|
+
FileUtils.rm(@redmark.file)
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ravicious-clothmark
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rafal Cieslak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-19 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bb-ruby
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: BlueCloth
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: RedCloth
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 4.2.2
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description: With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.
|
56
|
+
email: ravicious@gmail.com
|
57
|
+
executables:
|
58
|
+
- bbmark
|
59
|
+
- bluemark
|
60
|
+
- redmark
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
extra_rdoc_files:
|
64
|
+
- LICENSE
|
65
|
+
- README.rdoc
|
66
|
+
files:
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- VERSION
|
71
|
+
- bin/bbmark
|
72
|
+
- bin/bluemark
|
73
|
+
- bin/redmark
|
74
|
+
- clothmark.gemspec
|
75
|
+
- lib/clothmark.rb
|
76
|
+
- lib/clothmark/markups.rb
|
77
|
+
- lib/clothmark/module.rb
|
78
|
+
- spec/clothmark/bbmark_spec.rb
|
79
|
+
- spec/clothmark/bluemark_spec.rb
|
80
|
+
- spec/clothmark/clothmark_spec.rb
|
81
|
+
- spec/clothmark/redmark_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/ravicious/clothmark
|
85
|
+
licenses:
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- --charset=UTF-8
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 2
|
109
|
+
summary: With ClothMark you can easily convert your files formatted with Markdown, Textile or BBCode to HTML files.
|
110
|
+
test_files:
|
111
|
+
- spec/clothmark/bbmark_spec.rb
|
112
|
+
- spec/clothmark/bluemark_spec.rb
|
113
|
+
- spec/clothmark/clothmark_spec.rb
|
114
|
+
- spec/clothmark/redmark_spec.rb
|
115
|
+
- spec/spec_helper.rb
|