RedCloth 4.0.4-x86-mswin32-60 → 4.1.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of RedCloth might be problematic. Click here for more details.

@@ -0,0 +1,159 @@
1
+ /*
2
+ * redcloth_inline.c.rl
3
+ *
4
+ * Copyright (C) 2008 Jason Garber
5
+ */
6
+ #include <ruby.h>
7
+ #include "redcloth.h"
8
+
9
+ %%{
10
+
11
+ machine redcloth_inline;
12
+ include redcloth_common "redcloth_common.c.rl";
13
+ include redcloth_inline "redcloth_inline.rl";
14
+
15
+ }%%
16
+
17
+ %% write data nofinal;
18
+
19
+ VALUE
20
+ red_pass(VALUE self, VALUE regs, VALUE ref, ID meth, VALUE refs)
21
+ {
22
+ VALUE txt = rb_hash_aref(regs, ref);
23
+ if (!NIL_P(txt)) rb_hash_aset(regs, ref, redcloth_inline2(self, txt, refs));
24
+ return rb_funcall(self, meth, 1, regs);
25
+ }
26
+
27
+ VALUE
28
+ red_parse_attr(VALUE self, VALUE regs, VALUE ref)
29
+ {
30
+ VALUE txt = rb_hash_aref(regs, ref);
31
+ VALUE new_regs = redcloth_attributes(self, txt);
32
+ return rb_funcall(regs, rb_intern("update"), 1, new_regs);
33
+ }
34
+
35
+ VALUE
36
+ red_parse_link_attr(VALUE self, VALUE regs, VALUE ref)
37
+ {
38
+ VALUE txt = rb_hash_aref(regs, ref);
39
+ VALUE new_regs = redcloth_link_attributes(self, txt);
40
+ return rb_funcall(regs, rb_intern("update"), 1, new_regs);
41
+ }
42
+
43
+ VALUE
44
+ red_pass_code(VALUE self, VALUE regs, VALUE ref, ID meth)
45
+ {
46
+ VALUE txt = rb_hash_aref(regs, ref);
47
+ if (!NIL_P(txt)) {
48
+ VALUE txt2 = rb_str_new2("");
49
+ rb_str_cat_escaped_for_preformatted(self, txt2, RSTRING_PTR(txt), RSTRING_PTR(txt) + RSTRING_LEN(txt));
50
+ rb_hash_aset(regs, ref, txt2);
51
+ }
52
+ return rb_funcall(self, meth, 1, regs);
53
+ }
54
+
55
+ VALUE
56
+ red_block(VALUE self, VALUE regs, VALUE block, VALUE refs)
57
+ {
58
+ ID method;
59
+ VALUE fallback;
60
+ VALUE sym_text = ID2SYM(rb_intern("text"));
61
+ VALUE btype = rb_hash_aref(regs, ID2SYM(rb_intern("type")));
62
+ block = rb_funcall(block, rb_intern("strip"), 0);
63
+ if ((!NIL_P(block)) && !NIL_P(btype))
64
+ {
65
+ method = rb_intern(RSTRING_PTR(btype));
66
+ if (method == rb_intern("notextile")) {
67
+ rb_hash_aset(regs, sym_text, block);
68
+ } else {
69
+ rb_hash_aset(regs, sym_text, redcloth_inline2(self, block, refs));
70
+ }
71
+ if (rb_respond_to(self, method)) {
72
+ block = rb_funcall(self, method, 1, regs);
73
+ } else {
74
+ fallback = rb_hash_aref(regs, ID2SYM(rb_intern("fallback")));
75
+ if (!NIL_P(fallback)) {
76
+ rb_str_append(fallback, rb_hash_aref(regs, sym_text));
77
+ CLEAR_REGS();
78
+ rb_hash_aset(regs, sym_text, fallback);
79
+ }
80
+ block = rb_funcall(self, rb_intern("p"), 1, regs);
81
+ }
82
+ }
83
+ return block;
84
+ }
85
+
86
+ VALUE
87
+ red_blockcode(VALUE self, VALUE regs, VALUE block)
88
+ {
89
+ VALUE btype = rb_hash_aref(regs, ID2SYM(rb_intern("type")));
90
+ if (RSTRING_LEN(block) > 0)
91
+ {
92
+ rb_hash_aset(regs, ID2SYM(rb_intern("text")), block);
93
+ block = rb_funcall(self, rb_intern(RSTRING_PTR(btype)), 1, regs);
94
+ }
95
+ return block;
96
+ }
97
+
98
+ void
99
+ red_inc(VALUE regs, VALUE ref)
100
+ {
101
+ int aint = 0;
102
+ VALUE aval = rb_hash_aref(regs, ref);
103
+ if (aval != Qnil) aint = NUM2INT(aval);
104
+ rb_hash_aset(regs, ref, INT2NUM(aint + 1));
105
+ }
106
+
107
+ VALUE
108
+ redcloth_inline(self, p, pe, refs)
109
+ VALUE self;
110
+ char *p, *pe;
111
+ VALUE refs;
112
+ {
113
+ int cs, act;
114
+ char *ts, *te, *reg, *eof;
115
+ char *orig_p = p, *orig_pe = pe;
116
+ VALUE block = rb_str_new2("");
117
+ VALUE regs = Qnil;
118
+ unsigned int opts = 0;
119
+ VALUE buf = Qnil;
120
+
121
+ %% write init;
122
+
123
+ %% write exec;
124
+
125
+ return block;
126
+ }
127
+
128
+ /** Append characters to a string, escaping (&, <, >, ", ') using the formatter's escape method.
129
+ * @param str ruby string
130
+ * @param ts start of character buffer to append
131
+ * @param te end of character buffer
132
+ */
133
+ void
134
+ rb_str_cat_escaped(self, str, ts, te)
135
+ VALUE self, str;
136
+ char *ts, *te;
137
+ {
138
+ VALUE source_str = rb_str_new(ts, te-ts);
139
+ VALUE escaped_str = rb_funcall(self, rb_intern("escape"), 1, source_str);
140
+ rb_str_concat(str, escaped_str);
141
+ }
142
+
143
+ void
144
+ rb_str_cat_escaped_for_preformatted(self, str, ts, te)
145
+ VALUE self, str;
146
+ char *ts, *te;
147
+ {
148
+ VALUE source_str = rb_str_new(ts, te-ts);
149
+ VALUE escaped_str = rb_funcall(self, rb_intern("escape_pre"), 1, source_str);
150
+ rb_str_concat(str, escaped_str);
151
+ }
152
+
153
+ VALUE
154
+ redcloth_inline2(self, str, refs)
155
+ VALUE self, str, refs;
156
+ {
157
+ StringValue(str);
158
+ return redcloth_inline(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, refs);
159
+ }
@@ -0,0 +1,108 @@
1
+ /*
2
+ * redcloth_inline.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 RedclothInline extends RedclothScanService.Base {
27
+
28
+ %%{
29
+
30
+ machine redcloth_inline;
31
+ include redcloth_common "redcloth_common.java.rl";
32
+ include redcloth_inline "redcloth_inline.rl";
33
+
34
+ }%%
35
+
36
+ %% write data nofinal;
37
+
38
+ public IRubyObject red_pass_code(IRubyObject self, IRubyObject regs, IRubyObject ref, String meth) {
39
+ IRubyObject txt = ((RubyHash)regs).aref(ref);
40
+ if(!txt.isNil()) {
41
+ IRubyObject txt2 = RubyString.newEmptyString(runtime);
42
+ strCatEscapedForPreformatted(self, txt2, ((RubyString)txt).getByteList().bytes, ((RubyString)txt).getByteList().begin, ((RubyString)txt).getByteList().begin + ((RubyString)txt).getByteList().realSize);
43
+ ((RubyHash)regs).aset(ref, txt2);
44
+ }
45
+ return self.callMethod(runtime.getCurrentContext(), meth, regs);
46
+ }
47
+
48
+ public IRubyObject red_parse_attr(IRubyObject self, IRubyObject regs, IRubyObject ref) {
49
+ IRubyObject txt = ((RubyHash)regs).aref(ref);
50
+ IRubyObject new_regs = RedclothAttributes.attributes(self, txt);
51
+ return regs.callMethod(runtime.getCurrentContext(), "update", new_regs);
52
+ }
53
+
54
+ public IRubyObject red_parse_link_attr(IRubyObject self, IRubyObject regs, IRubyObject ref) {
55
+ IRubyObject txt = ((RubyHash)regs).aref(ref);
56
+ IRubyObject new_regs = RedclothAttributes.link_attributes(self, txt);
57
+ return regs.callMethod(runtime.getCurrentContext(), "update", new_regs);
58
+ }
59
+
60
+ public void PASS_CODE(IRubyObject H, String A, String T, int O) {
61
+ ((RubyString)H).append(red_pass_code(self, regs, runtime.newSymbol(A), T));
62
+ }
63
+
64
+ public void PARSE_ATTR(String A) {
65
+ red_parse_attr(self, regs, runtime.newSymbol(A));
66
+ }
67
+
68
+ public void PARSE_LINK_ATTR(String A) {
69
+ red_parse_link_attr(self, regs, runtime.newSymbol(A));
70
+ }
71
+
72
+ private int opts;
73
+ private IRubyObject buf;
74
+
75
+ public RedclothInline(IRubyObject self, byte[] data, int p, int pe, IRubyObject refs) {
76
+ this.runtime = self.getRuntime();
77
+ this.self = self;
78
+
79
+ // This is GROSS but necessary for EOF matching
80
+ this.data = new byte[pe+1];
81
+ System.arraycopy(data, p, this.data, 0, pe);
82
+ this.data[pe] = 0;
83
+
84
+ this.p = 0;
85
+ this.pe = pe+1;
86
+ this.eof = this.pe;
87
+ this.orig_p = 0;
88
+ this.orig_pe = this.pe;
89
+ this.refs = refs;
90
+ this.block = RubyString.newEmptyString(runtime);
91
+ this.regs = runtime.getNil();
92
+ this.opts = 0;
93
+ this.buf = runtime.getNil();
94
+ }
95
+
96
+
97
+ public IRubyObject inline() {
98
+ %% write init;
99
+ %% write exec;
100
+
101
+ return block;
102
+ }
103
+
104
+ public static IRubyObject inline2(IRubyObject self, IRubyObject str, IRubyObject refs) {
105
+ ByteList bl = str.convertToString().getByteList();
106
+ return new RedclothInline(self, bl.bytes, bl.begin, bl.realSize, refs).inline();
107
+ }
108
+ }
@@ -3,28 +3,24 @@
3
3
  *
4
4
  * Copyright (C) 2008 Jason Garber
5
5
  */
6
- #include <ruby.h>
7
- #include "redcloth.h"
8
-
9
6
  %%{
10
7
 
11
8
  machine redcloth_inline;
12
- include redcloth_common "redcloth_common.rl";
13
9
 
14
10
  # links
15
11
  mtext_noquotes = mtext -- '"' ;
16
12
  quoted_mtext = '"' mtext_noquotes '"' ;
17
13
  mtext_including_quotes = (mtext_noquotes ' "' mtext_noquotes '" ' mtext_noquotes?)+ ;
18
- link_says = ( C_noactions "."* " "* ((quoted_mtext | mtext_including_quotes | mtext_noquotes) -- '":') ) >A %{ STORE(link_text); } ;
14
+ link_says = ( C_noactions "."* " "* ((quoted_mtext | mtext_including_quotes | mtext_noquotes) -- '":') ) >A %{ STORE("link_text"); } ;
19
15
  link_says_noquotes_noactions = ( C_noquotes_noactions "."* " "* ((mtext_noquotes) -- '":') ) ;
20
- link = ( '"' link_says '":' %A uri %{ STORE_URL(href); } ) >X ;
16
+ link = ( '"' link_says '":' %A uri %{ STORE_URL("href"); } ) >X ;
21
17
  link_noquotes_noactions = ( '"' link_says_noquotes_noactions '":' uri ) ;
22
- bracketed_link = ( '["' link_says '":' %A uri %{ STORE(href); } :> "]" ) >X ;
18
+ bracketed_link = ( '["' link_says '":' %A uri %{ STORE("href"); } :> "]" ) >X ;
23
19
 
24
20
  # images
25
- image_src = ( uri ) >A %{ STORE(src) } ;
21
+ image_src = ( uri ) >A %{ STORE("src"); } ;
26
22
  image_is = ( A2 C ". "? image_src :> title? ) ;
27
- image_link = ( ":" uri >A %{ STORE_URL(href); } ) ;
23
+ image_link = ( ":" uri >A %{ STORE_URL("href"); } ) ;
28
24
  image = ( "["? "!" image_is "!" %A image_link? "]"? ) >X ;
29
25
 
30
26
  # footnotes
@@ -43,7 +39,7 @@
43
39
  i = "["? "__" >X mtext >A %T :> "__" "]"? ;
44
40
  del = "[-" >X C ( mtext ) >A %T :>> "-]" ;
45
41
  emdash_parenthetical_phrase_with_spaces = " -- " mtext " -- " ;
46
- del_phrase = (( " " >A %{ STORE(beginning_space); } "-") >X C ( mtext ) >A %T :>> ( "-" end_markup_phrase )) - emdash_parenthetical_phrase_with_spaces ;
42
+ del_phrase = (( " " >A %{ STORE("beginning_space"); } "-") >X C ( mtext ) >A %T :>> ( "-" end_markup_phrase )) - emdash_parenthetical_phrase_with_spaces ;
47
43
  ins = "["? "+" >X mtext >A %T :> "+" "]"? ;
48
44
  sup = "[^" >X mtext >A %T :> "^]" ;
49
45
  sup_phrase = ( "^" when starts_phrase) >X ( mtext ) >A %T :>> ( "^" end_markup_phrase ) ;
@@ -74,7 +70,7 @@
74
70
  emdash = "--" ;
75
71
  arrow = "->" ;
76
72
  endash = " - " ;
77
- acronym = ( [A-Z] >A [A-Z0-9]{2,} %T "(" default+ >A %{ STORE(title) } :> ")" ) >X ;
73
+ acronym = ( [A-Z] >A [A-Z0-9]{2,} %T "(" default+ >A %{ STORE("title"); } :> ")" ) >X ;
78
74
  caps_noactions = upper{3,} ;
79
75
  caps = ( caps_noactions >A %*T ) >X ;
80
76
  dim_digit = [0-9.]+ ;
@@ -101,54 +97,54 @@
101
97
 
102
98
  main := |*
103
99
 
104
- image { INLINE(block, image); };
100
+ image { INLINE(block, "image"); };
105
101
 
106
- link { PARSE_LINK_ATTR(link_text); PASS(block, name, link); };
107
- bracketed_link { PARSE_LINK_ATTR(link_text); PASS(block, name, link); };
102
+ link { PARSE_LINK_ATTR("link_text"); PASS(block, "name", "link"); };
103
+ bracketed_link { PARSE_LINK_ATTR("link_text"); PASS(block, "name", "link"); };
108
104
 
109
- code { PARSE_ATTR(text); PASS_CODE(block, text, code, opts); };
105
+ code { PARSE_ATTR("text"); PASS_CODE(block, "text", "code", opts); };
110
106
  code_tag_start { CAT(block); fgoto code_tag; };
111
- notextile { INLINE(block, notextile); };
112
- strong { PARSE_ATTR(text); PASS(block, text, strong); };
113
- b { PARSE_ATTR(text); PASS(block, text, b); };
114
- em { PARSE_ATTR(text); PASS(block, text, em); };
115
- i { PARSE_ATTR(text); PASS(block, text, i); };
116
- del { PASS(block, text, del); };
117
- del_phrase { PASS(block, text, del_phrase); };
118
- ins { PARSE_ATTR(text); PASS(block, text, ins); };
119
- sup { PARSE_ATTR(text); PASS(block, text, sup); };
120
- sup_phrase { PARSE_ATTR(text); PASS(block, text, sup_phrase); };
121
- sub { PARSE_ATTR(text); PASS(block, text, sub); };
122
- sub_phrase { PARSE_ATTR(text); PASS(block, text, sub_phrase); };
123
- span { PARSE_ATTR(text); PASS(block, text, span); };
124
- span_phrase { PARSE_ATTR(text); PASS(block, text, span_phrase); };
125
- cite { PARSE_ATTR(text); PASS(block, text, cite); };
107
+ notextile { INLINE(block, "notextile"); };
108
+ strong { PARSE_ATTR("text"); PASS(block, "text", "strong"); };
109
+ b { PARSE_ATTR("text"); PASS(block, "text", "b"); };
110
+ em { PARSE_ATTR("text"); PASS(block, "text", "em"); };
111
+ i { PARSE_ATTR("text"); PASS(block, "text", "i"); };
112
+ del { PASS(block, "text", "del"); };
113
+ del_phrase { PASS(block, "text", "del_phrase"); };
114
+ ins { PARSE_ATTR("text"); PASS(block, "text", "ins"); };
115
+ sup { PARSE_ATTR("text"); PASS(block, "text", "sup"); };
116
+ sup_phrase { PARSE_ATTR("text"); PASS(block, "text", "sup_phrase"); };
117
+ sub { PARSE_ATTR("text"); PASS(block, "text", "sub"); };
118
+ sub_phrase { PARSE_ATTR("text"); PASS(block, "text", "sub_phrase"); };
119
+ span { PARSE_ATTR("text"); PASS(block, "text", "span"); };
120
+ span_phrase { PARSE_ATTR("text"); PASS(block, "text", "span_phrase"); };
121
+ cite { PARSE_ATTR("text"); PASS(block, "text", "cite"); };
126
122
  ignore => ignore;
127
- snip { PASS(block, text, snip); };
128
- quote1 { PASS(block, text, quote1); };
129
- quote2 { PASS(block, text, quote2); };
130
- multi_paragraph_quote { PASS(block, text, multi_paragraph_quote); };
123
+ snip { PASS(block, "text", "snip"); };
124
+ quote1 { PASS(block, "text", "quote1"); };
125
+ quote2 { PASS(block, "text", "quote2"); };
126
+ multi_paragraph_quote { PASS(block, "text", "multi_paragraph_quote"); };
131
127
 
132
- ellipsis { INLINE(block, ellipsis); };
133
- emdash { INLINE(block, emdash); };
134
- endash { INLINE(block, endash); };
135
- arrow { INLINE(block, arrow); };
136
- caps { INLINE(block, caps); };
137
- acronym { INLINE(block, acronym); };
138
- dim { INLINE(block, dim); };
139
- trademark { INLINE(block, trademark); };
140
- registered { INLINE(block, registered); };
141
- copyright { INLINE(block, copyright); };
142
- footno { PASS(block, text, footno); };
143
- entity { INLINE(block, entity); };
128
+ ellipsis { INLINE(block, "ellipsis"); };
129
+ emdash { INLINE(block, "emdash"); };
130
+ endash { INLINE(block, "endash"); };
131
+ arrow { INLINE(block, "arrow"); };
132
+ caps { INLINE(block, "caps"); };
133
+ acronym { INLINE(block, "acronym"); };
134
+ dim { INLINE(block, "dim"); };
135
+ trademark { INLINE(block, "trademark"); };
136
+ registered { INLINE(block, "registered"); };
137
+ copyright { INLINE(block, "copyright"); };
138
+ footno { PASS(block, "text", "footno"); };
139
+ entity { INLINE(block, "entity"); };
144
140
 
145
- script_tag { INLINE(block, inline_html); };
146
- start_tag { INLINE(block, inline_html); };
147
- end_tag { INLINE(block, inline_html); };
148
- empty_tag { INLINE(block, inline_html); };
149
- html_comment { INLINE(block, inline_html); };
141
+ script_tag { INLINE(block, "inline_html"); };
142
+ start_tag { INLINE(block, "inline_html"); };
143
+ end_tag { INLINE(block, "inline_html"); };
144
+ empty_tag { INLINE(block, "inline_html"); };
145
+ html_comment { INLINE(block, "inline_html"); };
150
146
 
151
- redcloth_version { INLINE(block, inline_redcloth_version); };
147
+ redcloth_version { INLINE(block, "inline_redcloth_version"); };
152
148
 
153
149
  other_phrase => esc;
154
150
  PUNCT => esc;
@@ -158,149 +154,4 @@
158
154
 
159
155
  *|;
160
156
 
161
- }%%
162
-
163
- %% write data nofinal;
164
-
165
- VALUE
166
- red_pass(VALUE self, VALUE regs, VALUE ref, ID meth, VALUE refs)
167
- {
168
- VALUE txt = rb_hash_aref(regs, ref);
169
- if (!NIL_P(txt)) rb_hash_aset(regs, ref, redcloth_inline2(self, txt, refs));
170
- return rb_funcall(self, meth, 1, regs);
171
- }
172
-
173
- VALUE
174
- red_parse_attr(VALUE self, VALUE regs, VALUE ref)
175
- {
176
- VALUE txt = rb_hash_aref(regs, ref);
177
- VALUE new_regs = redcloth_attributes(self, txt);
178
- return rb_funcall(regs, rb_intern("update"), 1, new_regs);
179
- }
180
-
181
- VALUE
182
- red_parse_link_attr(VALUE self, VALUE regs, VALUE ref)
183
- {
184
- VALUE txt = rb_hash_aref(regs, ref);
185
- VALUE new_regs = redcloth_link_attributes(self, txt);
186
- return rb_funcall(regs, rb_intern("update"), 1, new_regs);
187
- }
188
-
189
- VALUE
190
- red_pass_code(VALUE self, VALUE regs, VALUE ref, ID meth)
191
- {
192
- VALUE txt = rb_hash_aref(regs, ref);
193
- if (!NIL_P(txt)) {
194
- VALUE txt2 = rb_str_new2("");
195
- rb_str_cat_escaped_for_preformatted(self, txt2, RSTRING_PTR(txt), RSTRING_PTR(txt) + RSTRING_LEN(txt));
196
- rb_hash_aset(regs, ref, txt2);
197
- }
198
- return rb_funcall(self, meth, 1, regs);
199
- }
200
-
201
- VALUE
202
- red_block(VALUE self, VALUE regs, VALUE block, VALUE refs)
203
- {
204
- ID method;
205
- VALUE fallback;
206
- VALUE sym_text = ID2SYM(rb_intern("text"));
207
- VALUE btype = rb_hash_aref(regs, ID2SYM(rb_intern("type")));
208
- block = rb_funcall(block, rb_intern("strip"), 0);
209
- if ((!NIL_P(block)) && !NIL_P(btype))
210
- {
211
- method = rb_intern(RSTRING_PTR(btype));
212
- if (method == rb_intern("notextile")) {
213
- rb_hash_aset(regs, sym_text, block);
214
- } else {
215
- rb_hash_aset(regs, sym_text, redcloth_inline2(self, block, refs));
216
- }
217
- if (rb_respond_to(self, method)) {
218
- block = rb_funcall(self, method, 1, regs);
219
- } else {
220
- fallback = rb_hash_aref(regs, ID2SYM(rb_intern("fallback")));
221
- if (!NIL_P(fallback)) {
222
- rb_str_append(fallback, rb_hash_aref(regs, sym_text));
223
- CLEAR_REGS();
224
- rb_hash_aset(regs, sym_text, fallback);
225
- }
226
- block = rb_funcall(self, rb_intern("p"), 1, regs);
227
- }
228
- }
229
- return block;
230
- }
231
-
232
- VALUE
233
- red_blockcode(VALUE self, VALUE regs, VALUE block)
234
- {
235
- VALUE btype = rb_hash_aref(regs, ID2SYM(rb_intern("type")));
236
- block = rb_funcall(block, rb_intern("strip"), 0);
237
- if (RSTRING_LEN(block) > 0)
238
- {
239
- rb_hash_aset(regs, ID2SYM(rb_intern("text")), block);
240
- block = rb_funcall(self, rb_intern(RSTRING_PTR(btype)), 1, regs);
241
- }
242
- return block;
243
- }
244
-
245
- void
246
- red_inc(VALUE regs, VALUE ref)
247
- {
248
- int aint = 0;
249
- VALUE aval = rb_hash_aref(regs, ref);
250
- if (aval != Qnil) aint = NUM2INT(aval);
251
- rb_hash_aset(regs, ref, INT2NUM(aint + 1));
252
- }
253
-
254
- VALUE
255
- redcloth_inline(self, p, pe, refs)
256
- VALUE self;
257
- char *p, *pe;
258
- VALUE refs;
259
- {
260
- int cs, act;
261
- char *ts, *te, *reg, *eof;
262
- char *orig_p = p, *orig_pe = pe;
263
- VALUE block = rb_str_new2("");
264
- VALUE regs = Qnil;
265
- unsigned int opts = 0;
266
- VALUE buf = Qnil;
267
-
268
- %% write init;
269
-
270
- %% write exec;
271
-
272
- return block;
273
- }
274
-
275
- /** Append characters to a string, escaping (&, <, >, ", ') using the formatter's escape method.
276
- * @param str ruby string
277
- * @param ts start of character buffer to append
278
- * @param te end of character buffer
279
- */
280
- void
281
- rb_str_cat_escaped(self, str, ts, te)
282
- VALUE self, str;
283
- char *ts, *te;
284
- {
285
- VALUE source_str = rb_str_new(ts, te-ts);
286
- VALUE escaped_str = rb_funcall(self, rb_intern("escape"), 1, source_str);
287
- rb_str_concat(str, escaped_str);
288
- }
289
-
290
- void
291
- rb_str_cat_escaped_for_preformatted(self, str, ts, te)
292
- VALUE self, str;
293
- char *ts, *te;
294
- {
295
- VALUE source_str = rb_str_new(ts, te-ts);
296
- VALUE escaped_str = rb_funcall(self, rb_intern("escape_pre"), 1, source_str);
297
- rb_str_concat(str, escaped_str);
298
- }
299
-
300
- VALUE
301
- redcloth_inline2(self, str, refs)
302
- VALUE self, str, refs;
303
- {
304
- StringValue(str);
305
- return redcloth_inline(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, refs);
306
- }
157
+ }%%;