BBRedCloth 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/BBRedCloth.gemspec +36 -0
- data/CHANGELOG +123 -0
- data/COPYING +18 -0
- data/Manifest +45 -0
- data/README.textile +149 -0
- data/Rakefile +247 -0
- data/bin/bbredcloth +34 -0
- data/ext/mingw-rbconfig.rb +176 -0
- data/ext/redcloth_scan/extconf.rb +9 -0
- data/ext/redcloth_scan/redcloth.h +196 -0
- data/ext/redcloth_scan/redcloth_attributes.c +655 -0
- data/ext/redcloth_scan/redcloth_bbcode.c +2457 -0
- data/ext/redcloth_scan/redcloth_bbcode_inline.c +1890 -0
- data/ext/redcloth_scan/redcloth_inline.c +12387 -0
- data/ext/redcloth_scan/redcloth_scan.c +10848 -0
- data/extras/ragel_profiler.rb +73 -0
- data/lib/case_sensitive_require/RedCloth.rb +6 -0
- data/lib/redcloth/erb_extension.rb +27 -0
- data/lib/redcloth/formatters/base.rb +57 -0
- data/lib/redcloth/formatters/html.rb +487 -0
- data/lib/redcloth/formatters/latex.rb +249 -0
- data/lib/redcloth/formatters/latex_entities.yml +2414 -0
- data/lib/redcloth/textile_doc.rb +196 -0
- data/lib/redcloth/version.rb +28 -0
- data/lib/redcloth.rb +37 -0
- data/setup.rb +1585 -0
- data/test/basic.yml +933 -0
- data/test/code.yml +229 -0
- data/test/definitions.yml +82 -0
- data/test/extra_whitespace.yml +64 -0
- data/test/filter_html.yml +177 -0
- data/test/filter_pba.yml +20 -0
- data/test/helper.rb +109 -0
- data/test/html.yml +313 -0
- data/test/images.yml +254 -0
- data/test/instiki.yml +38 -0
- data/test/links.yml +275 -0
- data/test/lists.yml +283 -0
- data/test/poignant.yml +89 -0
- data/test/sanitize_html.yml +42 -0
- data/test/table.yml +267 -0
- data/test/test_custom_tags.rb +46 -0
- data/test/test_erb.rb +13 -0
- data/test/test_extensions.rb +31 -0
- data/test/test_formatters.rb +24 -0
- data/test/test_parser.rb +73 -0
- data/test/test_restrictions.rb +61 -0
- data/test/textism.yml +484 -0
- data/test/threshold.yml +772 -0
- data/test/validate_fixtures.rb +74 -0
- metadata +139 -0
data/BBRedCloth.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{BBRedCloth}
|
5
|
+
s.version = "0.8.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ryan Alyea"]
|
9
|
+
s.date = %q{2010-09-12}
|
10
|
+
s.default_executable = %q{bbredcloth}
|
11
|
+
s.description = %q{BBRedCloth-0.8.0 - Textile parser for Ruby. Includes BBCode additions.
|
12
|
+
http://redcloth.org/}
|
13
|
+
s.email = %q{ryan@fangamer.com}
|
14
|
+
s.executables = ["bbredcloth"]
|
15
|
+
s.extensions = ["ext/redcloth_scan/extconf.rb"]
|
16
|
+
s.extra_rdoc_files = ["CHANGELOG", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "README.textile"]
|
17
|
+
s.files = ["bin/bbredcloth", "CHANGELOG", "COPYING", "ext/mingw-rbconfig.rb", "ext/redcloth_scan/extconf.rb", "ext/redcloth_scan/redcloth.h", "extras/ragel_profiler.rb", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/formatters/latex_entities.yml", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "Manifest", "Rakefile", "README.textile", "setup.rb", "test/basic.yml", "test/code.yml", "test/definitions.yml", "test/extra_whitespace.yml", "test/filter_html.yml", "test/filter_pba.yml", "test/helper.rb", "test/html.yml", "test/images.yml", "test/instiki.yml", "test/links.yml", "test/lists.yml", "test/poignant.yml", "test/sanitize_html.yml", "test/table.yml", "test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb", "test/textism.yml", "test/threshold.yml", "test/validate_fixtures.rb", "BBRedCloth.gemspec", "ext/redcloth_scan/redcloth_attributes.c", "ext/redcloth_scan/redcloth_inline.c", "ext/redcloth_scan/redcloth_scan.c", "ext/redcloth_scan/redcloth_bbcode.c", "ext/redcloth_scan/redcloth_bbcode_inline.c"]
|
18
|
+
s.homepage = %q{http://redcloth.org}
|
19
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "BBRedCloth", "--main", "README.textile"]
|
20
|
+
s.require_paths = ["lib", "ext", "lib/case_sensitive_require"]
|
21
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
|
22
|
+
s.rubyforge_project = %q{bbredcloth}
|
23
|
+
s.rubygems_version = %q{1.3.7}
|
24
|
+
s.summary = %q{BBRedCloth-0.8.0 - Textile parser for Ruby. Includes BBCode additions. http://redcloth.org/}
|
25
|
+
s.test_files = ["test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb"]
|
26
|
+
|
27
|
+
if s.respond_to? :specification_version then
|
28
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
32
|
+
else
|
33
|
+
end
|
34
|
+
else
|
35
|
+
end
|
36
|
+
end
|
data/CHANGELOG
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
=== Edge
|
2
|
+
|
3
|
+
* Mentioned the three supported platforms and what's necessary to build RedCloth in the README file.
|
4
|
+
|
5
|
+
* Fixed a require problem that caused an error when you would gem check --test RedCloth. #91
|
6
|
+
|
7
|
+
=== 4.1.1 / November 19, 2008
|
8
|
+
|
9
|
+
* Added 'lib/case_sensitive_require' back into gemspec. It got left out in the conversion to echoe, so "require 'RedCloth'" didn't work. #88
|
10
|
+
|
11
|
+
* Fixed <embed> being recognized as a block-level element when using the twice-cooked method of flash embedding. #87
|
12
|
+
|
13
|
+
* Added horizontal rules from RedCloth 3. Three or more asterisks, dashes, or underscores between blocks triggers the HR tag.
|
14
|
+
|
15
|
+
* echoe was not being properly registered as a development dependency; a bug in RubyGems was making it a runtime dependency
|
16
|
+
|
17
|
+
* Fixed "No definition for redcloth_to Installing RDoc documentation"
|
18
|
+
|
19
|
+
* Fixed wrong platform names when cross-compiling java and win32 versions
|
20
|
+
|
21
|
+
=== 4.1.0 / October 31, 2008
|
22
|
+
|
23
|
+
* JRuby support! [olabini]
|
24
|
+
To run the tests with JRuby, you only need to: jruby -S rake
|
25
|
+
To compile the jruby version of the gem: jruby -S rake compile
|
26
|
+
|
27
|
+
* Added textilize ERB utility method. [edraut]
|
28
|
+
Use it in an ERB template like this: <%=t my_textile_string %> or
|
29
|
+
<%=r %{Some *textile* if you please!} %>
|
30
|
+
|
31
|
+
* Fix extended blockcode stripping whitespace following blank line. #78
|
32
|
+
|
33
|
+
|
34
|
+
=== 4.0.4 / October 1, 2008
|
35
|
+
|
36
|
+
* Added some very basic support for images in LaTeX. [virtualfunction]
|
37
|
+
|
38
|
+
* Fixed missed caps and inline modifiers wrapped in parentheses. #43, #45
|
39
|
+
|
40
|
+
* Removed indication of quotes explicitly with square brackets. Textile 2.0 does not support this and it wasn't in RedCloth 3. #46
|
41
|
+
|
42
|
+
* Made percent signs less greedy. They must surround a phrase or else they must be surrounded with square brackets, just like sup, sub, and del phrases. #47
|
43
|
+
|
44
|
+
* Reduced link eagerness so it wouldn't include preceding quoted phrases. #48
|
45
|
+
|
46
|
+
* Fixed compatibility issues with Ruby 1.9 [Keita Yamaguchi]. #52, 53, 54
|
47
|
+
|
48
|
+
* Fixed an error when a link was badly nested in parentheses. #55
|
49
|
+
|
50
|
+
* Fixed an error on superscript/subscript parenthetical phrase. #56
|
51
|
+
|
52
|
+
* Fixed bold phrases starting with a number being recognized as unordered lists. #60
|
53
|
+
|
54
|
+
* Fixed behavior of unclosed (multi-paragraph) quotes and incorrect handling of links inside double quotations. #59, #63
|
55
|
+
|
56
|
+
* Fixed empty block HTML disappearing. #64
|
57
|
+
|
58
|
+
|
59
|
+
=== 4.0.3 / August 18, 2008
|
60
|
+
|
61
|
+
* Fix NoMethodError: private method gsub!' called for nil:NilClass when two dimensions followed by a space. #38
|
62
|
+
|
63
|
+
* Fixed unititialized constant RedCloth::TextileDoc with Rails 2.1. Came from a workaround for Rails bug #320 that was applied even when not necessary. #42
|
64
|
+
|
65
|
+
|
66
|
+
=== 4.0.2 / August 15, 2008
|
67
|
+
|
68
|
+
* Fixed link references/aliases not being recognized when they include hyphens. #36
|
69
|
+
|
70
|
+
* Dimensions in feet and inches use correct typographic characters. #25
|
71
|
+
|
72
|
+
* Limit overzealous superscript and subscript. Sup/sub phrases must be surrounded by spaces or square brackets, as in Textile 2. #35
|
73
|
+
|
74
|
+
* Fixed HTML before tables causing the opening table tag to be emitted twice. #33
|
75
|
+
|
76
|
+
* Cleaned up unused code that was causing a warning. #28
|
77
|
+
|
78
|
+
* Workaround for Rails 2.1 bug that loads a previous version of RedCloth before loading the unpacked gem. Has since been fixed in edge rails. #30
|
79
|
+
|
80
|
+
* Added a RedCloth::VERSION.to_s and .== methods so you can puts and compare RedCloth::VERSION just like in previous RedCloth releases. #26
|
81
|
+
|
82
|
+
* Fixed HTML block ending tags terminating blocks prematurely. #22
|
83
|
+
|
84
|
+
|
85
|
+
=== 4.0.1 / July 24, 2008
|
86
|
+
|
87
|
+
* Fixed lines starting with dashes being recognized as a definition list when there were no definitions.
|
88
|
+
|
89
|
+
* Created alias RedCloth.rb so Rails 2.1 gem dependency works on case-sensitive operating systems .
|
90
|
+
* Fixed parsing sentences that had two em dashes surrounded by spaces from becoming del phrases. #19
|
91
|
+
|
92
|
+
* Fixed links including prior quoted phrases. #17
|
93
|
+
|
94
|
+
|
95
|
+
=== 4.0.0 / July 21, 2008
|
96
|
+
|
97
|
+
* New SuperRedCloth (RedCloth 4.0) is a total rewrite using Ragel for the parsing.
|
98
|
+
|
99
|
+
* Markdown support has been removed.
|
100
|
+
|
101
|
+
* Single newlines become <br> tags, just as in traditional RedCloth and other Textile parsers.
|
102
|
+
|
103
|
+
* HTML special characters are automatically escaped inside code signatures, like Textile 2. This means you can simply write @<br />@ and the symbols are escaped whereas in RedCloth 3 you had to write @<br />@ to make the code fragment readable.
|
104
|
+
|
105
|
+
* The restrictions parameter is observed just like previous versions (except :hard_breaks is now the default).
|
106
|
+
|
107
|
+
* Arguments to RedCloth#to_html are called so extensions made for prior versions can work. Note: extensions need to be included rather than defined directly within the RedCloth class as was previously possible.
|
108
|
+
|
109
|
+
* Custom block tags can be implemented as in the previous version, though the means of implementing them differs.
|
110
|
+
|
111
|
+
* HTML embedded in the Textile input does not often need to be escaped from Textile parsing.
|
112
|
+
|
113
|
+
* The parser will not wrap lines that begin with a space in paragraph tags.
|
114
|
+
|
115
|
+
* Rudimentary support for LaTeX is built in.
|
116
|
+
|
117
|
+
* RedCloth::VERSION on a line by itself inserts the version number into the output.
|
118
|
+
|
119
|
+
* Output (less newlines and tabs) is identical to Textile 2 except a few cases where the RedCloth way was preferable.
|
120
|
+
|
121
|
+
* Over 500 tests prevent regression
|
122
|
+
|
123
|
+
* It's 40 times faster than the previous version.
|
data/COPYING
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2008 Jason Garber
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
bin/bbredcloth
|
2
|
+
CHANGELOG
|
3
|
+
COPYING
|
4
|
+
ext/mingw-rbconfig.rb
|
5
|
+
ext/redcloth_scan/extconf.rb
|
6
|
+
ext/redcloth_scan/redcloth.h
|
7
|
+
|
8
|
+
extras/ragel_profiler.rb
|
9
|
+
lib/case_sensitive_require/RedCloth.rb
|
10
|
+
lib/redcloth/erb_extension.rb
|
11
|
+
lib/redcloth/formatters/base.rb
|
12
|
+
lib/redcloth/formatters/html.rb
|
13
|
+
lib/redcloth/formatters/latex.rb
|
14
|
+
lib/redcloth/formatters/latex_entities.yml
|
15
|
+
lib/redcloth/textile_doc.rb
|
16
|
+
lib/redcloth/version.rb
|
17
|
+
lib/redcloth.rb
|
18
|
+
Manifest
|
19
|
+
Rakefile
|
20
|
+
README.textile
|
21
|
+
setup.rb
|
22
|
+
test/basic.yml
|
23
|
+
test/code.yml
|
24
|
+
test/definitions.yml
|
25
|
+
test/extra_whitespace.yml
|
26
|
+
test/filter_html.yml
|
27
|
+
test/filter_pba.yml
|
28
|
+
test/helper.rb
|
29
|
+
test/html.yml
|
30
|
+
test/images.yml
|
31
|
+
test/instiki.yml
|
32
|
+
test/links.yml
|
33
|
+
test/lists.yml
|
34
|
+
test/poignant.yml
|
35
|
+
test/sanitize_html.yml
|
36
|
+
test/table.yml
|
37
|
+
test/test_custom_tags.rb
|
38
|
+
test/test_erb.rb
|
39
|
+
test/test_extensions.rb
|
40
|
+
test/test_formatters.rb
|
41
|
+
test/test_parser.rb
|
42
|
+
test/test_restrictions.rb
|
43
|
+
test/textism.yml
|
44
|
+
test/threshold.yml
|
45
|
+
test/validate_fixtures.rb
|
data/README.textile
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
h1. BBRedCloth - BBCode/Textile parser for Ruby
|
2
|
+
|
3
|
+
Homepage:: http://redcloth.org
|
4
|
+
Authors:: Jason Garber
|
5
|
+
Ryan Alyea
|
6
|
+
Copyright:: (c) 2008 Jason Garber
|
7
|
+
(c) 2009 Ryan Alyea
|
8
|
+
License:: MIT
|
9
|
+
|
10
|
+
(See http://redcloth.org/textile/ for a Textile reference.)
|
11
|
+
|
12
|
+
h2. BBRedCloth
|
13
|
+
|
14
|
+
BBRedCloth is a Ruby library for converting Textile into HTML. While fundamentally based on RedCloth, it also contains the ability to convert
|
15
|
+
|
16
|
+
h2. Installing
|
17
|
+
|
18
|
+
RedCloth can be installed via RubyGems:
|
19
|
+
|
20
|
+
<pre>
|
21
|
+
gem install BBRedCloth
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
It will install the appropriate Ruby gem. JRuby is not supported, nor is the pure-Ruby version.
|
25
|
+
|
26
|
+
If you wish to use BBRedCloth in your Rails 3 project, just add the following to your Gemfile:
|
27
|
+
|
28
|
+
<pre>
|
29
|
+
gem 'BBRedCloth', :require=>"RedCloth"
|
30
|
+
</pre>
|
31
|
+
|
32
|
+
== Compiling
|
33
|
+
|
34
|
+
If you just want to use BBRedCloth, you do NOT need to build/compile it. It is compiled from C sources automatically when you install the gem on the ruby platform.
|
35
|
+
|
36
|
+
BBRedCloth can be compiled with <tt>rake compile</tt>. Ragel 6.3 or greater and the echoe gem (3.1.1) are needed to build, compile, and package RedCloth. Again, Ragel and echoe are NOT needed to simply use RedCloth.
|
37
|
+
|
38
|
+
== Using BBRedCloth
|
39
|
+
|
40
|
+
BBRedCloth was designed to be mostly drop-in compatible with RedCloth. In fact, it still retains the RedCloth class. However, this makes running BBRedCloth and a newer RedCloth impossible for now.
|
41
|
+
|
42
|
+
If you wish to use the general RedCloth/Textile mode with this gem, just do as you normally do!
|
43
|
+
|
44
|
+
<pre>
|
45
|
+
require 'rubygems'
|
46
|
+
gem 'BBRedCloth'
|
47
|
+
require 'RedCloth'
|
48
|
+
text = "This is *my* text."
|
49
|
+
RedCloth.new(text).to_html
|
50
|
+
#=> "<p>This is <strong>my</strong> text.</p>"
|
51
|
+
</pre>
|
52
|
+
|
53
|
+
h3. BBCode
|
54
|
+
|
55
|
+
Because of the drop-in feature, new features must be activated. Just put options in an array after the text. For example:
|
56
|
+
|
57
|
+
<pre>
|
58
|
+
require 'rubygems'
|
59
|
+
gem 'BBRedCloth'
|
60
|
+
require 'RedCloth'
|
61
|
+
text = "This is *Textile* and [b]BBCode[/b] combined!"
|
62
|
+
RedCloth.new(text,[:bbcode]).to_html
|
63
|
+
#=> "<p>This is <strong>Textile</strong> and <strong>BBCode</strong> combined!</p>"
|
64
|
+
</pre>
|
65
|
+
|
66
|
+
h3. Filters
|
67
|
+
|
68
|
+
Most of RedCloth's options are supported such as :filter_html :
|
69
|
+
|
70
|
+
<pre>
|
71
|
+
require 'rubygems'
|
72
|
+
gem 'BBRedCloth'
|
73
|
+
require 'RedCloth'
|
74
|
+
text = "This *Textile* and [b]BBCode[/b] and <b>HTML</b> combined!"
|
75
|
+
RedCloth.new(text,[:bbcode]).to_html
|
76
|
+
RedCloth.new(text,[:filter_html,:bbcode]).to_html
|
77
|
+
#=> "<p>This <strong>Textile</strong> and <strong>BBCode</strong> and <b>HTML</b> combined!</p>"
|
78
|
+
#=> "<p>This <strong>Textile</strong> and <strong>BBCode</strong> and <b>HTML</b> combined!</p>"
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
h3. Disabling Certain HTML Code
|
82
|
+
|
83
|
+
Additionally, you can disable certain HTML features of BBCode and Textile and they are ignored:
|
84
|
+
|
85
|
+
<pre>
|
86
|
+
require 'rubygems'
|
87
|
+
gem 'BBRedCloth'
|
88
|
+
require 'RedCloth'
|
89
|
+
RedCloth.new( "Images should *not* be allowed! !test_image.jpg!", [:disable_inline=>:image] ).to_html
|
90
|
+
#=> "<p>Images should <strong>not</strong> be allowed! !test_image.jpg!</p>"
|
91
|
+
</pre>
|
92
|
+
|
93
|
+
You can disable the following:
|
94
|
+
|
95
|
+
* :image
|
96
|
+
* :link
|
97
|
+
* :code
|
98
|
+
* :notextile
|
99
|
+
* :strong
|
100
|
+
* :b
|
101
|
+
* :em
|
102
|
+
* :i
|
103
|
+
* :del
|
104
|
+
* :ins
|
105
|
+
* :sup
|
106
|
+
* :sub
|
107
|
+
* :span
|
108
|
+
* :cite
|
109
|
+
* :snip
|
110
|
+
* :quote1
|
111
|
+
* :quote2
|
112
|
+
* :multi_paragraph_quote
|
113
|
+
* :link_alias
|
114
|
+
|
115
|
+
h3. BBCode-Only
|
116
|
+
|
117
|
+
If you want to disable Textile, there is a BBCode-only mode:
|
118
|
+
|
119
|
+
<pre>
|
120
|
+
require 'rubygems'
|
121
|
+
gem 'BBRedCloth'
|
122
|
+
require 'RedCloth'
|
123
|
+
text = "This is *Textile* and [b]BBCode[/b] combined!"
|
124
|
+
RedCloth.new(text,[:bbcode_only]).to_html
|
125
|
+
#=> "<p>This is *Textile* and <strong>BBCode</strong> combined!</p>"
|
126
|
+
</pre>
|
127
|
+
|
128
|
+
h2. BBCode
|
129
|
+
|
130
|
+
The following are the tags supported:
|
131
|
+
|
132
|
+
* [b]
|
133
|
+
* [i]
|
134
|
+
* [u]
|
135
|
+
* [s]
|
136
|
+
* [ins]
|
137
|
+
* [del]
|
138
|
+
* [sup]
|
139
|
+
* [sub]
|
140
|
+
* [notextile]
|
141
|
+
* [color]
|
142
|
+
* [size]
|
143
|
+
* [align]
|
144
|
+
* [acronym]
|
145
|
+
* [url]
|
146
|
+
* [img]
|
147
|
+
* [pre]
|
148
|
+
* [quote]
|
149
|
+
* [spoiler]
|
data/Rakefile
ADDED
@@ -0,0 +1,247 @@
|
|
1
|
+
require './lib/redcloth/version'
|
2
|
+
require 'rubygems'
|
3
|
+
gem 'echoe', '>= 3.0.1'
|
4
|
+
require 'echoe'
|
5
|
+
|
6
|
+
# Platform missing from Echoe >= 3.2?
|
7
|
+
|
8
|
+
module Platform
|
9
|
+
def self.windows?
|
10
|
+
@windows ||= RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
|
11
|
+
!@windows.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.gcc?
|
15
|
+
@gcc ||= RUBY_PLATFORM =~ /mingw/
|
16
|
+
!@gcc.nil?
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.msvc?
|
20
|
+
@msvc ||= RUBY_PLATFORM =~ /mswin/
|
21
|
+
!@msvc.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.java?
|
25
|
+
@java ||= RUBY_PLATFORM =~ /java/
|
26
|
+
!@java.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.suffix
|
30
|
+
@suffix ||= Gem.default_exec_format[2..-1]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.rake
|
34
|
+
windows? ? "rake#{suffix}.bat" : "rake#{suffix}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.make
|
38
|
+
msvc? ? 'nmake' : 'make'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
e = Echoe.new('BBRedCloth', RedCloth::VERSION.to_s) do |p|
|
43
|
+
p.summary = RedCloth::DESCRIPTION
|
44
|
+
p.author = "Ryan Alyea"
|
45
|
+
p.email = 'ryan@fangamer.com'
|
46
|
+
p.clean_pattern += ['ext/redcloth_scan/**/*.{bundle,so,obj,pdb,lib,def,exp,c,o,xml,class,jar,java}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp,jar}', 'ext/redcloth_scan/Makefile']
|
47
|
+
p.url = "http://redcloth.org"
|
48
|
+
p.project = "bbredcloth"
|
49
|
+
p.rdoc_pattern = ['README.textile', 'COPING', 'CHANGELOG', 'lib/**/*.rb', 'doc/**/*.rdoc']
|
50
|
+
p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/
|
51
|
+
p.ruby_version = '>=1.8.4'
|
52
|
+
p.extension_pattern = nil
|
53
|
+
|
54
|
+
if Platform.gcc?
|
55
|
+
p.platform = 'x86-mswin32-60'
|
56
|
+
elsif Platform.java?
|
57
|
+
p.platform = 'universal-java'
|
58
|
+
end
|
59
|
+
|
60
|
+
if RUBY_PLATFORM =~ /mingw|mswin|java/
|
61
|
+
p.need_tar_gz = false
|
62
|
+
else
|
63
|
+
p.need_zip = true
|
64
|
+
p.need_tar_gz = true
|
65
|
+
p.extension_pattern = ["ext/**/extconf.rb"]
|
66
|
+
end
|
67
|
+
|
68
|
+
p.eval = proc do
|
69
|
+
case RUBY_PLATFORM
|
70
|
+
when /mingw/
|
71
|
+
self.files += ['lib/redcloth_scan.so']
|
72
|
+
when /java/
|
73
|
+
self.files += ['lib/redcloth_scan.jar']
|
74
|
+
else
|
75
|
+
self.files += %w[attributes inline scan bbcode bbcode_inline].map {|f| "ext/redcloth_scan/redcloth_#{f}.c"}
|
76
|
+
end
|
77
|
+
|
78
|
+
self.require_paths << "lib/case_sensitive_require"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
#### Pre-compiled extensions for alternative platforms
|
84
|
+
|
85
|
+
def move_extensions
|
86
|
+
Dir["ext/**/*.{bundle,so,jar}"].each { |file| mv file, "lib/" }
|
87
|
+
end
|
88
|
+
|
89
|
+
def java_classpath_arg
|
90
|
+
# A myriad of ways to discover the JRuby classpath
|
91
|
+
classpath = begin
|
92
|
+
require 'java'
|
93
|
+
# Already running in a JRuby JVM
|
94
|
+
Java::java.lang.System.getProperty('java.class.path')
|
95
|
+
rescue LoadError
|
96
|
+
ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
|
97
|
+
end
|
98
|
+
classpath ? "-cp #{classpath}" : ""
|
99
|
+
end
|
100
|
+
|
101
|
+
ext = "ext/redcloth_scan"
|
102
|
+
|
103
|
+
case RUBY_PLATFORM
|
104
|
+
when /mingw/
|
105
|
+
|
106
|
+
filename = "lib/redcloth_scan.so"
|
107
|
+
file filename => FileList["#{ext}/redcloth_scan.c", "#{ext}/redcloth_inline.c", "#{ext}/redcloth_attributes.c", "#{ext}/redcloth_bbcode.c","#{ext}/redcloth_bbcode_inline.c"] do
|
108
|
+
cp "ext/mingw-rbconfig.rb", "#{ext}/rbconfig.rb"
|
109
|
+
Dir.chdir("ext/redcloth_scan") do
|
110
|
+
ruby "-I. extconf.rb"
|
111
|
+
system(PLATFORM =~ /mswin/ ? 'nmake' : 'make')
|
112
|
+
end
|
113
|
+
move_extensions
|
114
|
+
rm "#{ext}/rbconfig.rb"
|
115
|
+
end
|
116
|
+
|
117
|
+
when /java/
|
118
|
+
|
119
|
+
filename = "lib/redcloth_scan.jar"
|
120
|
+
file filename => FileList["#{ext}/RedclothScanService.java", "#{ext}/RedclothInline.java", "#{ext}/RedclothAttributes.java"] do
|
121
|
+
sources = FileList["#{ext}/**/*.java"].join(' ')
|
122
|
+
sh "javac -target 1.5 -source 1.5 -d #{ext} #{java_classpath_arg} #{sources}"
|
123
|
+
sh "jar cf lib/redcloth_scan.jar -C #{ext} ."
|
124
|
+
move_extensions
|
125
|
+
end
|
126
|
+
|
127
|
+
else
|
128
|
+
filename = "#{ext}/redcloth_scan.#{Config::CONFIG['DLEXT']}"
|
129
|
+
file filename => FileList["#{ext}/redcloth_scan.c", "#{ext}/redcloth_inline.c", "#{ext}/redcloth_attributes.c", "#{ext}/redcloth_bbcode.c","#{ext}/redcloth_bbcode_inline.c"]
|
130
|
+
end
|
131
|
+
|
132
|
+
task :compile => [filename]
|
133
|
+
|
134
|
+
def ragel(target_file, source_file)
|
135
|
+
host_language = (target_file =~ /java$/) ? "J" : "C"
|
136
|
+
code_style = (host_language == "C") ? " -" + (@code_style || "T0") : ""
|
137
|
+
ensure_ragel_version(target_file) do
|
138
|
+
sh %{ragel #{source_file} -#{host_language}#{code_style} -o #{target_file}}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Make sure the .c files exist if you try the Makefile, otherwise Ragel will have to generate them.
|
143
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb", "#{ext}/redcloth_scan.c","#{ext}/redcloth_inline.c","#{ext}/redcloth_bbcode.c","#{ext}/redcloth_attributes.c","#{ext}/redcloth_bbcode_inline.c","#{ext}/redcloth_scan.o","#{ext}/redcloth_inline.o","#{ext}/redcloth_attributes.o","#{ext}/redcloth_bbcode.o","#{ext}/redcloth_bbcode_inline.o"]
|
144
|
+
|
145
|
+
# Ragel-generated C files
|
146
|
+
file "#{ext}/redcloth_scan.c" => ["#{ext}/redcloth_scan.c.rl", "#{ext}/redcloth_scan.rl", "#{ext}/redcloth_common.c.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
|
147
|
+
ragel "#{ext}/redcloth_scan.c", "#{ext}/redcloth_scan.c.rl"
|
148
|
+
end
|
149
|
+
file "#{ext}/redcloth_inline.c" => ["#{ext}/redcloth_inline.c.rl", "#{ext}/redcloth_inline.rl", "#{ext}/redcloth_common.c.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
|
150
|
+
ragel "#{ext}/redcloth_inline.c", "#{ext}/redcloth_inline.c.rl"
|
151
|
+
end
|
152
|
+
file "#{ext}/redcloth_attributes.c" => ["#{ext}/redcloth_attributes.c.rl", "#{ext}/redcloth_attributes.rl", "#{ext}/redcloth_common.c.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
|
153
|
+
ragel "#{ext}/redcloth_attributes.c", "#{ext}/redcloth_attributes.c.rl"
|
154
|
+
end
|
155
|
+
file "#{ext}/redcloth_bbcode.c" => ["#{ext}/redcloth_bbcode.c.rl", "#{ext}/redcloth_bbcode.rl", "#{ext}/redcloth_common.c.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
|
156
|
+
ragel "#{ext}/redcloth_bbcode.c", "#{ext}/redcloth_bbcode.c.rl"
|
157
|
+
end
|
158
|
+
file "#{ext}/redcloth_bbcode_inline.c" => ["#{ext}/redcloth_bbcode_inline.c.rl", "#{ext}/redcloth_bbcode_inline.rl"] do
|
159
|
+
ragel "#{ext}/redcloth_bbcode_inline.c", "#{ext}/redcloth_bbcode_inline.c.rl"
|
160
|
+
end
|
161
|
+
|
162
|
+
# Ragel-generated Java files
|
163
|
+
file "#{ext}/RedclothScanService.java" => ["#{ext}/redcloth_scan.java.rl", "#{ext}/redcloth_scan.rl", "#{ext}/redcloth_common.java.rl", "#{ext}/redcloth_common.rl"] do
|
164
|
+
ragel "#{ext}/RedclothScanService.java", "#{ext}/redcloth_scan.java.rl"
|
165
|
+
end
|
166
|
+
file "#{ext}/RedclothInline.java" => ["#{ext}/redcloth_inline.java.rl", "#{ext}/redcloth_inline.rl", "#{ext}/redcloth_common.java.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth_scan.java.rl"] do
|
167
|
+
ragel "#{ext}/RedclothInline.java", "#{ext}/redcloth_inline.java.rl"
|
168
|
+
end
|
169
|
+
file "#{ext}/RedclothAttributes.java" => ["#{ext}/redcloth_attributes.java.rl", "#{ext}/redcloth_attributes.rl", "#{ext}/redcloth_common.java.rl", "#{ext}/redcloth_common.rl", "#{ext}/redcloth_scan.java.rl"] do
|
170
|
+
ragel "#{ext}/RedclothAttributes.java", "#{ext}/redcloth_attributes.java.rl"
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
#### Optimization
|
175
|
+
|
176
|
+
RAGEL_CODE_GENERATION_STYLES = {
|
177
|
+
'T0' => "Table driven FSM (default)",
|
178
|
+
'T1' => "Faster table driven FSM",
|
179
|
+
'F0' => "Flat table driven FSM",
|
180
|
+
'F1' => "Faster flat table-driven FSM",
|
181
|
+
'G0' => "Goto-driven FSM",
|
182
|
+
'G1' => "Faster goto-driven FSM",
|
183
|
+
'G2' => "Really fast goto-driven FSM"
|
184
|
+
}
|
185
|
+
|
186
|
+
desc "Find the fastest code generation style for Ragel"
|
187
|
+
task :optimize do
|
188
|
+
require 'extras/ragel_profiler'
|
189
|
+
results = []
|
190
|
+
RAGEL_CODE_GENERATION_STYLES.each do |style, name|
|
191
|
+
@code_style = style
|
192
|
+
profiler = RagelProfiler.new(style + " " + name)
|
193
|
+
|
194
|
+
# Hack to get everything to invoke again. Could use #execute, but then it
|
195
|
+
# doesn't execute prerequisites the second+ time
|
196
|
+
Rake::Task.tasks.each {|t| t.instance_eval "@already_invoked = false" }
|
197
|
+
|
198
|
+
Rake::Task['clobber'].invoke
|
199
|
+
|
200
|
+
profiler.measure(:compile) do
|
201
|
+
Rake::Task['compile'].invoke
|
202
|
+
end
|
203
|
+
profiler.measure(:test) do
|
204
|
+
Rake::Task['test'].invoke
|
205
|
+
end
|
206
|
+
profiler.ext_size(ext_so)
|
207
|
+
|
208
|
+
end
|
209
|
+
puts RagelProfiler.results
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
#### Custom testing tasks
|
214
|
+
|
215
|
+
task :test => [:compile]
|
216
|
+
|
217
|
+
# Run specific tests or test files
|
218
|
+
#
|
219
|
+
# rake test:parser
|
220
|
+
# => Runs the full TestParser unit test
|
221
|
+
#
|
222
|
+
# rake test:parser:textism
|
223
|
+
# => Runs the tests matching /textism/ in the TestParser unit test
|
224
|
+
rule "" do |t|
|
225
|
+
# test:file:method
|
226
|
+
if /test:(.*)(:([^.]+))?$/.match(t.name)
|
227
|
+
arguments = t.name.split(":")[1..-1]
|
228
|
+
file_name = arguments.first
|
229
|
+
test_name = arguments[1..-1]
|
230
|
+
|
231
|
+
if File.exist?("test/test_#{file_name}.rb")
|
232
|
+
run_file_name = "test_#{file_name}.rb"
|
233
|
+
end
|
234
|
+
|
235
|
+
sh "ruby -Ilib:test test/#{run_file_name} -n /#{test_name}/"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def ensure_ragel_version(name)
|
240
|
+
@ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i}
|
241
|
+
if @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 3)
|
242
|
+
yield
|
243
|
+
else
|
244
|
+
STDERR.puts "Ragel 6.3 or greater is required to generate #{name}."
|
245
|
+
exit(1)
|
246
|
+
end
|
247
|
+
end
|
data/bin/bbredcloth
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
3
|
+
require 'optparse'
|
4
|
+
require 'redcloth'
|
5
|
+
|
6
|
+
if %w(--version -v).include? ARGV.first
|
7
|
+
puts "#{RedCloth::NAME} #{RedCloth::VERSION}"
|
8
|
+
exit(0)
|
9
|
+
end
|
10
|
+
|
11
|
+
output_as = "html"
|
12
|
+
bbcode_only = false
|
13
|
+
opts = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: bbredcloth [options] [redcloth_formatted.txt]"
|
15
|
+
opts.separator "If no file specified, STDIN will be used. If you are typing input, you can send an EOF by pressing ^D (^Z on Windows)"
|
16
|
+
opts.separator ""
|
17
|
+
opts.on("-o", "--output STYLE", "Output format (defaults to #{output_as})") do |o|
|
18
|
+
output_as = o
|
19
|
+
end
|
20
|
+
opts.on("-b","--bbcode-only", "BBCode-Only") do |b|
|
21
|
+
bbcode_only = b
|
22
|
+
end
|
23
|
+
end
|
24
|
+
opts.parse! ARGV
|
25
|
+
|
26
|
+
p bbcode_only
|
27
|
+
|
28
|
+
red = RedCloth.new( ARGF.read, [(bbcode_only ? :bbcode_only : :bbcode)] )
|
29
|
+
out_meth = "to_#{ output_as }"
|
30
|
+
if red.respond_to? out_meth
|
31
|
+
puts red.method( out_meth ).call
|
32
|
+
else
|
33
|
+
abort "** No to_#{ output_as } method found for the `#{ output_as }' format"
|
34
|
+
end
|