BBRedCloth 0.8.0 → 0.8.1
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/BBRedCloth.gemspec +7 -7
- data/Manifest +17 -2
- data/bin/{bbredcloth → redcloth} +2 -8
- data/ext/redcloth_scan/redcloth.h +5 -2
- data/ext/redcloth_scan/redcloth_attributes.c.rl +56 -0
- data/ext/redcloth_scan/redcloth_attributes.java.rl +96 -0
- data/ext/redcloth_scan/redcloth_attributes.rl +33 -0
- data/ext/redcloth_scan/redcloth_bbcode.c +14 -14
- data/ext/redcloth_scan/redcloth_bbcode.c.rl +60 -0
- data/ext/redcloth_scan/redcloth_bbcode.rl +127 -0
- data/ext/redcloth_scan/redcloth_bbcode_inline.c +14 -14
- data/ext/redcloth_scan/redcloth_bbcode_inline.c.rl +72 -0
- data/ext/redcloth_scan/redcloth_bbcode_inline.rl +84 -0
- data/ext/redcloth_scan/redcloth_common.c.rl +19 -0
- data/ext/redcloth_scan/redcloth_common.java.rl +18 -0
- data/ext/redcloth_scan/redcloth_common.rl +111 -0
- data/ext/redcloth_scan/redcloth_inline.c +46 -24
- data/ext/redcloth_scan/redcloth_inline.c.rl +205 -0
- data/ext/redcloth_scan/redcloth_inline.java.rl +108 -0
- data/ext/redcloth_scan/redcloth_inline.rl +176 -0
- data/ext/redcloth_scan/redcloth_scan.c +6 -6
- data/ext/redcloth_scan/redcloth_scan.c.rl +236 -0
- data/ext/redcloth_scan/redcloth_scan.java.rl +555 -0
- data/ext/redcloth_scan/redcloth_scan.rl +426 -0
- data/lib/redcloth/version.rb +1 -1
- data/test/basic.yml +5 -0
- data/test/html.yml +1 -1
- data/test/test_restrictions.rb +1 -1
- metadata +26 -7
data/BBRedCloth.gemspec
CHANGED
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{BBRedCloth}
|
|
5
|
-
s.version = "0.8.
|
|
5
|
+
s.version = "0.8.1"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Ryan Alyea"]
|
|
9
|
-
s.date = %q{
|
|
10
|
-
s.default_executable = %q{
|
|
11
|
-
s.description = %q{BBRedCloth-0.8.
|
|
9
|
+
s.date = %q{2011-04-19}
|
|
10
|
+
s.default_executable = %q{redcloth}
|
|
11
|
+
s.description = %q{BBRedCloth-0.8.1 - Textile parser for Ruby. Includes BBCode additions.
|
|
12
12
|
http://redcloth.org/}
|
|
13
13
|
s.email = %q{ryan@fangamer.com}
|
|
14
|
-
s.executables = ["
|
|
14
|
+
s.executables = ["redcloth"]
|
|
15
15
|
s.extensions = ["ext/redcloth_scan/extconf.rb"]
|
|
16
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/
|
|
17
|
+
s.files = ["bin/redcloth", "CHANGELOG", "COPYING", "ext/mingw-rbconfig.rb", "ext/redcloth_scan/extconf.rb", "ext/redcloth_scan/redcloth.h", "ext/redcloth_scan/redcloth_attributes.c.rl", "ext/redcloth_scan/redcloth_attributes.java.rl", "ext/redcloth_scan/redcloth_attributes.rl", "ext/redcloth_scan/redcloth_bbcode.c.rl", "ext/redcloth_scan/redcloth_bbcode.rl", "ext/redcloth_scan/redcloth_bbcode_inline.rl", "ext/redcloth_scan/redcloth_bbcode_inline.c.rl", "ext/redcloth_scan/redcloth_common.c.rl", "ext/redcloth_scan/redcloth_common.java.rl", "ext/redcloth_scan/redcloth_common.rl", "ext/redcloth_scan/redcloth_inline.c.rl", "ext/redcloth_scan/redcloth_inline.java.rl", "ext/redcloth_scan/redcloth_inline.rl", "ext/redcloth_scan/redcloth_scan.c.rl", "ext/redcloth_scan/redcloth_scan.java.rl", "ext/redcloth_scan/redcloth_scan.rl", "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
18
|
s.homepage = %q{http://redcloth.org}
|
|
19
19
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "BBRedCloth", "--main", "README.textile"]
|
|
20
20
|
s.require_paths = ["lib", "ext", "lib/case_sensitive_require"]
|
|
21
21
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
|
|
22
22
|
s.rubyforge_project = %q{bbredcloth}
|
|
23
23
|
s.rubygems_version = %q{1.3.7}
|
|
24
|
-
s.summary = %q{BBRedCloth-0.8.
|
|
24
|
+
s.summary = %q{BBRedCloth-0.8.1 - Textile parser for Ruby. Includes BBCode additions. http://redcloth.org/}
|
|
25
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
26
|
|
|
27
27
|
if s.respond_to? :specification_version then
|
data/Manifest
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
bin/
|
|
1
|
+
bin/redcloth
|
|
2
2
|
CHANGELOG
|
|
3
3
|
COPYING
|
|
4
4
|
ext/mingw-rbconfig.rb
|
|
5
5
|
ext/redcloth_scan/extconf.rb
|
|
6
6
|
ext/redcloth_scan/redcloth.h
|
|
7
|
-
|
|
7
|
+
ext/redcloth_scan/redcloth_attributes.c.rl
|
|
8
|
+
ext/redcloth_scan/redcloth_attributes.java.rl
|
|
9
|
+
ext/redcloth_scan/redcloth_attributes.rl
|
|
10
|
+
ext/redcloth_scan/redcloth_bbcode.c.rl
|
|
11
|
+
ext/redcloth_scan/redcloth_bbcode.rl
|
|
12
|
+
ext/redcloth_scan/redcloth_bbcode_inline.rl
|
|
13
|
+
ext/redcloth_scan/redcloth_bbcode_inline.c.rl
|
|
14
|
+
ext/redcloth_scan/redcloth_common.c.rl
|
|
15
|
+
ext/redcloth_scan/redcloth_common.java.rl
|
|
16
|
+
ext/redcloth_scan/redcloth_common.rl
|
|
17
|
+
ext/redcloth_scan/redcloth_inline.c.rl
|
|
18
|
+
ext/redcloth_scan/redcloth_inline.java.rl
|
|
19
|
+
ext/redcloth_scan/redcloth_inline.rl
|
|
20
|
+
ext/redcloth_scan/redcloth_scan.c.rl
|
|
21
|
+
ext/redcloth_scan/redcloth_scan.java.rl
|
|
22
|
+
ext/redcloth_scan/redcloth_scan.rl
|
|
8
23
|
extras/ragel_profiler.rb
|
|
9
24
|
lib/case_sensitive_require/RedCloth.rb
|
|
10
25
|
lib/redcloth/erb_extension.rb
|
data/bin/{bbredcloth → redcloth}
RENAMED
|
@@ -9,23 +9,17 @@ if %w(--version -v).include? ARGV.first
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
output_as = "html"
|
|
12
|
-
bbcode_only = false
|
|
13
12
|
opts = OptionParser.new do |opts|
|
|
14
|
-
opts.banner = "Usage:
|
|
13
|
+
opts.banner = "Usage: redcloth [options] [redcloth_formatted.txt]"
|
|
15
14
|
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
15
|
opts.separator ""
|
|
17
16
|
opts.on("-o", "--output STYLE", "Output format (defaults to #{output_as})") do |o|
|
|
18
17
|
output_as = o
|
|
19
18
|
end
|
|
20
|
-
opts.on("-b","--bbcode-only", "BBCode-Only") do |b|
|
|
21
|
-
bbcode_only = b
|
|
22
|
-
end
|
|
23
19
|
end
|
|
24
20
|
opts.parse! ARGV
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
red = RedCloth.new( ARGF.read, [(bbcode_only ? :bbcode_only : :bbcode)] )
|
|
22
|
+
red = RedCloth.new( ARGF.read )
|
|
29
23
|
out_meth = "to_#{ output_as }"
|
|
30
24
|
if red.respond_to? out_meth
|
|
31
25
|
puts red.method( out_meth ).call
|
|
@@ -36,6 +36,7 @@ void red_inc(VALUE, VALUE);
|
|
|
36
36
|
VALUE red_block(VALUE, VALUE, VALUE, VALUE);
|
|
37
37
|
VALUE red_blockcode(VALUE, VALUE, VALUE);
|
|
38
38
|
VALUE red_pass(VALUE, VALUE, VALUE, ID, VALUE);
|
|
39
|
+
VALUE red_passthrough(VALUE self, char *ts, char *te, VALUE refs);
|
|
39
40
|
VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
40
41
|
VALUE redcloth_bbcode(VALUE, char *, char *, VALUE);
|
|
41
42
|
VALUE redcloth_bbcode2(VALUE, VALUE, VALUE);
|
|
@@ -45,8 +46,10 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
|
|
|
45
46
|
/* parser macros */
|
|
46
47
|
#define CALL_STACK_SIZE 20
|
|
47
48
|
#define UNLESS_DISABLED_INLINE(H, T, F) \
|
|
48
|
-
if (rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue) {
|
|
49
|
-
else { F }
|
|
49
|
+
if (rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue) { rb_str_append(H,red_passthrough(self, ts, te, refs)); } \
|
|
50
|
+
else { /*VALUE test = rb_str_new(ts,te-ts); printf("\nred_passthrough_else() '%s'\n", RSTRING(test)->ptr);*/ F }
|
|
51
|
+
#define UNLESS_DISABLED_ATTRIBUTE(T, F) \
|
|
52
|
+
if (!(rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue)) { F } //if !(rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue) { F }
|
|
50
53
|
#define CLEAR_REGS() regs = rb_hash_new();
|
|
51
54
|
#define RESET_REG() reg = NULL
|
|
52
55
|
#define CAT(H) rb_str_cat(H, ts, te-ts)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* redcloth_attributes.c.rl
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008 Jason Garber
|
|
5
|
+
*/
|
|
6
|
+
#include <ruby.h>
|
|
7
|
+
#include "redcloth.h"
|
|
8
|
+
|
|
9
|
+
%%{
|
|
10
|
+
|
|
11
|
+
machine redcloth_attributes;
|
|
12
|
+
include redcloth_common "redcloth_common.c.rl";
|
|
13
|
+
include redcloth_attributes "redcloth_attributes.rl";
|
|
14
|
+
|
|
15
|
+
}%%
|
|
16
|
+
|
|
17
|
+
%% write data nofinal;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
VALUE
|
|
21
|
+
redcloth_attribute_parser(machine, self, p, pe)
|
|
22
|
+
int machine;
|
|
23
|
+
VALUE self;
|
|
24
|
+
char *p, *pe;
|
|
25
|
+
{
|
|
26
|
+
int cs, act;
|
|
27
|
+
char *ts, *te, *reg, *bck, *eof;
|
|
28
|
+
VALUE regs = rb_hash_new();
|
|
29
|
+
VALUE buf = Qnil;
|
|
30
|
+
|
|
31
|
+
%% write init;
|
|
32
|
+
|
|
33
|
+
cs = machine;
|
|
34
|
+
|
|
35
|
+
%% write exec;
|
|
36
|
+
|
|
37
|
+
return regs;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
VALUE
|
|
41
|
+
redcloth_attributes(self, str)
|
|
42
|
+
VALUE self, str;
|
|
43
|
+
{
|
|
44
|
+
StringValue(str);
|
|
45
|
+
int cs = redcloth_attributes_en_inline;
|
|
46
|
+
return redcloth_attribute_parser(cs, self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
VALUE
|
|
50
|
+
redcloth_link_attributes(self, str)
|
|
51
|
+
VALUE self, str;
|
|
52
|
+
{
|
|
53
|
+
StringValue(str);
|
|
54
|
+
int cs = redcloth_attributes_en_link_says;
|
|
55
|
+
return redcloth_attribute_parser(cs, self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1);
|
|
56
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* redcloth_attributes.rl
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008 Jason Garber
|
|
5
|
+
*/
|
|
6
|
+
import java.io.IOException;
|
|
7
|
+
|
|
8
|
+
import org.jruby.Ruby;
|
|
9
|
+
import org.jruby.RubyArray;
|
|
10
|
+
import org.jruby.RubyClass;
|
|
11
|
+
import org.jruby.RubyHash;
|
|
12
|
+
import org.jruby.RubyModule;
|
|
13
|
+
import org.jruby.RubyNumeric;
|
|
14
|
+
import org.jruby.RubyObject;
|
|
15
|
+
import org.jruby.RubyString;
|
|
16
|
+
import org.jruby.RubySymbol;
|
|
17
|
+
import org.jruby.anno.JRubyMethod;
|
|
18
|
+
import org.jruby.runtime.Block;
|
|
19
|
+
import org.jruby.runtime.CallbackFactory;
|
|
20
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
|
21
|
+
import org.jruby.exceptions.RaiseException;
|
|
22
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
|
23
|
+
|
|
24
|
+
import org.jruby.util.ByteList;
|
|
25
|
+
|
|
26
|
+
public class RedclothAttributes extends RedclothScanService.Base {
|
|
27
|
+
|
|
28
|
+
%%{
|
|
29
|
+
|
|
30
|
+
machine redcloth_attributes;
|
|
31
|
+
include redcloth_common "redcloth_common.java.rl";
|
|
32
|
+
include redcloth_attributes "redcloth_attributes.rl";
|
|
33
|
+
|
|
34
|
+
}%%
|
|
35
|
+
|
|
36
|
+
%% write data nofinal;
|
|
37
|
+
|
|
38
|
+
public void SET_ATTRIBUTES() {
|
|
39
|
+
SET_ATTRIBUTE("class_buf", "class");
|
|
40
|
+
SET_ATTRIBUTE("id_buf", "id");
|
|
41
|
+
SET_ATTRIBUTE("lang_buf", "lang");
|
|
42
|
+
SET_ATTRIBUTE("style_buf", "style");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void SET_ATTRIBUTE(String B, String A) {
|
|
46
|
+
buf = ((RubyHash)regs).aref(runtime.newSymbol(B));
|
|
47
|
+
if(!buf.isNil()) {
|
|
48
|
+
((RubyHash)regs).aset(runtime.newSymbol(A), buf);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private int machine;
|
|
53
|
+
private IRubyObject buf;
|
|
54
|
+
|
|
55
|
+
public RedclothAttributes(int machine, IRubyObject self, byte[] data, int p, int pe) {
|
|
56
|
+
this.runtime = self.getRuntime();
|
|
57
|
+
this.self = self;
|
|
58
|
+
|
|
59
|
+
// This is GROSS but necessary for EOF matching
|
|
60
|
+
this.data = new byte[pe+1];
|
|
61
|
+
System.arraycopy(data, p, this.data, 0, pe);
|
|
62
|
+
this.data[pe] = 0;
|
|
63
|
+
|
|
64
|
+
this.p = 0;
|
|
65
|
+
this.pe = pe+1;
|
|
66
|
+
this.eof = this.pe;
|
|
67
|
+
this.orig_p = 0;
|
|
68
|
+
this.orig_pe = this.pe;
|
|
69
|
+
|
|
70
|
+
this.regs = RubyHash.newHash(runtime);
|
|
71
|
+
this.buf = runtime.getNil();
|
|
72
|
+
this.machine = machine;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public IRubyObject parse() {
|
|
76
|
+
%% write init;
|
|
77
|
+
|
|
78
|
+
cs = machine;
|
|
79
|
+
|
|
80
|
+
%% write exec;
|
|
81
|
+
|
|
82
|
+
return regs;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public static IRubyObject attributes(IRubyObject self, IRubyObject str) {
|
|
86
|
+
ByteList bl = str.convertToString().getByteList();
|
|
87
|
+
int cs = redcloth_attributes_en_inline;
|
|
88
|
+
return new RedclothAttributes(cs, self, bl.bytes, bl.begin, bl.realSize).parse();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public static IRubyObject link_attributes(IRubyObject self, IRubyObject str) {
|
|
92
|
+
ByteList bl = str.convertToString().getByteList();
|
|
93
|
+
int cs = redcloth_attributes_en_link_says;
|
|
94
|
+
return new RedclothAttributes(cs, self, bl.bytes, bl.begin, bl.realSize).parse();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* redcloth_attributes.rl
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008 Jason Garber
|
|
5
|
+
*/
|
|
6
|
+
%%{
|
|
7
|
+
|
|
8
|
+
machine redcloth_attributes;
|
|
9
|
+
|
|
10
|
+
C2_CLAS = ( "(" ( [^)#]+ >A %{ STORE("class_buf"); } )? ("#" [^)]+ >A %{STORE("id_buf");} )? ")" ) ;
|
|
11
|
+
C2_LNGE = ( "[" [^\]]+ >A %{ STORE("lang_buf"); } "]" ) ;
|
|
12
|
+
C2_STYL = ( "{" [^}]+ >A %{ STORE("style_buf"); } "}" ) ;
|
|
13
|
+
C2 = ( C2_CLAS | C2_STYL | C2_LNGE )+ ;
|
|
14
|
+
|
|
15
|
+
mtext_with_attributes = ( C2 mtext >A %T ) >X ;
|
|
16
|
+
|
|
17
|
+
inline := |*
|
|
18
|
+
|
|
19
|
+
mtext_with_attributes { SET_ATTRIBUTES(); } ;
|
|
20
|
+
|
|
21
|
+
*|;
|
|
22
|
+
|
|
23
|
+
link_text_with_attributes = C2 "."* " "* ( mtext+ ) >A %{ STORE("name"); } ;
|
|
24
|
+
link_text_without_attributes = ( mtext+ ) >B %{ STORE_B("name_without_attributes"); } ;
|
|
25
|
+
|
|
26
|
+
link_says := |*
|
|
27
|
+
|
|
28
|
+
link_text_with_attributes { SET_ATTRIBUTES(); } ;
|
|
29
|
+
link_text_without_attributes { SET_ATTRIBUTE("name_without_attributes", "name"); } ;
|
|
30
|
+
|
|
31
|
+
*|;
|
|
32
|
+
|
|
33
|
+
}%%;
|
|
@@ -2014,35 +2014,35 @@ _eof_trans:
|
|
|
2014
2014
|
break;
|
|
2015
2015
|
case 26:
|
|
2016
2016
|
#line 60 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2017
|
-
{te = p+1;{ PASS(block, "text", "strong"); }}
|
|
2017
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,strong,PASS(block, "text", "strong");) }}
|
|
2018
2018
|
break;
|
|
2019
2019
|
case 27:
|
|
2020
2020
|
#line 61 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2021
|
-
{te = p+1;{ PASS(block, "text", "em"); }}
|
|
2021
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,em,PASS(block, "text", "em");) }}
|
|
2022
2022
|
break;
|
|
2023
2023
|
case 28:
|
|
2024
2024
|
#line 62 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2025
|
-
{te = p+1;{ PASS(block, "text", "ins"); }}
|
|
2025
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) }}
|
|
2026
2026
|
break;
|
|
2027
2027
|
case 29:
|
|
2028
2028
|
#line 63 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2029
|
-
{te = p+1;{ PASS(block, "text", "del"); }}
|
|
2029
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,s,PASS(block, "text", "del");) }}
|
|
2030
2030
|
break;
|
|
2031
2031
|
case 30:
|
|
2032
2032
|
#line 64 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2033
|
-
{te = p+1;{ PASS(block, "text", "del"); }}
|
|
2033
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,del,PASS(block, "text", "del");) }}
|
|
2034
2034
|
break;
|
|
2035
2035
|
case 31:
|
|
2036
2036
|
#line 65 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2037
|
-
{te = p+1;{ PASS(block, "text", "ins"); }}
|
|
2037
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) }}
|
|
2038
2038
|
break;
|
|
2039
2039
|
case 32:
|
|
2040
2040
|
#line 66 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2041
|
-
{te = p+1;{ PASS(block, "text", "sub"); }}
|
|
2041
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,sub,PASS(block, "text", "sub");) }}
|
|
2042
2042
|
break;
|
|
2043
2043
|
case 33:
|
|
2044
2044
|
#line 67 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2045
|
-
{te = p+1;{ PASS(block, "text", "sup"); }}
|
|
2045
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,sup,PASS(block, "text", "sup");) }}
|
|
2046
2046
|
break;
|
|
2047
2047
|
case 34:
|
|
2048
2048
|
#line 8 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
@@ -2050,27 +2050,27 @@ _eof_trans:
|
|
|
2050
2050
|
break;
|
|
2051
2051
|
case 35:
|
|
2052
2052
|
#line 69 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2053
|
-
{te = p+1;{ PASS(block, "text", "color"); }}
|
|
2053
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,color,PASS(block, "text", "color");) }}
|
|
2054
2054
|
break;
|
|
2055
2055
|
case 36:
|
|
2056
2056
|
#line 70 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2057
|
-
{te = p+1;{ PASS(block, "text", "bbsize"); }}
|
|
2057
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,size,PASS(block, "text", "bbsize");) }}
|
|
2058
2058
|
break;
|
|
2059
2059
|
case 37:
|
|
2060
2060
|
#line 71 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2061
|
-
{te = p+1;{ PASS(block, "text", "bbalign"); }}
|
|
2061
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,align,PASS(block, "text", "bbalign");) }}
|
|
2062
2062
|
break;
|
|
2063
2063
|
case 38:
|
|
2064
2064
|
#line 72 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2065
|
-
{te = p+1;{ PASS(block, "text", "acronym"); }}
|
|
2065
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,acronym,PASS(block, "text", "acronym");) }}
|
|
2066
2066
|
break;
|
|
2067
2067
|
case 39:
|
|
2068
2068
|
#line 73 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2069
|
-
{te = p+1;{ PASS(block, "name", "link"); }}
|
|
2069
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) }}
|
|
2070
2070
|
break;
|
|
2071
2071
|
case 40:
|
|
2072
2072
|
#line 74 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
2073
|
-
{te = p+1;{ PASS(block, "name", "link"); }}
|
|
2073
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) }}
|
|
2074
2074
|
break;
|
|
2075
2075
|
case 41:
|
|
2076
2076
|
#line 75 "ext/redcloth_scan/redcloth_bbcode.c.rl"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* redcloth_bbcode.c.rl
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2009 Ryan Alyea
|
|
5
|
+
*/
|
|
6
|
+
#include <ruby.h>
|
|
7
|
+
#include "redcloth.h"
|
|
8
|
+
|
|
9
|
+
%%{
|
|
10
|
+
|
|
11
|
+
machine redcloth_bbcode;
|
|
12
|
+
include redcloth_common "redcloth_common.c.rl";
|
|
13
|
+
include redcloth_bbcode "redcloth_bbcode.rl";
|
|
14
|
+
|
|
15
|
+
}%%
|
|
16
|
+
|
|
17
|
+
%% write data nofinal;
|
|
18
|
+
|
|
19
|
+
VALUE
|
|
20
|
+
redcloth_bbcode(self, p, pe, refs)
|
|
21
|
+
VALUE self;
|
|
22
|
+
char *p, *pe;
|
|
23
|
+
VALUE refs;
|
|
24
|
+
{
|
|
25
|
+
int cs, act, nest;
|
|
26
|
+
char *ts = NULL, *te = NULL, *reg = NULL, *bck = NULL, *eof = NULL;
|
|
27
|
+
char *orig_p = p, *orig_pe = pe;
|
|
28
|
+
VALUE block = rb_str_new2("");
|
|
29
|
+
VALUE regs = Qnil; CLEAR_REGS()
|
|
30
|
+
unsigned int opts = 0;
|
|
31
|
+
VALUE buf = Qnil;
|
|
32
|
+
VALUE hash = Qnil;
|
|
33
|
+
|
|
34
|
+
VALUE html = rb_str_new2("");
|
|
35
|
+
VALUE failed_start = rb_str_new2("");
|
|
36
|
+
char *failed_start_point_p = NULL, *failed_start_point_ts = NULL, *failed_start_point_te = NULL;
|
|
37
|
+
int stack[CALL_STACK_SIZE],top,nested_quote = 0, nested_spoiler = 0, store_cite = 1, store_title = 1;
|
|
38
|
+
|
|
39
|
+
%% write init;
|
|
40
|
+
|
|
41
|
+
%% write exec;
|
|
42
|
+
|
|
43
|
+
if (RSTRING_LEN(block) > 0)
|
|
44
|
+
{
|
|
45
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), block);
|
|
46
|
+
rb_str_append(html, rb_funcall(self, rb_intern("p"), 1, regs));
|
|
47
|
+
CLEAR(block);
|
|
48
|
+
CLEAR_REGS()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return rb_funcall(html, rb_intern("strip"), 0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
VALUE
|
|
55
|
+
redcloth_bbcode2(self, str, refs)
|
|
56
|
+
VALUE self, str, refs;
|
|
57
|
+
{
|
|
58
|
+
StringValue(str);
|
|
59
|
+
return redcloth_bbcode(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, refs);
|
|
60
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* redcloth_bbcode.rl
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2009 Ryan Alyea
|
|
5
|
+
*/
|
|
6
|
+
%%{
|
|
7
|
+
|
|
8
|
+
machine redcloth_bbcode;
|
|
9
|
+
include redcloth_bbcode_inline 'redcloth_bbcode_inline.rl';
|
|
10
|
+
|
|
11
|
+
#bb_pre_tag_start = "[pre" [^\]]* "]" (space* "[code]")? ;
|
|
12
|
+
#bb_pre_tag_end = ("[/code]" space*)? "[/pre]" LF? ;
|
|
13
|
+
|
|
14
|
+
bb_quote_title = " title"? "=" bbmtext %{ if(store_cite) STORE("cite"); } >A;
|
|
15
|
+
bb_quote_tag_start = LF? ("[quote" bb_quote_title? "]") ;
|
|
16
|
+
bb_quote_tag_end = "[/quote]" LF? ;
|
|
17
|
+
|
|
18
|
+
bb_spoiler_tag_title = " title"? "=" bbmtext %{ if(store_title) STORE("title"); } >A;
|
|
19
|
+
bb_spoiler_tag_start = ("[spoiler" bb_spoiler_tag_title? "]") ;
|
|
20
|
+
bb_spoiler_tag_end = "[/spoiler]" LF? ;
|
|
21
|
+
|
|
22
|
+
bbcode_tag = "[";
|
|
23
|
+
bbcode_tag_not_quote_end = bbcode_tag -- bb_quote_tag_end;
|
|
24
|
+
|
|
25
|
+
blank_line = LF;
|
|
26
|
+
double_return = LF{2,} ;
|
|
27
|
+
|
|
28
|
+
direct_uri = "http" "s"? "://" uchar+ absolute_path?;
|
|
29
|
+
automatic_url = direct_uri >X >A %{ STORE_URL("href"); } ;
|
|
30
|
+
|
|
31
|
+
bb_pre_tag := |*
|
|
32
|
+
bb_pre_tag_end {
|
|
33
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), rb_funcall(self, rb_intern("escape_pre"), 1, rb_funcall(block,rb_intern("strip"),0)));
|
|
34
|
+
rb_str_append(html,rb_funcall(self, rb_intern("bb_block_pre"), 1, regs));
|
|
35
|
+
CLEAR(block);
|
|
36
|
+
CLEAR_REGS();
|
|
37
|
+
fgoto main;
|
|
38
|
+
};
|
|
39
|
+
default => cat;
|
|
40
|
+
EOF => { CLEAR(block); CLEAR_REGS(); rb_str_append(block,failed_start); failed_start = rb_str_new2(""); p = failed_start_point_p; ts = failed_start_point_ts; te = failed_start_point_te; fgoto done; };
|
|
41
|
+
*|;
|
|
42
|
+
|
|
43
|
+
bb_quote_tag := |*
|
|
44
|
+
bb_quote_tag_start => { CAT(block); ++nested_quote; };
|
|
45
|
+
bb_quote_tag_end {
|
|
46
|
+
if (nested_quote-- == 0) {
|
|
47
|
+
//printf("\n\nQUOTE TAG: %s \n\n",RSTRING_PTR(rb_funcall(block,rb_intern("strip"),0)));
|
|
48
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), redcloth_bbcode2(self,rb_funcall(block,rb_intern("strip"),0),rb_hash_new()));
|
|
49
|
+
rb_str_append(html,rb_funcall(self, rb_intern("bbquote"), 1, regs));
|
|
50
|
+
nested_quote = 0;
|
|
51
|
+
store_cite = 1;
|
|
52
|
+
CLEAR(block);
|
|
53
|
+
CLEAR_REGS();
|
|
54
|
+
fgoto main;
|
|
55
|
+
}
|
|
56
|
+
else { CAT(block); }
|
|
57
|
+
};
|
|
58
|
+
default => cat;
|
|
59
|
+
EOF => { CLEAR(block); CLEAR_REGS(); rb_str_append(block,failed_start); failed_start = rb_str_new2(""); p = failed_start_point_p; ts = failed_start_point_ts; te = failed_start_point_te; fgoto done; };
|
|
60
|
+
*|;
|
|
61
|
+
|
|
62
|
+
bb_spoiler_tag := |*
|
|
63
|
+
bb_spoiler_tag_start => { CAT(block); ++nested_spoiler; };
|
|
64
|
+
bb_spoiler_tag_end {
|
|
65
|
+
if (nested_spoiler-- == 0) {
|
|
66
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), redcloth_bbcode2(self,rb_funcall(block,rb_intern("strip"),0),rb_hash_new()));
|
|
67
|
+
rb_str_append(html,rb_funcall(self, rb_intern("bb_block_spoiler"), 1, regs));
|
|
68
|
+
nested_spoiler = 0;
|
|
69
|
+
store_title = 1;
|
|
70
|
+
CLEAR(block);
|
|
71
|
+
CLEAR_REGS();
|
|
72
|
+
fgoto main;
|
|
73
|
+
}
|
|
74
|
+
else { CAT(block); }
|
|
75
|
+
};
|
|
76
|
+
default => cat;
|
|
77
|
+
EOF => { CLEAR(block); CLEAR_REGS(); rb_str_append(block,failed_start); failed_start = rb_str_new2(""); p = failed_start_point_p; ts = failed_start_point_ts; te = failed_start_point_te; fgoto done; };
|
|
78
|
+
*|;
|
|
79
|
+
|
|
80
|
+
done := |*
|
|
81
|
+
EOF;
|
|
82
|
+
*|;
|
|
83
|
+
|
|
84
|
+
block := |*
|
|
85
|
+
EOF {
|
|
86
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), rb_funcall(block,rb_intern("strip"),0));
|
|
87
|
+
rb_str_append(html, rb_funcall(self, rb_intern("p"), 1, regs));
|
|
88
|
+
CLEAR(block);
|
|
89
|
+
CLEAR_REGS()
|
|
90
|
+
fgoto main;
|
|
91
|
+
};
|
|
92
|
+
bb_quote_tag_start {
|
|
93
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), rb_funcall(block,rb_intern("strip"),0));
|
|
94
|
+
rb_str_append(html, rb_funcall(self, rb_intern("p"), 1, regs));
|
|
95
|
+
CLEAR(block);
|
|
96
|
+
CLEAR_REGS()
|
|
97
|
+
failed_start_point_p = p; failed_start_point_ts = ts; failed_start_point_te = te;
|
|
98
|
+
fgoto bb_quote_tag;
|
|
99
|
+
};
|
|
100
|
+
automatic_url { UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) };
|
|
101
|
+
bbcode_tag => {
|
|
102
|
+
fhold;
|
|
103
|
+
fcall bbcode_inline;
|
|
104
|
+
};
|
|
105
|
+
double_return {
|
|
106
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("text")), rb_funcall(block,rb_intern("strip"),0));
|
|
107
|
+
rb_str_append(html, rb_funcall(self, rb_intern("p"), 1, regs));
|
|
108
|
+
CLEAR(block);
|
|
109
|
+
CLEAR_REGS()
|
|
110
|
+
fgoto main;
|
|
111
|
+
};
|
|
112
|
+
default => esc;
|
|
113
|
+
*|;
|
|
114
|
+
|
|
115
|
+
main := |*
|
|
116
|
+
#bbcode_tag => {
|
|
117
|
+
# fhold;
|
|
118
|
+
# fcall bbcode_inline;
|
|
119
|
+
#};
|
|
120
|
+
bb_pre_tag_start => { rb_str_append(failed_start,rb_str_new(ts,te-ts)); failed_start_point_p = p; failed_start_point_ts = ts; failed_start_point_te = te; fgoto bb_pre_tag; };
|
|
121
|
+
bb_quote_tag_start => { rb_str_append(failed_start,rb_str_new(ts,te-ts)); failed_start_point_p = p; failed_start_point_ts = ts; failed_start_point_te = te; store_cite = 0; fgoto bb_quote_tag; };
|
|
122
|
+
bb_spoiler_tag_start => { rb_str_append(failed_start,rb_str_new(ts,te-ts)); failed_start_point_p = p; failed_start_point_ts = ts; failed_start_point_te = te; store_title = 0; fgoto bb_spoiler_tag; };
|
|
123
|
+
blank_line => cat;
|
|
124
|
+
default => { fhold; fgoto block; };
|
|
125
|
+
*|;
|
|
126
|
+
|
|
127
|
+
}%%;
|
|
@@ -1722,35 +1722,35 @@ _eof_trans:
|
|
|
1722
1722
|
break;
|
|
1723
1723
|
case 23:
|
|
1724
1724
|
#line 60 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1725
|
-
{te = p+1;{ PASS(block, "text", "strong"); }}
|
|
1725
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,strong,PASS(block, "text", "strong");) }}
|
|
1726
1726
|
break;
|
|
1727
1727
|
case 24:
|
|
1728
1728
|
#line 61 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1729
|
-
{te = p+1;{ PASS(block, "text", "em"); }}
|
|
1729
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,em,PASS(block, "text", "em");) }}
|
|
1730
1730
|
break;
|
|
1731
1731
|
case 25:
|
|
1732
1732
|
#line 62 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1733
|
-
{te = p+1;{ PASS(block, "text", "ins"); }}
|
|
1733
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) }}
|
|
1734
1734
|
break;
|
|
1735
1735
|
case 26:
|
|
1736
1736
|
#line 63 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1737
|
-
{te = p+1;{ PASS(block, "text", "del"); }}
|
|
1737
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,s,PASS(block, "text", "del");) }}
|
|
1738
1738
|
break;
|
|
1739
1739
|
case 27:
|
|
1740
1740
|
#line 64 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1741
|
-
{te = p+1;{ PASS(block, "text", "del"); }}
|
|
1741
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,del,PASS(block, "text", "del");) }}
|
|
1742
1742
|
break;
|
|
1743
1743
|
case 28:
|
|
1744
1744
|
#line 65 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1745
|
-
{te = p+1;{ PASS(block, "text", "ins"); }}
|
|
1745
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) }}
|
|
1746
1746
|
break;
|
|
1747
1747
|
case 29:
|
|
1748
1748
|
#line 66 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1749
|
-
{te = p+1;{ PASS(block, "text", "sub"); }}
|
|
1749
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,sub,PASS(block, "text", "sub");) }}
|
|
1750
1750
|
break;
|
|
1751
1751
|
case 30:
|
|
1752
1752
|
#line 67 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1753
|
-
{te = p+1;{ PASS(block, "text", "sup"); }}
|
|
1753
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,sup,PASS(block, "text", "sup");) }}
|
|
1754
1754
|
break;
|
|
1755
1755
|
case 31:
|
|
1756
1756
|
#line 8 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
@@ -1758,27 +1758,27 @@ _eof_trans:
|
|
|
1758
1758
|
break;
|
|
1759
1759
|
case 32:
|
|
1760
1760
|
#line 69 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1761
|
-
{te = p+1;{ PASS(block, "text", "color"); }}
|
|
1761
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,color,PASS(block, "text", "color");) }}
|
|
1762
1762
|
break;
|
|
1763
1763
|
case 33:
|
|
1764
1764
|
#line 70 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1765
|
-
{te = p+1;{ PASS(block, "text", "bbsize"); }}
|
|
1765
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,size,PASS(block, "text", "bbsize");) }}
|
|
1766
1766
|
break;
|
|
1767
1767
|
case 34:
|
|
1768
1768
|
#line 71 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1769
|
-
{te = p+1;{ PASS(block, "text", "bbalign"); }}
|
|
1769
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,align,PASS(block, "text", "bbalign");) }}
|
|
1770
1770
|
break;
|
|
1771
1771
|
case 35:
|
|
1772
1772
|
#line 72 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1773
|
-
{te = p+1;{ PASS(block, "text", "acronym"); }}
|
|
1773
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,acronym,PASS(block, "text", "acronym");) }}
|
|
1774
1774
|
break;
|
|
1775
1775
|
case 36:
|
|
1776
1776
|
#line 73 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1777
|
-
{te = p+1;{ PASS(block, "name", "link"); }}
|
|
1777
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) }}
|
|
1778
1778
|
break;
|
|
1779
1779
|
case 37:
|
|
1780
1780
|
#line 74 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|
|
1781
|
-
{te = p+1;{ PASS(block, "name", "link"); }}
|
|
1781
|
+
{te = p+1;{ UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) }}
|
|
1782
1782
|
break;
|
|
1783
1783
|
case 38:
|
|
1784
1784
|
#line 75 "ext/redcloth_scan/redcloth_bbcode_inline.c.rl"
|