BBRedCloth 0.8.8 → 0.9.0.alpha1
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 +8 -8
- data/CHANGELOG +160 -3
- data/Manifest +0 -18
- data/README.textile +17 -2
- data/Rakefile +14 -12
- data/ext/redcloth_scan/redcloth.h +42 -16
- data/ext/redcloth_scan/redcloth_attributes.c +373 -379
- data/ext/redcloth_scan/redcloth_bbcode.c +57 -56
- data/ext/redcloth_scan/redcloth_bbcode_inline.c +22 -21
- data/ext/redcloth_scan/redcloth_inline.c +7488 -9996
- data/ext/redcloth_scan/redcloth_scan.c +22693 -8756
- data/lib/redcloth.rb +7 -0
- data/lib/redcloth/formatters/base.rb +26 -20
- data/lib/redcloth/formatters/html.rb +39 -96
- data/lib/redcloth/formatters/latex.rb +11 -11
- data/lib/redcloth/textile_doc.rb +0 -5
- data/lib/redcloth/version.rb +4 -4
- data/test/basic.yml +118 -13
- data/test/code.yml +15 -7
- data/test/html.yml +38 -1
- data/test/images.yml +51 -0
- data/test/links.yml +35 -1
- data/test/lists.yml +180 -1
- data/test/table.yml +86 -0
- data/test/test_restrictions.rb +0 -4
- data/test/textism.yml +2 -16
- data/test/threshold.yml +4 -19
- metadata +14 -31
- data/ext/mingw-rbconfig.rb +0 -176
- data/ext/redcloth_scan/redcloth_attributes.c.rl +0 -56
- data/ext/redcloth_scan/redcloth_attributes.java.rl +0 -96
- data/ext/redcloth_scan/redcloth_attributes.rl +0 -33
- data/ext/redcloth_scan/redcloth_bbcode.c.rl +0 -60
- data/ext/redcloth_scan/redcloth_bbcode.rl +0 -127
- data/ext/redcloth_scan/redcloth_bbcode_inline.c.rl +0 -72
- data/ext/redcloth_scan/redcloth_bbcode_inline.rl +0 -85
- data/ext/redcloth_scan/redcloth_common.c.rl +0 -19
- data/ext/redcloth_scan/redcloth_common.java.rl +0 -18
- data/ext/redcloth_scan/redcloth_common.rl +0 -111
- data/ext/redcloth_scan/redcloth_inline.c.rl +0 -205
- data/ext/redcloth_scan/redcloth_inline.java.rl +0 -108
- data/ext/redcloth_scan/redcloth_inline.rl +0 -176
- data/ext/redcloth_scan/redcloth_scan.c.rl +0 -236
- data/ext/redcloth_scan/redcloth_scan.java.rl +0 -555
- data/ext/redcloth_scan/redcloth_scan.rl +0 -426
- data/extras/ragel_profiler.rb +0 -73
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}%%;
|
|
@@ -1,60 +0,0 @@
|
|
|
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 = 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 = STR_NEW2("");
|
|
35
|
-
VALUE failed_start = 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
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
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 = 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 = 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 = 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,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,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,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
|
-
}%%;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* redcloth_bbcode_inline.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_inline;
|
|
12
|
-
include redcloth_common "redcloth_common.c.rl";
|
|
13
|
-
include redcloth_bbcode_inline "redcloth_bbcode_inline.rl";
|
|
14
|
-
|
|
15
|
-
bbcode_tag = "[";
|
|
16
|
-
|
|
17
|
-
dim_digit = [0-9.]+ ;
|
|
18
|
-
prime = ("'" | '"')?;
|
|
19
|
-
dim_noactions = dim_digit prime (("x" | " x ") dim_digit prime) %T (("x" | " x ") dim_digit prime)? ;
|
|
20
|
-
|
|
21
|
-
other_phrase = phrase -- dim_noactions;
|
|
22
|
-
|
|
23
|
-
main := |*
|
|
24
|
-
bbcode_tag => {
|
|
25
|
-
fhold;
|
|
26
|
-
fcall bbcode_inline;
|
|
27
|
-
};
|
|
28
|
-
other_phrase => esc;
|
|
29
|
-
PUNCT => esc;
|
|
30
|
-
space => esc;
|
|
31
|
-
|
|
32
|
-
EOF;
|
|
33
|
-
*|;
|
|
34
|
-
|
|
35
|
-
}%%
|
|
36
|
-
|
|
37
|
-
%% write data nofinal;
|
|
38
|
-
|
|
39
|
-
VALUE
|
|
40
|
-
redcloth_bbcode_inline(self, p, pe, refs)
|
|
41
|
-
VALUE self;
|
|
42
|
-
char *p, *pe;
|
|
43
|
-
VALUE refs;
|
|
44
|
-
{
|
|
45
|
-
int cs, act, nest;
|
|
46
|
-
char *ts = NULL, *te = NULL, *reg = NULL, *bck = NULL, *eof = NULL;
|
|
47
|
-
char *orig_p = p, *orig_pe = pe;
|
|
48
|
-
VALUE block = STR_NEW2("");
|
|
49
|
-
VALUE regs = Qnil; CLEAR_REGS()
|
|
50
|
-
unsigned int opts = 0;
|
|
51
|
-
VALUE buf = Qnil;
|
|
52
|
-
VALUE hash = Qnil;
|
|
53
|
-
|
|
54
|
-
VALUE html = STR_NEW2("");
|
|
55
|
-
VALUE failed_start = STR_NEW2("");
|
|
56
|
-
char *failed_start_point_p = NULL, *failed_start_point_ts = NULL, *failed_start_point_te = NULL;
|
|
57
|
-
int stack[CALL_STACK_SIZE],top,nested_quote = 0, nested_spoiler = 0, store_cite = 1, store_title = 1;
|
|
58
|
-
|
|
59
|
-
%% write init;
|
|
60
|
-
|
|
61
|
-
%% write exec;
|
|
62
|
-
|
|
63
|
-
return block;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
VALUE
|
|
67
|
-
redcloth_bbcode_inline2(self, str, refs)
|
|
68
|
-
VALUE self, str, refs;
|
|
69
|
-
{
|
|
70
|
-
StringValue(str);
|
|
71
|
-
return redcloth_bbcode_inline(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, refs);
|
|
72
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* redcloth_bbcode_inline.rl
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2009 Ryan Alyea
|
|
5
|
-
*/
|
|
6
|
-
%%{
|
|
7
|
-
|
|
8
|
-
machine redcloth_bbcode_inline;
|
|
9
|
-
|
|
10
|
-
bbchars = (default - space - "]" - "[")+ ;
|
|
11
|
-
bbmtext = ( bbchars (mspace bbchars)* ) ;
|
|
12
|
-
mtext_spaced = ( mspace* chars (mspace chars)* mspace* ) ;
|
|
13
|
-
bb_uri = (uri -- '[' -- ']') ;
|
|
14
|
-
|
|
15
|
-
bb_b = "[b]" >X mtext_spaced >A %T :>> "[/b]" ;
|
|
16
|
-
bb_i = "[i]" >X mtext_spaced >A %T :>> "[/i]" ;
|
|
17
|
-
bb_u = "[u]" >X mtext_spaced >A %T :>> "[/u]" ;
|
|
18
|
-
bb_s = "[s]" >X mtext_spaced >A %T :>> "[/s]" ;
|
|
19
|
-
bb_del = "[del]" >X mtext_spaced >A %T :>> "[/del]" ;
|
|
20
|
-
bb_ins = "[ins]" >X mtext_spaced >A %T :>> "[/ins]" ;
|
|
21
|
-
bb_sub = "[sub]" >X mtext_spaced >A %T :>> "[/sub]" ;
|
|
22
|
-
bb_sup = "[sup]" >X mtext_spaced >A %T :>> "[/sup]" ;
|
|
23
|
-
bb_notextile = "[notextile]" >X mtext_spaced >A %T :>> "[/notextile]" ;
|
|
24
|
-
bb_innercolor = ("#"[0-9a-fA-F]{3}|"#"[0-9a-fA-F]{6}|"aqua"|"black"|"blue"|"fuchsia"|"gray"|"green"|"lime"|"maroon"|"navy"|"olive"|"purple"|"red"|"silver"|"teal"|"white"|"yellow"|"orange"|"cyan"|"magenta"|"grey") %{ STORE("color"); };
|
|
25
|
-
bb_color = ("[color=" >X bb_innercolor >A "]" mtext_spaced >A %T :>> "[/color]") ;
|
|
26
|
-
bb_innersize = space* ( (digit? "."? digit{1,2} ("em"|"pt"|"px"|"%")? )|("xx-small"|"x-small"|"small"|"medium"|"large"|"x-large"|"xx-large"|"smaller"|"larger")) %{ STORE("size"); } space* ;
|
|
27
|
-
bb_size = ("[size=" >X bb_innersize >A "]" mtext_spaced >A %T :>> "[/size]") ;
|
|
28
|
-
bb_inneralign = space* ("left"|"center"|"right") %{ STORE("bbalign"); } space* ;
|
|
29
|
-
bb_align = ("[align=" >X bb_inneralign >A "]" mtext_spaced >A %T :>> "[/align]") ;
|
|
30
|
-
bb_acronym = ("[acronym=" >X bbmtext %{ STORE("title"); } >A "]" mtext_spaced >A %T :>> "[/acronym]") ;
|
|
31
|
-
|
|
32
|
-
bb_link = "[url]" >X bb_uri %{ STORE("href"); } >A :>> "[/url]" ;
|
|
33
|
-
bb_link2 = "[url=">X bb_uri %{ STORE("href"); } >A "]" mtext_spaced %{ STORE("name"); } >A :>> "[/url]" ;
|
|
34
|
-
|
|
35
|
-
bb_img = "[img]" >X bb_uri %{ STORE("src"); } >A :>> "[/img]" ;
|
|
36
|
-
bb_img2 = "[img=">X bb_uri %{ STORE("src"); } >A "]" mtext_spaced{0,1} %{ STORE("title"); } >A :>> "[/img]" ;
|
|
37
|
-
|
|
38
|
-
bb_pre_tag_start = "[pre" [^\]]* "]" (space* "[code]")? ;
|
|
39
|
-
bb_pre_tag_end = ("[/code]" space*)? "[/pre]" LF? ;
|
|
40
|
-
|
|
41
|
-
bb_spoiler_title = " title"? "=" bbmtext %{ STORE("title"); } >A;
|
|
42
|
-
bb_spoiler = "[spoiler" >X bb_spoiler_title? "]" mtext >A %T :>> "[/spoiler]" ;
|
|
43
|
-
|
|
44
|
-
nl = "\n";
|
|
45
|
-
|
|
46
|
-
action bb_cat2html { CAT(html); }
|
|
47
|
-
action bb_failed4html { rb_str_append(block,failed_start); rb_str_append(block,rb_funcall(self, rb_intern("escape"), 1, html)); fgoto bbcode_inline; }
|
|
48
|
-
|
|
49
|
-
bb_inline_pre_tag := |*
|
|
50
|
-
bb_pre_tag_end {
|
|
51
|
-
rb_hash_aset(regs, ID2SYM(rb_intern("text")), rb_funcall(self, rb_intern("escape_pre"), 1, html));
|
|
52
|
-
rb_str_append(block,rb_funcall(self, rb_intern("bb_pre"), 1, regs));
|
|
53
|
-
BBDONE();
|
|
54
|
-
fgoto bbcode_inline;
|
|
55
|
-
};
|
|
56
|
-
default => bb_cat2html;
|
|
57
|
-
EOF => bb_failed4html;
|
|
58
|
-
*|;
|
|
59
|
-
|
|
60
|
-
bbcode_inline := |*
|
|
61
|
-
bb_b { UNLESS_DISABLED_INLINE(block,strong,PASS(block, "text", "strong");) };
|
|
62
|
-
bb_i { UNLESS_DISABLED_INLINE(block,em,PASS(block, "text", "em");) };
|
|
63
|
-
bb_u { UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) };
|
|
64
|
-
bb_s { UNLESS_DISABLED_INLINE(block,s,PASS(block, "text", "del");) };
|
|
65
|
-
bb_del { UNLESS_DISABLED_INLINE(block,del,PASS(block, "text", "del");) };
|
|
66
|
-
bb_ins { UNLESS_DISABLED_INLINE(block,ins,PASS(block, "text", "ins");) };
|
|
67
|
-
bb_sub { UNLESS_DISABLED_INLINE(block,sub,PASS(block, "text", "sub");) };
|
|
68
|
-
bb_sup { UNLESS_DISABLED_INLINE(block,sup,PASS(block, "text", "sup");) };
|
|
69
|
-
bb_notextile => ignore;
|
|
70
|
-
bb_color { UNLESS_DISABLED_INLINE(block,color,PASS(block, "text", "color");) };
|
|
71
|
-
bb_size { UNLESS_DISABLED_INLINE(block,size,PASS(block, "text", "bbsize");) };
|
|
72
|
-
bb_align { UNLESS_DISABLED_INLINE(block,align,PASS(block, "text", "bbalign");) };
|
|
73
|
-
bb_acronym { UNLESS_DISABLED_INLINE(block,acronym,PASS(block, "text", "acronym");) };
|
|
74
|
-
bb_link { UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) };
|
|
75
|
-
bb_link2 { UNLESS_DISABLED_INLINE(block,link,PASS(block, "name", "link");) };
|
|
76
|
-
bb_img { UNLESS_DISABLED_INLINE(block,image,PASS(block, "name", "image");); };
|
|
77
|
-
bb_img2 { UNLESS_DISABLED_INLINE(block,image,PASS(block, "name", "image");); };
|
|
78
|
-
bb_spoiler { PASS(block, "name", "bb_spoiler"); CLEAR_REGS();};
|
|
79
|
-
|
|
80
|
-
bb_pre_tag_start { ASET("type", "notextile"); rb_str_append(failed_start,STR_NEW(ts,te-ts)); fgoto bb_inline_pre_tag; };
|
|
81
|
-
nl => { fhold; fret; };
|
|
82
|
-
default => { CAT(block); fret;};
|
|
83
|
-
*|;
|
|
84
|
-
|
|
85
|
-
}%%;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
%%{
|
|
2
|
-
|
|
3
|
-
machine redcloth_common;
|
|
4
|
-
include redcloth_common "redcloth_common.rl";
|
|
5
|
-
|
|
6
|
-
action esc { rb_str_cat_escaped(self, block, ts, te); }
|
|
7
|
-
action esc_pre { rb_str_cat_escaped_for_preformatted(self, block, ts, te); }
|
|
8
|
-
action ignore { rb_str_append(block, rb_funcall(self, rb_intern("ignore"), 1, regs)); }
|
|
9
|
-
action esc_test {rb_str_cat_escaped_test(self, block, ts, te);}
|
|
10
|
-
|
|
11
|
-
# conditionals
|
|
12
|
-
action starts_line {
|
|
13
|
-
p == orig_p || *(p-1) == '\r' || *(p-1) == '\n' || *(p-1) == '\f'
|
|
14
|
-
}
|
|
15
|
-
action starts_phrase {
|
|
16
|
-
p == orig_p || *(p-1) == '\r' || *(p-1) == '\n' || *(p-1) == '\f' || *(p-1) == ' '
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}%%;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
%%{
|
|
2
|
-
|
|
3
|
-
machine redcloth_common;
|
|
4
|
-
include redcloth_common "redcloth_common.rl";
|
|
5
|
-
|
|
6
|
-
action esc { strCatEscaped(self, block, data, ts, te); }
|
|
7
|
-
action esc_pre { strCatEscapedForPreformatted(self, block, data, ts, te); }
|
|
8
|
-
action ignore { ((RubyString)block).append(self.callMethod(runtime.getCurrentContext(), "ignore", regs)); }
|
|
9
|
-
|
|
10
|
-
# conditionals
|
|
11
|
-
action starts_line {
|
|
12
|
-
p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f'
|
|
13
|
-
}
|
|
14
|
-
action starts_phrase {
|
|
15
|
-
p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f' || data[(p-1)] == ' '
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}%%;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
%%{
|
|
2
|
-
|
|
3
|
-
machine redcloth_common;
|
|
4
|
-
|
|
5
|
-
action A { reg = p; }
|
|
6
|
-
action B { bck = p; }
|
|
7
|
-
action T { STORE("text"); }
|
|
8
|
-
action X { CLEAR_REGS(); RESET_REG(); }
|
|
9
|
-
action cat { CAT(block); }
|
|
10
|
-
|
|
11
|
-
# simple
|
|
12
|
-
LF = ( '\n' ) ;
|
|
13
|
-
default = ^0 ;
|
|
14
|
-
EOF = 0 ;
|
|
15
|
-
|
|
16
|
-
# textile modifiers
|
|
17
|
-
A_LEFT = "<" %{ UNLESS_DISABLED_ATTRIBUTE(align,ASET("align", "left");) } ;
|
|
18
|
-
A_RIGHT = ">" %{ UNLESS_DISABLED_ATTRIBUTE(align,ASET("align", "right");) } ;
|
|
19
|
-
A_JUSTIFIED = "<>" %{ UNLESS_DISABLED_ATTRIBUTE(align,ASET("align", "justify");) } ;
|
|
20
|
-
A_CENTER = "=" %{ UNLESS_DISABLED_ATTRIBUTE(align,ASET("align", "center");) } ;
|
|
21
|
-
A_PADLEFT = "(" >A %{ AINC("padding-left"); } ;
|
|
22
|
-
A_PADRIGHT = ")" >A %{ AINC("padding-right"); } ;
|
|
23
|
-
A_HLGN = ( A_LEFT | A_RIGHT | A_JUSTIFIED | A_CENTER | A_PADLEFT | A_PADRIGHT ) ;
|
|
24
|
-
A_LIMIT = ( A_LEFT | A_CENTER | A_RIGHT ) ;
|
|
25
|
-
A_VLGN = ( "-" %{ ASET("vertical-align", "middle"); } | "^" %{ ASET("vertical-align", "top"); } | "~" %{ ASET("vertical-align", "bottom"); } ) ;
|
|
26
|
-
C_CLAS = ( "(" ( [^)#]+ >A %{ STORE("class"); } )? ("#" [^)]+ >A %{STORE("id");} )? ")" ) ;
|
|
27
|
-
C_LNGE = ( "[" [^\]]+ >A %{ STORE("lang"); } "]" ) ;
|
|
28
|
-
C_STYL = ( "{" [^}]+ >A %{ STORE("style"); } "}" ) ;
|
|
29
|
-
S_CSPN = ( "\\" [0-9]+ >A %{ STORE("colspan"); } ) ;
|
|
30
|
-
S_RSPN = ( "/" [0-9]+ >A %{ STORE("rowspan"); } ) ;
|
|
31
|
-
D_HEADER = "_" %{ ASET("th", "true"); } ;
|
|
32
|
-
A = ( ( A_HLGN | A_VLGN )* ) ;
|
|
33
|
-
A2 = ( A_LIMIT? ) ;
|
|
34
|
-
S = ( S_CSPN | S_RSPN )* ;
|
|
35
|
-
C = ( C_CLAS | C_STYL | C_LNGE )* ;
|
|
36
|
-
D = ( D_HEADER ) ;
|
|
37
|
-
N_CONT = "_" %{ list_continue = 1; };
|
|
38
|
-
N_NUM = digit+ >A %{ STORE("start"); };
|
|
39
|
-
N = ( N_CONT | N_NUM )? ;
|
|
40
|
-
PUNCT = ( "!" | '"' | "#" | "$" | "%" | "&" | "'" | "," | "-" | "." | "/" | ":" | ";" | "=" | "?" | "\\" | "^" | "`" | "|" | "~" | "[" | "]" | "(" | ")" | "<" ) ;
|
|
41
|
-
dotspace = ("." " "*) ;
|
|
42
|
-
indent = [ \t]* ;
|
|
43
|
-
|
|
44
|
-
# very un-DRY; Adrian says an action-stripping macro will come in a future Ragel version
|
|
45
|
-
A_LEFT_noactions = "<" ;
|
|
46
|
-
A_RIGHT_noactions = ">" ;
|
|
47
|
-
A_JUSTIFIED_noactions = "<>" ;
|
|
48
|
-
A_CENTER_noactions = "=" ;
|
|
49
|
-
A_PADLEFT_noactions = "(" ;
|
|
50
|
-
A_PADRIGHT_noactions = ")" ;
|
|
51
|
-
A_HLGN_noactions = ( A_LEFT_noactions | A_RIGHT_noactions | A_JUSTIFIED_noactions | A_CENTER_noactions | A_PADLEFT_noactions | A_PADRIGHT_noactions ) ;
|
|
52
|
-
A_VLGN_noactions = ( "-" | "^" | "~" ) ;
|
|
53
|
-
C_CLAS_noactions = ( "(" ( [^)#]+ )? ("#" [^)]+ )? ")" ) ;
|
|
54
|
-
C_LNGE_noactions = ( "[" [^\]]+ "]" ) ;
|
|
55
|
-
C_STYL_noactions = ( "{" [^}]+ "}" ) ;
|
|
56
|
-
A_noactions = ( ( A_HLGN_noactions | A_VLGN_noactions )* ) ;
|
|
57
|
-
C_noactions = ( C_CLAS_noactions | C_STYL_noactions | C_LNGE_noactions )* ;
|
|
58
|
-
C_noquotes_noactions = C_noactions -- '"' ;
|
|
59
|
-
|
|
60
|
-
# text blocks
|
|
61
|
-
trailing = PUNCT - ("'" | '"') ;
|
|
62
|
-
chars = (default - space)+ ;
|
|
63
|
-
phrase = chars -- trailing ;
|
|
64
|
-
|
|
65
|
-
# html tags (from Hpricot)
|
|
66
|
-
NameChar = [\-A-Za-z0-9._:?] ;
|
|
67
|
-
Name = [A-Za-z_:] NameChar* ;
|
|
68
|
-
NameAttr = NameChar+ ;
|
|
69
|
-
Q1Attr = [^']* ;
|
|
70
|
-
Q2Attr = [^"]* ;
|
|
71
|
-
UnqAttr = ( space | [^ \t\r\n<>"'] [^ \t\r\n<>]* ) ;
|
|
72
|
-
Nmtoken = NameChar+ ;
|
|
73
|
-
Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'" | UnqAttr space+ ) space* ;
|
|
74
|
-
AttrEnd = ( NameAttr space* "=" space* UnqAttr? | Nmtoken ) ;
|
|
75
|
-
AttrSet = ( Attr | Nmtoken space+ ) ;
|
|
76
|
-
|
|
77
|
-
script_tag_start = ( "<script" [^>]* ">" ) >X >A %T ;
|
|
78
|
-
script_tag_end = ( "</script>" >A %T LF? ) >X ;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# URI tokens (lifted from Mongrel)
|
|
82
|
-
CTL = (cntrl | 127);
|
|
83
|
-
safe = ("$" | "-" | "_" | ".");
|
|
84
|
-
extra = ("!" | "*" | "'" | "(" | ")" | "," | "#");
|
|
85
|
-
reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
|
|
86
|
-
unsafe = (CTL | " " | "\"" | "%" | "<" | ">");
|
|
87
|
-
national = any -- (alpha | digit | reserved | extra | safe | unsafe);
|
|
88
|
-
unreserved = (alpha | digit | safe | extra | national);
|
|
89
|
-
escape = ("%" xdigit xdigit);
|
|
90
|
-
uchar = (unreserved | escape);
|
|
91
|
-
pchar = (uchar | ":" | "@" | "&" | "=" | "+");
|
|
92
|
-
scheme = ( alpha | digit | "+" | "-" | "." )+ ;
|
|
93
|
-
absolute_uri = (scheme ":" (uchar | reserved )*);
|
|
94
|
-
safepath = (pchar* (alpha | digit | safe) pchar*) ;
|
|
95
|
-
path = (safepath ( "/" pchar* )*) ;
|
|
96
|
-
query = ( uchar | reserved )* ;
|
|
97
|
-
param = ( pchar | "/" )* ;
|
|
98
|
-
params = (param ( ";" param )*) ;
|
|
99
|
-
rel_path = (path (";" params)?) ("?" query)?;
|
|
100
|
-
absolute_path = ("/"+ rel_path?);
|
|
101
|
-
target = ("#" pchar*) ;
|
|
102
|
-
uri = (target | absolute_uri | absolute_path | rel_path) ;
|
|
103
|
-
|
|
104
|
-
# common
|
|
105
|
-
title = ( '(' default+ >A %{ STORE("title"); } :> ')' ) ;
|
|
106
|
-
word = ( alnum | safe | " " ) ;
|
|
107
|
-
mspace = ( ( " " | "\t" | LF )+ ) -- LF{2} ;
|
|
108
|
-
mtext = ( chars (mspace chars)* ) ;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}%%;
|