Changeset 274
- Timestamp:
- 03/17/2008 12:03:39 (8 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
- 4 moved
-
ext/redcloth_scan/extconf.rb (modified) (1 diff)
-
ext/redcloth_scan/redcloth.h (moved) (moved from trunk/ext/redcloth_scan/superredcloth.h) (3 diffs)
-
ext/redcloth_scan/redcloth_common.rl (moved) (moved from trunk/ext/redcloth_scan/superredcloth_common.rl) (1 diff)
-
ext/redcloth_scan/redcloth_inline.rl (moved) (moved from trunk/ext/redcloth_scan/superredcloth_inline.rl) (6 diffs)
-
ext/redcloth_scan/redcloth_scan.rl (moved) (moved from trunk/ext/redcloth_scan/superredcloth_scan.rl) (9 diffs)
-
lib/redcloth/html.rb (modified) (1 diff)
-
lib/redcloth/latex.rb (modified) (1 diff)
-
test/helper.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/redcloth_scan/extconf.rb
r272 r274 3 3 $CFLAGS << " -O0 " # do not optimize (takes too much memory and performance gain is negligeable) 4 4 5 dir_config(" superredcloth_scan")5 dir_config("redcloth_scan") 6 6 have_library("c", "main") 7 7 8 create_makefile(" superredcloth_scan")8 create_makefile("redcloth_scan") -
trunk/ext/redcloth_scan/redcloth.h
r272 r274 1 #ifndef superredcloth_h2 #define superredcloth_h1 #ifndef redcloth_h 2 #define redcloth_h 3 3 4 4 /* variable defs */ 5 #ifndef superredcloth_scan_c5 #ifndef redcloth_scan_c 6 6 extern VALUE super_ParseError, super_RedCloth; 7 7 extern int SYM_html_escape_entities; … … 11 11 void rb_str_cat_escaped(VALUE str, char *ts, char *te, unsigned int opts); 12 12 void rb_str_cat_escaped_for_preformatted(VALUE str, char *ts, char *te, unsigned int opts); 13 VALUE superredcloth_inline(VALUE, char *, char *, VALUE);14 VALUE superredcloth_inline2(VALUE, VALUE, VALUE);15 VALUE superredcloth_transform(VALUE, char *, char *, VALUE);16 VALUE superredcloth_transform2(VALUE, VALUE);13 VALUE redcloth_inline(VALUE, char *, char *, VALUE); 14 VALUE redcloth_inline2(VALUE, VALUE, VALUE); 15 VALUE redcloth_transform(VALUE, char *, char *, VALUE); 16 VALUE redcloth_transform2(VALUE, VALUE); 17 17 void red_inc(VALUE, VALUE); 18 18 VALUE red_block(VALUE, VALUE, ID, VALUE); … … 50 50 } \ 51 51 if (p > reg && reg >= ts) { \ 52 VALUE str = superredcloth_transform(rb_formatter, reg, p, refs); \52 VALUE str = redcloth_transform(rb_formatter, reg, p, refs); \ 53 53 rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \ 54 54 /* printf("TRANSFORM(" #T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \ -
trunk/ext/redcloth_scan/redcloth_common.rl
r272 r274 1 1 %%{ 2 2 3 machine superredcloth_common;3 machine redcloth_common; 4 4 5 5 action A { reg = p; } -
trunk/ext/redcloth_scan/redcloth_inline.rl
r272 r274 1 1 /* 2 * superredcloth_inline.rl2 * redcloth_inline.rl 3 3 * 4 4 * $Author: why $ … … 8 8 */ 9 9 #include <ruby.h> 10 #include " superredcloth.h"10 #include "redcloth.h" 11 11 12 12 %%{ 13 13 14 machine superredcloth_inline;15 include superredcloth_common "ext/superredcloth_scan/superredcloth_common.rl";14 machine redcloth_inline; 15 include redcloth_common "ext/redcloth_scan/redcloth_common.rl"; 16 16 17 17 # common … … 135 135 { 136 136 VALUE txt = rb_hash_aref(regs, ref); 137 if (!NIL_P(txt)) rb_hash_aset(regs, ref, superredcloth_inline2(rb_formatter, txt, refs));137 if (!NIL_P(txt)) rb_hash_aset(regs, ref, redcloth_inline2(rb_formatter, txt, refs)); 138 138 return rb_funcall(rb_formatter, meth, 1, regs); 139 139 } … … 166 166 if ((RSTRING(block)->len > 0) && !NIL_P(btype)) 167 167 { 168 rb_hash_aset(regs, ID2SYM(rb_intern("text")), superredcloth_inline2(rb_formatter, block, refs));168 rb_hash_aset(regs, ID2SYM(rb_intern("text")), redcloth_inline2(rb_formatter, block, refs)); 169 169 block = rb_funcall(rb_formatter, rb_intern(RSTRING(btype)->ptr), 1, regs); 170 170 } … … 195 195 196 196 VALUE 197 superredcloth_inline(rb_formatter, p, pe, refs)197 redcloth_inline(rb_formatter, p, pe, refs) 198 198 VALUE rb_formatter; 199 199 char *p, *pe; … … 303 303 304 304 VALUE 305 superredcloth_inline2(formatter, str, refs)305 redcloth_inline2(formatter, str, refs) 306 306 VALUE formatter, str, refs; 307 307 { 308 308 StringValue(str); 309 return superredcloth_inline(formatter, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1, refs);310 } 309 return redcloth_inline(formatter, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1, refs); 310 } -
trunk/ext/redcloth_scan/redcloth_scan.rl
r272 r274 1 1 /* 2 * superredcloth_scan.rl2 * redcloth_scan.rl 3 3 * 4 4 * $Author: why $ … … 7 7 * Copyright (C) 2007 why the lucky stiff 8 8 */ 9 #define superredcloth_scan_c9 #define redcloth_scan_c 10 10 11 11 #include <ruby.h> 12 #include " superredcloth.h"12 #include "redcloth.h" 13 13 14 14 VALUE super_ParseError, super_RedCloth, super_HTML, super_LATEX; … … 17 17 %%{ 18 18 19 machine superredcloth_scan;20 include superredcloth_common "ext/superredcloth_scan/superredcloth_common.rl";19 machine redcloth_scan; 20 include redcloth_common "ext/redcloth_scan/redcloth_common.rl"; 21 21 22 22 action extend { extend = rb_hash_aref(regs, ID2SYM(rb_intern("type"))); } … … 174 174 175 175 VALUE 176 superredcloth_transform(rb_formatter, p, pe, refs)176 redcloth_transform(rb_formatter, p, pe, refs) 177 177 VALUE rb_formatter; 178 178 char *p, *pe; … … 210 210 211 211 if ( NIL_P(refs) && rb_funcall(refs_found, rb_intern("empty?"), 0) == Qfalse ) { 212 return superredcloth_transform(rb_formatter, orig_p, orig_pe, refs_found);212 return redcloth_transform(rb_formatter, orig_p, orig_pe, refs_found); 213 213 } else { 214 214 rb_funcall(rb_formatter, rb_intern("after_transform"), 1, html); … … 218 218 219 219 VALUE 220 superredcloth_transform2(formatter, str)220 redcloth_transform2(formatter, str) 221 221 VALUE formatter, str; 222 222 { 223 223 rb_str_cat2(str, "\n"); 224 224 StringValue(str); 225 return superredcloth_transform(formatter, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1, Qnil);225 return redcloth_transform(formatter, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1, Qnil); 226 226 } 227 227 228 228 static VALUE 229 superredcloth_to_html(self)229 redcloth_to_html(self) 230 230 VALUE self; 231 231 { … … 233 233 int len = 0; 234 234 235 return superredcloth_transform2(super_HTML, self);235 return redcloth_transform2(super_HTML, self); 236 236 } 237 237 238 238 static VALUE 239 superredcloth_to_latex(self)239 redcloth_to_latex(self) 240 240 VALUE self; 241 241 { … … 243 243 int len = 0; 244 244 245 return superredcloth_transform2(super_LATEX, self);245 return redcloth_transform2(super_LATEX, self); 246 246 } 247 247 248 248 static VALUE 249 superredcloth_to(self, formatter)249 redcloth_to(self, formatter) 250 250 VALUE self, formatter; 251 251 { … … 253 253 int len = 0; 254 254 255 return superredcloth_transform2(formatter, self);256 } 257 258 void Init_ superredcloth_scan()259 { 260 super_RedCloth = rb_define_class(" SuperRedCloth", rb_cString);261 rb_define_method(super_RedCloth, "to_html", superredcloth_to_html, 0);262 rb_define_method(super_RedCloth, "to_latex", superredcloth_to_latex, 0);263 rb_define_method(super_RedCloth, "to", superredcloth_to, 1);255 return redcloth_transform2(formatter, self); 256 } 257 258 void Init_redcloth_scan() 259 { 260 super_RedCloth = rb_define_class("RedCloth", rb_cString); 261 rb_define_method(super_RedCloth, "to_html", redcloth_to_html, 0); 262 rb_define_method(super_RedCloth, "to_latex", redcloth_to_latex, 0); 263 rb_define_method(super_RedCloth, "to", redcloth_to, 1); 264 264 super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException); 265 265 super_HTML = rb_define_module_under(super_RedCloth, "HTML"); -
trunk/lib/redcloth/html.rb
r272 r274 1 class << SuperRedCloth::HTML1 class << RedCloth::HTML 2 2 def options 3 3 {:html_escape_entities => true} -
trunk/lib/redcloth/latex.rb
r272 r274 1 class << SuperRedCloth::LATEX1 class << RedCloth::LATEX 2 2 def options 3 3 {:html_escape_entities => false} -
trunk/test/helper.rb
r272 r274 1 1 require 'test/unit' 2 2 $:.unshift File.dirname(__FILE__) + "/../lib" 3 require ' superredcloth'3 require 'redcloth' 4 4 require 'yaml' 5 5 6 6 def red(formatter, str) 7 SuperRedCloth.new(str).send("to_#{formatter}")7 RedCloth.new(str).send("to_#{formatter}") 8 8 end 9 9