RedCloth 4.1.0-universal-java

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.

Files changed (59) hide show
  1. data/CHANGELOG +103 -0
  2. data/COPYING +18 -0
  3. data/Manifest +57 -0
  4. data/README +156 -0
  5. data/Rakefile +205 -0
  6. data/RedCloth.gemspec +141 -0
  7. data/bin/redcloth +28 -0
  8. data/ext/mingw-rbconfig.rb +176 -0
  9. data/ext/redcloth_scan/extconf.rb +9 -0
  10. data/ext/redcloth_scan/redcloth.h +164 -0
  11. data/ext/redcloth_scan/redcloth_attributes.c.rl +56 -0
  12. data/ext/redcloth_scan/redcloth_attributes.java.rl +96 -0
  13. data/ext/redcloth_scan/redcloth_attributes.rl +33 -0
  14. data/ext/redcloth_scan/redcloth_common.c.rl +18 -0
  15. data/ext/redcloth_scan/redcloth_common.java.rl +18 -0
  16. data/ext/redcloth_scan/redcloth_common.rl +111 -0
  17. data/ext/redcloth_scan/redcloth_inline.c.rl +159 -0
  18. data/ext/redcloth_scan/redcloth_inline.java.rl +108 -0
  19. data/ext/redcloth_scan/redcloth_inline.rl +157 -0
  20. data/ext/redcloth_scan/redcloth_scan.c.rl +227 -0
  21. data/ext/redcloth_scan/redcloth_scan.java.rl +555 -0
  22. data/ext/redcloth_scan/redcloth_scan.rl +323 -0
  23. data/extras/ragel_profiler.rb +73 -0
  24. data/lib/case_sensitive_require/RedCloth.rb +6 -0
  25. data/lib/redcloth.rb +37 -0
  26. data/lib/redcloth/erb_extension.rb +27 -0
  27. data/lib/redcloth/formatters/base.rb +57 -0
  28. data/lib/redcloth/formatters/html.rb +349 -0
  29. data/lib/redcloth/formatters/latex.rb +249 -0
  30. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  31. data/lib/redcloth/textile_doc.rb +105 -0
  32. data/lib/redcloth/version.rb +28 -0
  33. data/lib/redcloth_scan.jar +0 -0
  34. data/setup.rb +1585 -0
  35. data/test/basic.yml +870 -0
  36. data/test/code.yml +229 -0
  37. data/test/definitions.yml +82 -0
  38. data/test/extra_whitespace.yml +64 -0
  39. data/test/filter_html.yml +177 -0
  40. data/test/filter_pba.yml +20 -0
  41. data/test/helper.rb +108 -0
  42. data/test/html.yml +305 -0
  43. data/test/images.yml +246 -0
  44. data/test/instiki.yml +38 -0
  45. data/test/links.yml +259 -0
  46. data/test/lists.yml +283 -0
  47. data/test/poignant.yml +89 -0
  48. data/test/sanitize_html.yml +42 -0
  49. data/test/table.yml +267 -0
  50. data/test/test_custom_tags.rb +46 -0
  51. data/test/test_erb.rb +13 -0
  52. data/test/test_extensions.rb +31 -0
  53. data/test/test_formatters.rb +24 -0
  54. data/test/test_parser.rb +73 -0
  55. data/test/test_restrictions.rb +41 -0
  56. data/test/textism.yml +480 -0
  57. data/test/threshold.yml +772 -0
  58. data/test/validate_fixtures.rb +73 -0
  59. metadata +139 -0
@@ -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
+ }
@@ -0,0 +1,157 @@
1
+ /*
2
+ * redcloth_inline.rl
3
+ *
4
+ * Copyright (C) 2008 Jason Garber
5
+ */
6
+ %%{
7
+
8
+ machine redcloth_inline;
9
+
10
+ # links
11
+ mtext_noquotes = mtext -- '"' ;
12
+ quoted_mtext = '"' mtext_noquotes '"' ;
13
+ mtext_including_quotes = (mtext_noquotes ' "' mtext_noquotes '" ' mtext_noquotes?)+ ;
14
+ link_says = ( C_noactions "."* " "* ((quoted_mtext | mtext_including_quotes | mtext_noquotes) -- '":') ) >A %{ STORE("link_text"); } ;
15
+ link_says_noquotes_noactions = ( C_noquotes_noactions "."* " "* ((mtext_noquotes) -- '":') ) ;
16
+ link = ( '"' link_says '":' %A uri %{ STORE_URL("href"); } ) >X ;
17
+ link_noquotes_noactions = ( '"' link_says_noquotes_noactions '":' uri ) ;
18
+ bracketed_link = ( '["' link_says '":' %A uri %{ STORE("href"); } :> "]" ) >X ;
19
+
20
+ # images
21
+ image_src = ( uri ) >A %{ STORE("src"); } ;
22
+ image_is = ( A2 C ". "? image_src :> title? ) ;
23
+ image_link = ( ":" uri >A %{ STORE_URL("href"); } ) ;
24
+ image = ( "["? "!" image_is "!" %A image_link? "]"? ) >X ;
25
+
26
+ # footnotes
27
+ footno = "[" >X %A digit+ %T "]" ;
28
+
29
+ # markup
30
+ end_markup_phrase = (" " | PUNCT | EOF | LF) @{ fhold; };
31
+ code = "["? "@" >X mtext >A %T :> "@" "]"? ;
32
+ code_tag_start = "<code" [^>]* ">" ;
33
+ code_tag_end = "</code>" ;
34
+ script_tag = ( "<script" [^>]* ">" (default+ -- "</script>") "</script>" LF? ) >X >A %T ;
35
+ notextile = "<notextile>" >X (default+ -- "</notextile>") >A %T "</notextile>";
36
+ strong = "["? "*" >X mtext >A %T :> "*" "]"? ;
37
+ b = "["? "**" >X mtext >A %T :> "**" "]"? ;
38
+ em = "["? "_" >X mtext >A %T :> "_" "]"? ;
39
+ i = "["? "__" >X mtext >A %T :> "__" "]"? ;
40
+ del = "[-" >X C ( mtext ) >A %T :>> "-]" ;
41
+ emdash_parenthetical_phrase_with_spaces = " -- " mtext " -- " ;
42
+ del_phrase = (( " " >A %{ STORE("beginning_space"); } "-") >X C ( mtext ) >A %T :>> ( "-" end_markup_phrase )) - emdash_parenthetical_phrase_with_spaces ;
43
+ ins = "["? "+" >X mtext >A %T :> "+" "]"? ;
44
+ sup = "[^" >X mtext >A %T :> "^]" ;
45
+ sup_phrase = ( "^" when starts_phrase) >X ( mtext ) >A %T :>> ( "^" end_markup_phrase ) ;
46
+ sub = "[~" >X mtext >A %T :> "~]" ;
47
+ sub_phrase = ( "~" when starts_phrase) >X ( mtext ) >A %T :>> ( "~" end_markup_phrase ) ;
48
+ span = "[%" >X mtext >A %T :> "%]" ;
49
+ span_phrase = (("%" when starts_phrase) >X ( mtext ) >A %T :>> ( "%" end_markup_phrase )) ;
50
+ cite = "["? "??" >X mtext >A %T :> "??" "]"? ;
51
+ ignore = "["? "==" >X %A mtext %T :> "==" "]"? ;
52
+ snip = "["? "```" >X %A mtext %T :> "```" "]"? ;
53
+
54
+ # quotes
55
+ quote1 = "'" >X %A mtext %T :> "'" ;
56
+ non_quote_chars_or_link = (chars -- '"') | link_noquotes_noactions ;
57
+ mtext_inside_quotes = ( non_quote_chars_or_link (mspace non_quote_chars_or_link)* ) ;
58
+ html_tag_up_to_attribute_quote = "<" Name space+ NameAttr space* "=" space* ;
59
+ quote2 = ('"' >X %A ( mtext_inside_quotes - (mtext_inside_quotes html_tag_up_to_attribute_quote ) ) %T :> '"' ) ;
60
+ multi_paragraph_quote = (('"' when starts_line) >X %A ( chars -- '"' ) %T );
61
+
62
+ # html
63
+ start_tag = ( "<" Name space+ AttrSet* (AttrEnd)? ">" | "<" Name ">" ) >X >A %T ;
64
+ empty_tag = ( "<" Name space+ AttrSet* (AttrEnd)? "/>" | "<" Name "/>" ) >X >A %T ;
65
+ end_tag = ( "</" Name space* ">" ) >X >A %T ;
66
+ html_comment = ("<!--" (default+) :>> "-->") >X >A %T;
67
+
68
+ # glyphs
69
+ ellipsis = ( " "? >A %T "..." ) >X ;
70
+ emdash = "--" ;
71
+ arrow = "->" ;
72
+ endash = " - " ;
73
+ acronym = ( [A-Z] >A [A-Z0-9]{2,} %T "(" default+ >A %{ STORE("title"); } :> ")" ) >X ;
74
+ caps_noactions = upper{3,} ;
75
+ caps = ( caps_noactions >A %*T ) >X ;
76
+ dim_digit = [0-9.]+ ;
77
+ prime = ("'" | '"')?;
78
+ dim_noactions = dim_digit prime (("x" | " x ") dim_digit prime) %T (("x" | " x ") dim_digit prime)? ;
79
+ dim = dim_noactions >X >A %T ;
80
+ tm = [Tt] [Mm] ;
81
+ trademark = " "? ( "[" tm "]" | "(" tm ")" ) ;
82
+ reg = [Rr] ;
83
+ registered = " "? ( "[" reg "]" | "(" reg ")" ) ;
84
+ cee = [Cc] ;
85
+ copyright = ( "[" cee "]" | "(" cee ")" ) ;
86
+ entity = ( "&" %A ( '#' digit+ | ( alpha ( alpha | digit )+ ) ) %T ';' ) >X ;
87
+
88
+ # info
89
+ redcloth_version = "[RedCloth::VERSION]" ;
90
+
91
+ other_phrase = phrase -- dim_noactions;
92
+
93
+ code_tag := |*
94
+ code_tag_end { CAT(block); fgoto main; };
95
+ default => esc_pre;
96
+ *|;
97
+
98
+ main := |*
99
+
100
+ image { INLINE(block, "image"); };
101
+
102
+ link { PARSE_LINK_ATTR("link_text"); PASS(block, "name", "link"); };
103
+ bracketed_link { PARSE_LINK_ATTR("link_text"); PASS(block, "name", "link"); };
104
+
105
+ code { PARSE_ATTR("text"); PASS_CODE(block, "text", "code", opts); };
106
+ code_tag_start { CAT(block); fgoto code_tag; };
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"); };
122
+ ignore => ignore;
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"); };
127
+
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"); };
140
+
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"); };
146
+
147
+ redcloth_version { INLINE(block, "inline_redcloth_version"); };
148
+
149
+ other_phrase => esc;
150
+ PUNCT => esc;
151
+ space => esc;
152
+
153
+ EOF;
154
+
155
+ *|;
156
+
157
+ }%%;
@@ -0,0 +1,227 @@
1
+ /*
2
+ * redcloth_scan.c.rl
3
+ *
4
+ * Copyright (C) 2008 Jason Garber
5
+ */
6
+ #define redcloth_scan_c
7
+
8
+ #include <ruby.h>
9
+ #include "redcloth.h"
10
+
11
+ VALUE mRedCloth, super_ParseError, super_RedCloth, super_HTML, super_LATEX;
12
+ int SYM_escape_preformatted, SYM_escape_attributes;
13
+
14
+ %%{
15
+
16
+ machine redcloth_scan;
17
+ include redcloth_common "redcloth_common.c.rl";
18
+
19
+ action extend { extend = rb_hash_aref(regs, ID2SYM(rb_intern("type"))); }
20
+
21
+ include redcloth_scan "redcloth_scan.rl";
22
+
23
+ }%%
24
+
25
+ %% write data nofinal;
26
+
27
+ VALUE
28
+ redcloth_transform(self, p, pe, refs)
29
+ VALUE self;
30
+ char *p, *pe;
31
+ VALUE refs;
32
+ {
33
+ char *orig_p = p, *orig_pe = pe;
34
+ int cs, act, nest;
35
+ char *ts = NULL, *te = NULL, *reg = NULL, *bck = NULL, *eof = NULL;
36
+ VALUE html = rb_str_new2("");
37
+ VALUE table = rb_str_new2("");
38
+ VALUE block = rb_str_new2("");
39
+ VALUE regs; CLEAR_REGS()
40
+
41
+
42
+ VALUE list_layout = Qnil;
43
+ char *list_type = NULL;
44
+ VALUE list_index = rb_ary_new();
45
+ int list_continue = 0;
46
+ VALUE plain_block; SET_PLAIN_BLOCK("p");
47
+ VALUE extend = Qnil;
48
+ char listm[10] = "";
49
+ VALUE refs_found = rb_hash_new();
50
+
51
+ %% write init;
52
+
53
+ %% write exec;
54
+
55
+ if (RSTRING_LEN(block) > 0)
56
+ {
57
+ ADD_BLOCK();
58
+ }
59
+
60
+ if ( NIL_P(refs) && rb_funcall(refs_found, rb_intern("empty?"), 0) == Qfalse ) {
61
+ return redcloth_transform(self, orig_p, orig_pe, refs_found);
62
+ } else {
63
+ rb_funcall(self, rb_intern("after_transform"), 1, html);
64
+ return html;
65
+ }
66
+ }
67
+
68
+ VALUE
69
+ redcloth_transform2(self, str)
70
+ VALUE self, str;
71
+ {
72
+ StringValue(str);
73
+ rb_funcall(self, rb_intern("before_transform"), 1, str);
74
+ return redcloth_transform(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, Qnil);
75
+ }
76
+
77
+ /*
78
+ * Converts special characters into HTML entities.
79
+ */
80
+ static VALUE
81
+ redcloth_html_esc(int argc, VALUE* argv, VALUE self) //(self, str, level)
82
+ {
83
+ VALUE str, level;
84
+
85
+ rb_scan_args(argc, argv, "11", &str, &level);
86
+
87
+ VALUE new_str = rb_str_new2("");
88
+ if (str == Qnil)
89
+ return new_str;
90
+
91
+ StringValue(str);
92
+
93
+ if (RSTRING_LEN(str) == 0)
94
+ return new_str;
95
+
96
+ char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
97
+ char *t = ts, *t2 = ts, *ch = NULL;
98
+ if (te <= ts) return;
99
+
100
+ while (t2 < te) {
101
+ ch = NULL;
102
+
103
+ // normal + pre
104
+ switch (*t2)
105
+ {
106
+ case '&': ch = "amp"; break;
107
+ case '>': ch = "gt"; break;
108
+ case '<': ch = "lt"; break;
109
+ }
110
+
111
+ // normal (non-pre)
112
+ if (level != SYM_escape_preformatted) {
113
+ switch (*t2)
114
+ {
115
+ case '\n': ch = "br"; break;
116
+ case '"' : ch = "quot"; break;
117
+ case '\'':
118
+ ch = (level == SYM_escape_attributes) ? "apos" : "squot";
119
+ break;
120
+ }
121
+ }
122
+
123
+ if (ch != NULL)
124
+ {
125
+ if (t2 > t)
126
+ rb_str_cat(new_str, t, t2-t);
127
+ rb_str_concat(new_str, rb_funcall(self, rb_intern(ch), 1, rb_hash_new()));
128
+ t = t2 + 1;
129
+ }
130
+
131
+ t2++;
132
+ }
133
+ if (t2 > t)
134
+ rb_str_cat(new_str, t, t2-t);
135
+
136
+ return new_str;
137
+ }
138
+
139
+ /*
140
+ * Converts special characters into LaTeX entities.
141
+ */
142
+ static VALUE
143
+ redcloth_latex_esc(VALUE self, VALUE str)
144
+ {
145
+ VALUE new_str = rb_str_new2("");
146
+
147
+ if (str == Qnil)
148
+ return new_str;
149
+
150
+ StringValue(str);
151
+
152
+ if (RSTRING_LEN(str) == 0)
153
+ return new_str;
154
+
155
+ char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
156
+ char *t = ts, *t2 = ts, *ch = NULL;
157
+ if (te <= ts) return;
158
+
159
+ while (t2 < te) {
160
+ ch = NULL;
161
+
162
+ switch (*t2)
163
+ {
164
+ case '{': ch = "#123"; break;
165
+ case '}': ch = "#125"; break;
166
+ case '\\': ch = "#92"; break;
167
+ case '#': ch = "#35"; break;
168
+ case '$': ch = "#36"; break;
169
+ case '%': ch = "#37"; break;
170
+ case '&': ch = "amp"; break;
171
+ case '_': ch = "#95"; break;
172
+ case '^': ch = "circ"; break;
173
+ case '~': ch = "tilde"; break;
174
+ case '<': ch = "lt"; break;
175
+ case '>': ch = "gt"; break;
176
+ case '\n': ch = "#10"; break;
177
+ }
178
+
179
+ if (ch != NULL)
180
+ {
181
+ if (t2 > t)
182
+ rb_str_cat(new_str, t, t2-t);
183
+ VALUE opts = rb_hash_new();
184
+ rb_hash_aset(opts, ID2SYM(rb_intern("text")), rb_str_new2(ch));
185
+ rb_str_concat(new_str, rb_funcall(self, rb_intern("entity"), 1, opts));
186
+ t = t2 + 1;
187
+ }
188
+
189
+ t2++;
190
+ }
191
+ if (t2 > t)
192
+ rb_str_cat(new_str, t, t2-t);
193
+
194
+ return new_str;
195
+ }
196
+
197
+ static VALUE
198
+ redcloth_to(self, formatter)
199
+ VALUE self, formatter;
200
+ {
201
+ char *pe, *p;
202
+ int len = 0;
203
+
204
+ rb_funcall(self, rb_intern("delete!"), 1, rb_str_new2("\r"));
205
+ VALUE working_copy = rb_obj_clone(self);
206
+ rb_extend_object(working_copy, formatter);
207
+ if (rb_funcall(working_copy, rb_intern("lite_mode"), 0) == Qtrue) {
208
+ return redcloth_inline2(working_copy, self, rb_hash_new());
209
+ } else {
210
+ return redcloth_transform2(working_copy, self);
211
+ }
212
+ }
213
+
214
+ void Init_redcloth_scan()
215
+ {
216
+ mRedCloth = rb_define_module("RedCloth");
217
+ /* A Textile document that can be converted to other formats. See
218
+ the README for Textile syntax. */
219
+ super_RedCloth = rb_define_class_under(mRedCloth, "TextileDoc", rb_cString);
220
+ rb_define_method(super_RedCloth, "to", redcloth_to, 1);
221
+ super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException);
222
+ /* Escaping */
223
+ rb_define_method(super_RedCloth, "html_esc", redcloth_html_esc, -1);
224
+ rb_define_method(super_RedCloth, "latex_esc", redcloth_latex_esc, 1);
225
+ SYM_escape_preformatted = ID2SYM(rb_intern("html_escape_preformatted"));
226
+ SYM_escape_attributes = ID2SYM(rb_intern("html_escape_attributes"));
227
+ }