cbot-bbcodeizer 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README +128 -0
- data/Rakefile +22 -0
- data/bbcodeizer.gemspec +23 -0
- data/init.rb +4 -0
- data/lib/bbcodeizer.rb +171 -0
- data/lib/bbcodeizer/version.rb +3 -0
- data/lib/bbcodeizer_helper.rb +8 -0
- data/rdoc/BBCodeizeHelper.html +182 -0
- data/rdoc/Bbcodeizer.html +146 -0
- data/rdoc/README.html +214 -0
- data/rdoc/created.rid +5 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +60 -0
- data/rdoc/js/darkfish.js +116 -0
- data/rdoc/js/jquery.js +32 -0
- data/rdoc/js/quicksearch.js +114 -0
- data/rdoc/js/thickbox-compressed.js +10 -0
- data/rdoc/lib/bbcodeize_helper_rb.html +54 -0
- data/rdoc/lib/bbcodeizer/version_rb.html +52 -0
- data/rdoc/lib/bbcodeizer_helper_rb.html +54 -0
- data/rdoc/lib/bbcodeizer_rb.html +52 -0
- data/rdoc/rdoc.css +763 -0
- data/test/bbcodeizer_test.rb +145 -0
- metadata +125 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: Bbcodeizer</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="module">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="./index.html">Home</a>
|
25
|
+
<a href="./index.html#classes">Classes</a>
|
26
|
+
<a href="./index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="./lib/bbcodeizer/version_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/bbcodeizer/version.rb">lib/bbcodeizer/version.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="project-metadata">
|
60
|
+
|
61
|
+
|
62
|
+
<div id="fileindex-section" class="section project-section">
|
63
|
+
<h3 class="section-header">Files</h3>
|
64
|
+
<ul>
|
65
|
+
|
66
|
+
<li class="file"><a href="./README.html">README</a></li>
|
67
|
+
|
68
|
+
</ul>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
|
72
|
+
<div id="classindex-section" class="section project-section">
|
73
|
+
<h3 class="section-header">Class/Module Index
|
74
|
+
<span class="search-toggle"><img src="./images/find.png"
|
75
|
+
height="16" width="16" alt="[+]"
|
76
|
+
title="show/hide quicksearch" /></span></h3>
|
77
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
78
|
+
<fieldset>
|
79
|
+
<legend>Quicksearch</legend>
|
80
|
+
<input type="text" name="quicksearch" value=""
|
81
|
+
class="quicksearch-field" />
|
82
|
+
</fieldset>
|
83
|
+
</form>
|
84
|
+
|
85
|
+
<ul class="link-list">
|
86
|
+
|
87
|
+
<li><a href="./BBCodeizeHelper.html">BBCodeizeHelper</a></li>
|
88
|
+
|
89
|
+
<li><a href="./Bbcodeizer.html">Bbcodeizer</a></li>
|
90
|
+
|
91
|
+
</ul>
|
92
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div id="documentation">
|
100
|
+
<h1 class="module">Bbcodeizer</h1>
|
101
|
+
|
102
|
+
<div id="description" class="description">
|
103
|
+
|
104
|
+
</div><!-- description -->
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<!-- Constants -->
|
116
|
+
<div id="constants-list" class="section">
|
117
|
+
<h3 class="section-header">Constants</h3>
|
118
|
+
<dl>
|
119
|
+
|
120
|
+
<dt><a name="VERSION">VERSION</a></dt>
|
121
|
+
|
122
|
+
<dd class="description"></dd>
|
123
|
+
|
124
|
+
|
125
|
+
</dl>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<!-- Methods -->
|
132
|
+
|
133
|
+
</div><!-- 5Buntitled-5D -->
|
134
|
+
|
135
|
+
|
136
|
+
</div><!-- documentation -->
|
137
|
+
|
138
|
+
<div id="validator-badges">
|
139
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
140
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
141
|
+
Rdoc Generator</a> 2</small>.</p>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
</body>
|
145
|
+
</html>
|
146
|
+
|
data/rdoc/README.html
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>File: README [BBCodeizer]</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="./js/jquery.js" type="text/javascript"
|
14
|
+
charset="utf-8"></script>
|
15
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
16
|
+
charset="utf-8"></script>
|
17
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
18
|
+
charset="utf-8"></script>
|
19
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
20
|
+
charset="utf-8"></script>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body class="file">
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="project-metadata">
|
36
|
+
|
37
|
+
|
38
|
+
<div id="fileindex-section" class="section project-section">
|
39
|
+
<h3 class="section-header">Files</h3>
|
40
|
+
<ul>
|
41
|
+
|
42
|
+
<li class="file"><a href="./README.html">README</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
|
48
|
+
<div id="classindex-section" class="section project-section">
|
49
|
+
<h3 class="section-header">Class Index
|
50
|
+
<span class="search-toggle"><img src="./images/find.png"
|
51
|
+
height="16" width="16" alt="[+]"
|
52
|
+
title="show/hide quicksearch" /></span></h3>
|
53
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
54
|
+
<fieldset>
|
55
|
+
<legend>Quicksearch</legend>
|
56
|
+
<input type="text" name="quicksearch" value=""
|
57
|
+
class="quicksearch-field" />
|
58
|
+
</fieldset>
|
59
|
+
</form>
|
60
|
+
|
61
|
+
<ul class="link-list">
|
62
|
+
|
63
|
+
<li><a href="./BBCodeizeHelper.html">BBCodeizeHelper</a></li>
|
64
|
+
|
65
|
+
<li><a href="./Bbcodeizer.html">Bbcodeizer</a></li>
|
66
|
+
|
67
|
+
</ul>
|
68
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div id="documentation">
|
76
|
+
|
77
|
+
<h2>BBCodeizer</h2>
|
78
|
+
|
79
|
+
<p>BBCodeizer is a gem used to translate BBCode to HTML. The main interface is
|
80
|
+
provided through the helper method “bbcodeize.” Use of it is as simple as
|
81
|
+
passing a string to bbcodeize:</p>
|
82
|
+
|
83
|
+
<pre><%= bbcodeize post.body %></pre>
|
84
|
+
|
85
|
+
<p>You can also invoke the BBCodeizer directly without the helper:</p>
|
86
|
+
|
87
|
+
<pre>render :text => BBCodeizer.bbcodeize(post.body)</pre>
|
88
|
+
|
89
|
+
<p>All settings are centralized so you can very quickly deactivate any tag or
|
90
|
+
modify the HTML that is generated. You can modify these settings by adding
|
91
|
+
lines to the end of your environment.rb. For example:</p>
|
92
|
+
|
93
|
+
<pre># deactivate [color], [size], and [code] tags
|
94
|
+
BBCodeizer.deactivate(:color, :size, :code)
|
95
|
+
|
96
|
+
# use <b> instead of <strong>
|
97
|
+
BBCodeizer.replace_using(:bold, '<b>\1</b>')</pre>
|
98
|
+
|
99
|
+
<p>These changes should be considered one-time configuration, e.g. tags cannot
|
100
|
+
be deactivated then activated again.</p>
|
101
|
+
|
102
|
+
<h2>Warning</h2>
|
103
|
+
|
104
|
+
<p>While BBCodeizer does some validation (see below), you should be aware it
|
105
|
+
is possible to create unsafe HTML in the wrong hands (for example, invoking
|
106
|
+
Javascript using the [url] tag). It is highly recommended you run the
|
107
|
+
resulting HTML through a sanity checker such as WhiteList:</p>
|
108
|
+
|
109
|
+
<pre>http://svn.techno-weenie.net/projects/plugins/white_list/</pre>
|
110
|
+
|
111
|
+
<p>Once installed, the following is a helper method that will produce nicely
|
112
|
+
formatted, safe HTML:</p>
|
113
|
+
|
114
|
+
<pre>def format_text(text)
|
115
|
+
white_list(simple_format(auto_link(bbcodeize(h(text)))))
|
116
|
+
end</pre>
|
117
|
+
|
118
|
+
<h2>Supported Tags</h2>
|
119
|
+
|
120
|
+
<p>BBCodeizer currently supports the following tags. The default HTML
|
121
|
+
expansion is documented here.</p>
|
122
|
+
|
123
|
+
<pre>[u]text[/u]
|
124
|
+
|
125
|
+
<u>text</u>
|
126
|
+
|
127
|
+
[b]text[/b]
|
128
|
+
|
129
|
+
<strong>text</strong>
|
130
|
+
|
131
|
+
[i]text[/i]
|
132
|
+
|
133
|
+
<em>text</em>
|
134
|
+
|
135
|
+
[img]http://example.com/image.gif[/img]
|
136
|
+
|
137
|
+
<img src="http://example.com/image.gif" />
|
138
|
+
|
139
|
+
[email=joe@example.com]Joe Example[/email]
|
140
|
+
|
141
|
+
<a href="mailto:joe@example.com">Joe Example</a>
|
142
|
+
|
143
|
+
[email]joe@example.com[/email]
|
144
|
+
|
145
|
+
<a href="mailto:joe@example.com">joe@example.com</a>
|
146
|
+
|
147
|
+
[code]bbcodeize(string)[/code]
|
148
|
+
|
149
|
+
<pre>bbcodeize(string)</pre>
|
150
|
+
|
151
|
+
[url=http://www.google.com]Google[/url]
|
152
|
+
|
153
|
+
<a href="http://www.google.com">Google</a>
|
154
|
+
|
155
|
+
[url]http://www.google.com[/url]
|
156
|
+
|
157
|
+
<a href="http://www.google.com">http://www.google.com</a>
|
158
|
+
|
159
|
+
[quote="Shakespeare"]To be or not to be[/quote]
|
160
|
+
|
161
|
+
<blockquote><cite>Shakespeare wrote:</cite><br />To be or not to
|
162
|
+
be</blockquote>
|
163
|
+
|
164
|
+
[quote]That is the question[/quote]
|
165
|
+
|
166
|
+
<blockquote>That is the question</blockquote>
|
167
|
+
|
168
|
+
[size=32]Big Text[/size]
|
169
|
+
|
170
|
+
<span style="font-size: 32px">Big Text</span>
|
171
|
+
|
172
|
+
[color=red]Red Text[/color] [color=#ABCDEF]Alphabet-colored Text[/color]
|
173
|
+
|
174
|
+
<span style="color: red">Red Text</span>
|
175
|
+
<span style="color: #ABCDEF">Alphabet Colored Text</span></pre>
|
176
|
+
|
177
|
+
<h2>Validation</h2>
|
178
|
+
|
179
|
+
<p>BBCodeizer aims to produce HTML that will not break your site - all opening
|
180
|
+
tags must have a closing tag or they will not be replaced (unmatched tags
|
181
|
+
are left as-is). All [code] and [quote] tags are left entirely untouched if
|
182
|
+
there is any mismatch with either of these. All other tags will replace as
|
183
|
+
many as possible and leave the remaining unmatched tags as-is.</p>
|
184
|
+
|
185
|
+
<p>BBCodeizer attempts to produce XHTML-compliant markup, however, misuse of
|
186
|
+
nesting tags is not validated or corrected. For example:</p>
|
187
|
+
|
188
|
+
<pre>[b]bold [u]bold + underline[/b] underline[/u]</pre>
|
189
|
+
|
190
|
+
<p>Will produce the following HTML:</p>
|
191
|
+
|
192
|
+
<pre><strong>bold <u>bold + underline</strong> underline</u></pre>
|
193
|
+
|
194
|
+
<p>Colors in the [color] tag are not validated - any string can be used.
|
195
|
+
Strings containing semicolons are not allowed to prevent users from adding
|
196
|
+
additional style rules.</p>
|
197
|
+
|
198
|
+
<p>Sizes used in the [size] tag are validated - only 1 or 2 digit numbers are
|
199
|
+
accepted.</p>
|
200
|
+
<hr style="height: 10px">
|
201
|
+
|
202
|
+
<p>Copyright © 2006 Jonathan Dance / Agora Games Copyright © 2011 Luke Curley
|
203
|
+
Distributed under the MIT license</p>
|
204
|
+
|
205
|
+
</div>
|
206
|
+
|
207
|
+
<div id="validator-badges">
|
208
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
209
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
210
|
+
Rdoc Generator</a> 2</small>.</p>
|
211
|
+
</div>
|
212
|
+
</body>
|
213
|
+
</html>
|
214
|
+
|
data/rdoc/created.rid
ADDED
Binary file
|
Binary file
|
data/rdoc/images/bug.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/rdoc/index.html
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>BBCodeizer</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
<script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body class="indexpage">
|
20
|
+
|
21
|
+
|
22
|
+
<h1>BBCodeizer</h1>
|
23
|
+
|
24
|
+
|
25
|
+
<p>This is the API documentation for 'BBCodeizer'.</p>
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
<h2>Files</h2>
|
31
|
+
<ul>
|
32
|
+
|
33
|
+
<li class="file"><a href="README.html">README</a></li>
|
34
|
+
|
35
|
+
</ul>
|
36
|
+
|
37
|
+
|
38
|
+
<h2 id="classes">Classes/Modules</h2>
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li class="module"><a href="BBCodeizeHelper.html">BBCodeizeHelper</a></li>
|
42
|
+
|
43
|
+
<li class="module"><a href="Bbcodeizer.html">Bbcodeizer</a></li>
|
44
|
+
|
45
|
+
</ul>
|
46
|
+
|
47
|
+
<h2 id="methods">Methods</h2>
|
48
|
+
<ul>
|
49
|
+
|
50
|
+
<li><a href="BBCodeizeHelper.html#method-i-bbcodeize">#bbcodeize — BBCodeizeHelper</a></li>
|
51
|
+
|
52
|
+
</ul>
|
53
|
+
|
54
|
+
<div id="validator-badges">
|
55
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
56
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
57
|
+
Rdoc Generator</a> 2</small>.</p>
|
58
|
+
</div>
|
59
|
+
</body>
|
60
|
+
</html>
|