RedCloth 4.1.9-universal-java → 4.2.0-universal-java
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.
Potentially problematic release.
This version of RedCloth might be problematic. Click here for more details.
- data/CHANGELOG +55 -0
 - data/Manifest +34 -38
 - data/README +17 -5
 - data/Rakefile +79 -30
 - data/RedCloth.gemspec +8 -9
 - data/ext/redcloth_scan/redcloth.h +38 -13
 - data/lib/redcloth.rb +9 -3
 - data/lib/redcloth/formatters/html.rb +2 -2
 - data/lib/redcloth/formatters/latex.rb +99 -54
 - data/lib/redcloth/formatters/latex_entities.yml +2 -2
 - data/lib/redcloth/version.rb +9 -4
 - data/lib/redcloth_scan.jar +0 -0
 - data/lib/tasks/pureruby.rake +12 -0
 - data/spec/custom_tags_spec.rb +50 -0
 - data/spec/differs/inline.rb +48 -0
 - data/{test/test_erb.rb → spec/erb_spec.rb} +6 -9
 - data/spec/extension_spec.rb +26 -0
 - data/{test → spec/fixtures}/basic.yml +90 -4
 - data/{test → spec/fixtures}/code.yml +29 -0
 - data/{test → spec/fixtures}/definitions.yml +0 -0
 - data/{test → spec/fixtures}/extra_whitespace.yml +0 -0
 - data/{test → spec/fixtures}/filter_html.yml +0 -0
 - data/{test → spec/fixtures}/filter_pba.yml +0 -0
 - data/{test → spec/fixtures}/html.yml +15 -0
 - data/{test → spec/fixtures}/images.yml +16 -6
 - data/{test → spec/fixtures}/instiki.yml +0 -0
 - data/{test → spec/fixtures}/links.yml +7 -1
 - data/{test → spec/fixtures}/lists.yml +162 -1
 - data/{test → spec/fixtures}/poignant.yml +0 -0
 - data/{test → spec/fixtures}/sanitize_html.yml +0 -0
 - data/{test → spec/fixtures}/table.yml +121 -23
 - data/{test → spec/fixtures}/textism.yml +44 -15
 - data/{test → spec/fixtures}/threshold.yml +6 -14
 - data/spec/formatters/class_filtered_html_spec.rb +7 -0
 - data/spec/formatters/filtered_html_spec.rb +7 -0
 - data/spec/formatters/html_no_breaks_spec.rb +9 -0
 - data/spec/formatters/html_spec.rb +13 -0
 - data/spec/formatters/id_filtered_html_spec.rb +7 -0
 - data/spec/formatters/latex_spec.rb +13 -0
 - data/spec/formatters/lite_mode_html_spec.rb +7 -0
 - data/spec/formatters/no_span_caps_html_spec.rb +7 -0
 - data/spec/formatters/sanitized_html_spec.rb +7 -0
 - data/spec/formatters/style_filtered_html_spec.rb +7 -0
 - data/spec/parser_spec.rb +95 -0
 - data/spec/spec.opts +3 -0
 - data/spec/spec_helper.rb +42 -0
 - metadata +46 -51
 - data/ext/mingw-rbconfig.rb +0 -176
 - data/ext/redcloth_scan/redcloth_attributes.c.rl +0 -55
 - data/ext/redcloth_scan/redcloth_attributes.java.rl +0 -95
 - data/ext/redcloth_scan/redcloth_attributes.rl +0 -33
 - data/ext/redcloth_scan/redcloth_common.c.rl +0 -18
 - data/ext/redcloth_scan/redcloth_common.java.rl +0 -18
 - data/ext/redcloth_scan/redcloth_common.rl +0 -115
 - data/ext/redcloth_scan/redcloth_inline.c.rl +0 -193
 - data/ext/redcloth_scan/redcloth_inline.java.rl +0 -140
 - data/ext/redcloth_scan/redcloth_inline.rl +0 -156
 - data/ext/redcloth_scan/redcloth_scan.c.rl +0 -228
 - data/ext/redcloth_scan/redcloth_scan.java.rl +0 -577
 - data/ext/redcloth_scan/redcloth_scan.rl +0 -320
 - data/extras/ragel_profiler.rb +0 -73
 - data/test/helper.rb +0 -108
 - data/test/test_custom_tags.rb +0 -58
 - data/test/test_extensions.rb +0 -31
 - data/test/test_formatters.rb +0 -24
 - data/test/test_parser.rb +0 -73
 - data/test/test_restrictions.rb +0 -41
 - data/test/validate_fixtures.rb +0 -74
 
| 
         @@ -1,140 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            /*
         
     | 
| 
       2 
     | 
    
         
            -
             * redcloth_inline.rl
         
     | 
| 
       3 
     | 
    
         
            -
             *
         
     | 
| 
       4 
     | 
    
         
            -
             * Copyright (C) 2009 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 = red_parse_title(RedclothAttributes.link_attributes(self, txt), ref);
         
     | 
| 
       57 
     | 
    
         
            -
                return regs.callMethod(runtime.getCurrentContext(), "update", new_regs);
         
     | 
| 
       58 
     | 
    
         
            -
              }
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              public IRubyObject red_parse_image_attr(IRubyObject self, IRubyObject regs, IRubyObject ref) {
         
     | 
| 
       61 
     | 
    
         
            -
                return red_parse_title(regs, ref);
         
     | 
| 
       62 
     | 
    
         
            -
              }
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
              public IRubyObject red_parse_title(IRubyObject regs, IRubyObject ref) {
         
     | 
| 
       65 
     | 
    
         
            -
                IRubyObject name = ((RubyHash)regs).aref(ref);
         
     | 
| 
       66 
     | 
    
         
            -
                if ( !name.isNil() ) {
         
     | 
| 
       67 
     | 
    
         
            -
                  String s = name.convertToString().toString();
         
     | 
| 
       68 
     | 
    
         
            -
                  int p = s.length();
         
     | 
| 
       69 
     | 
    
         
            -
                  if (s.charAt(p - 1) == ')') {
         
     | 
| 
       70 
     | 
    
         
            -
                    int level = -1;
         
     | 
| 
       71 
     | 
    
         
            -
                    p--;
         
     | 
| 
       72 
     | 
    
         
            -
                    while (p > 0 && level < 0) {
         
     | 
| 
       73 
     | 
    
         
            -
                      switch(s.charAt(p - 1)) {
         
     | 
| 
       74 
     | 
    
         
            -
                        case '(': ++level; break;
         
     | 
| 
       75 
     | 
    
         
            -
                        case ')': --level; break;
         
     | 
| 
       76 
     | 
    
         
            -
                      }
         
     | 
| 
       77 
     | 
    
         
            -
                      --p;
         
     | 
| 
       78 
     | 
    
         
            -
                    }
         
     | 
| 
       79 
     | 
    
         
            -
                    IRubyObject title = runtime.newString(s.substring(p + 1, s.length() - 1));
         
     | 
| 
       80 
     | 
    
         
            -
                    if(p > 0 && s.charAt(p - 1) == ' ') --p;
         
     | 
| 
       81 
     | 
    
         
            -
                    if(p != 0) {
         
     | 
| 
       82 
     | 
    
         
            -
                      ((RubyHash)regs).aset(ref, runtime.newString(s.substring(0, p)));
         
     | 
| 
       83 
     | 
    
         
            -
                      ((RubyHash)regs).aset(runtime.newSymbol("title"), title);
         
     | 
| 
       84 
     | 
    
         
            -
                    }
         
     | 
| 
       85 
     | 
    
         
            -
                  }
         
     | 
| 
       86 
     | 
    
         
            -
                }
         
     | 
| 
       87 
     | 
    
         
            -
                return regs;
         
     | 
| 
       88 
     | 
    
         
            -
              }
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
              public void PASS_CODE(IRubyObject H, String A, String T, int O) {
         
     | 
| 
       91 
     | 
    
         
            -
                ((RubyString)H).append(red_pass_code(self, regs, runtime.newSymbol(A), T));
         
     | 
| 
       92 
     | 
    
         
            -
              }
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
              public void PARSE_ATTR(String A) {
         
     | 
| 
       95 
     | 
    
         
            -
                red_parse_attr(self, regs, runtime.newSymbol(A));
         
     | 
| 
       96 
     | 
    
         
            -
              }
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
              public void PARSE_LINK_ATTR(String A) {
         
     | 
| 
       99 
     | 
    
         
            -
                red_parse_link_attr(self, regs, runtime.newSymbol(A));
         
     | 
| 
       100 
     | 
    
         
            -
              }
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
              public void PARSE_IMAGE_ATTR(String A) {
         
     | 
| 
       103 
     | 
    
         
            -
                red_parse_image_attr(self, regs, runtime.newSymbol(A));
         
     | 
| 
       104 
     | 
    
         
            -
              }
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              private int opts;
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
              public RedclothInline(IRubyObject self, byte[] data, int p, int pe, IRubyObject refs) {
         
     | 
| 
       109 
     | 
    
         
            -
                this.runtime = self.getRuntime();
         
     | 
| 
       110 
     | 
    
         
            -
                this.self = self;
         
     | 
| 
       111 
     | 
    
         
            -
                
         
     | 
| 
       112 
     | 
    
         
            -
                // This is GROSS but necessary for EOF matching
         
     | 
| 
       113 
     | 
    
         
            -
                this.data = new byte[pe+1];
         
     | 
| 
       114 
     | 
    
         
            -
                System.arraycopy(data, p, this.data, 0, pe);
         
     | 
| 
       115 
     | 
    
         
            -
                this.data[pe] = 0;
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                this.p = 0;
         
     | 
| 
       118 
     | 
    
         
            -
                this.pe = pe+1;
         
     | 
| 
       119 
     | 
    
         
            -
                this.eof = this.pe;
         
     | 
| 
       120 
     | 
    
         
            -
                this.orig_p = 0;
         
     | 
| 
       121 
     | 
    
         
            -
                this.orig_pe = this.pe;
         
     | 
| 
       122 
     | 
    
         
            -
                this.refs = refs;
         
     | 
| 
       123 
     | 
    
         
            -
                this.block = RubyString.newEmptyString(runtime);
         
     | 
| 
       124 
     | 
    
         
            -
                this.regs = runtime.getNil();
         
     | 
| 
       125 
     | 
    
         
            -
                this.opts = 0;
         
     | 
| 
       126 
     | 
    
         
            -
              }
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
              public IRubyObject inline() {
         
     | 
| 
       130 
     | 
    
         
            -
                %% write init;
         
     | 
| 
       131 
     | 
    
         
            -
                %% write exec;
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                return block;
         
     | 
| 
       134 
     | 
    
         
            -
              }
         
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
              public static IRubyObject inline2(IRubyObject self, IRubyObject str, IRubyObject refs) {
         
     | 
| 
       137 
     | 
    
         
            -
                ByteList bl = str.convertToString().getByteList();
         
     | 
| 
       138 
     | 
    
         
            -
                return new RedclothInline(self, bl.bytes, bl.begin, bl.realSize, refs).inline();
         
     | 
| 
       139 
     | 
    
         
            -
              }
         
     | 
| 
       140 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,156 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            /*
         
     | 
| 
       2 
     | 
    
         
            -
             * redcloth_inline.rl
         
     | 
| 
       3 
     | 
    
         
            -
             *
         
     | 
| 
       4 
     | 
    
         
            -
             * Copyright (C) 2009 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("name"); } ;
         
     | 
| 
       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_title = ( '(' mtext ')' ) ;
         
     | 
| 
       22 
     | 
    
         
            -
              image_is = ( A2 C ". "? (uri image_title?) >A %{ STORE("src"); } ) ;
         
     | 
| 
       23 
     | 
    
         
            -
              image_link = ( ":" uri >A %{ STORE_URL("href"); } ) ;
         
     | 
| 
       24 
     | 
    
         
            -
              image = ( "!" image_is "!" %A image_link? ) >X ;
         
     | 
| 
       25 
     | 
    
         
            -
              bracketed_image = ( "[!" image_is "!" %A image_link? "]" ) >X ;
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              # footnotes
         
     | 
| 
       28 
     | 
    
         
            -
              footno = "[" >X %A digit+ %T "]" ;
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              # markup
         
     | 
| 
       31 
     | 
    
         
            -
              end_markup_phrase = (" " | PUNCT | EOF | LF) @{ fhold; };
         
     | 
| 
       32 
     | 
    
         
            -
              code = "["? "@" >X mtext >A %T :> "@" "]"? ;
         
     | 
| 
       33 
     | 
    
         
            -
              script_tag = ( "<script" [^>]* ">" (default+ -- "</script>") "</script>" LF? ) >X >A %T ;
         
     | 
| 
       34 
     | 
    
         
            -
              strong = "["? "*" >X mtext >A %T :> "*" "]"? ;
         
     | 
| 
       35 
     | 
    
         
            -
              b = "["? "**" >X mtext >A %T :> "**" "]"? ;
         
     | 
| 
       36 
     | 
    
         
            -
              em = "["? "_" >X mtext >A %T :> "_" "]"? ;
         
     | 
| 
       37 
     | 
    
         
            -
              i = "["? "__" >X mtext >A %T :> "__" "]"? ;
         
     | 
| 
       38 
     | 
    
         
            -
              del = "[-" >X C ( mtext ) >A %T :>> "-]" ;
         
     | 
| 
       39 
     | 
    
         
            -
              emdash_parenthetical_phrase_with_spaces = " -- " mtext " -- " ;
         
     | 
| 
       40 
     | 
    
         
            -
              del_phrase = (( " " >A %{ STORE("beginning_space"); } "-" | "-" when starts_line) >X C ( mtext ) >A %T :>> ( "-" end_markup_phrase )) - emdash_parenthetical_phrase_with_spaces ;
         
     | 
| 
       41 
     | 
    
         
            -
              ins = "["? "+" >X mtext >A %T :> "+" "]"? ;
         
     | 
| 
       42 
     | 
    
         
            -
              sup = "[^" >X mtext >A %T :> "^]" ;
         
     | 
| 
       43 
     | 
    
         
            -
              sup_phrase = ( "^" when starts_phrase) >X ( mtext ) >A %T :>> ( "^" end_markup_phrase ) ;
         
     | 
| 
       44 
     | 
    
         
            -
              sub = "[~" >X mtext >A %T :> "~]" ;
         
     | 
| 
       45 
     | 
    
         
            -
              sub_phrase = ( "~" when starts_phrase) >X ( mtext ) >A %T :>> ( "~" end_markup_phrase ) ;
         
     | 
| 
       46 
     | 
    
         
            -
              span = "[%" >X mtext >A %T :> "%]" ;
         
     | 
| 
       47 
     | 
    
         
            -
              span_phrase = (("%" when starts_phrase) >X ( mtext ) >A %T :>> ( "%" end_markup_phrase )) ;
         
     | 
| 
       48 
     | 
    
         
            -
              cite = "["? "??" >X mtext >A %T :> "??" "]"? ;
         
     | 
| 
       49 
     | 
    
         
            -
              ignore = "["? "==" >X %A mtext %T :> "==" "]"? ;
         
     | 
| 
       50 
     | 
    
         
            -
              snip = "["? "```" >X %A mtext %T :> "```" "]"? ;
         
     | 
| 
       51 
     | 
    
         
            -
              
         
     | 
| 
       52 
     | 
    
         
            -
              # quotes
         
     | 
| 
       53 
     | 
    
         
            -
              quote1 = "'" >X %A mtext %T :> "'" ;
         
     | 
| 
       54 
     | 
    
         
            -
              non_quote_chars_or_link = (chars -- '"') | link_noquotes_noactions ;
         
     | 
| 
       55 
     | 
    
         
            -
              mtext_inside_quotes = ( non_quote_chars_or_link (mspace non_quote_chars_or_link)* ) ;
         
     | 
| 
       56 
     | 
    
         
            -
              html_tag_up_to_attribute_quote = "<" Name space+ NameAttr space* "=" space* ;
         
     | 
| 
       57 
     | 
    
         
            -
              quote2 = ('"' >X %A ( mtext_inside_quotes - (mtext_inside_quotes html_tag_up_to_attribute_quote ) ) %T :> '"' ) ;
         
     | 
| 
       58 
     | 
    
         
            -
              multi_paragraph_quote = (('"' when starts_line) >X  %A ( chars -- '"' ) %T );
         
     | 
| 
       59 
     | 
    
         
            -
              
         
     | 
| 
       60 
     | 
    
         
            -
              # html
         
     | 
| 
       61 
     | 
    
         
            -
              start_tag = ( "<" Name space+ AttrSet* (AttrEnd)? ">" | "<" Name ">" ) >X >A %T ;
         
     | 
| 
       62 
     | 
    
         
            -
              empty_tag = ( "<" Name space+ AttrSet* (AttrEnd)? "/>" | "<" Name "/>" ) >X >A %T ;
         
     | 
| 
       63 
     | 
    
         
            -
              end_tag = ( "</" Name space* ">" ) >X >A %T ;
         
     | 
| 
       64 
     | 
    
         
            -
              html_comment = ("<!--" (default+) :>> "-->") >X >A %T;
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
              # glyphs
         
     | 
| 
       67 
     | 
    
         
            -
              ellipsis = ( " "? >A %T "..." ) >X ;
         
     | 
| 
       68 
     | 
    
         
            -
              emdash = "--" ;
         
     | 
| 
       69 
     | 
    
         
            -
              arrow = "->" ;
         
     | 
| 
       70 
     | 
    
         
            -
              endash = " - " ;
         
     | 
| 
       71 
     | 
    
         
            -
              acronym = ( [A-Z] >A [A-Z0-9]{2,} %T "(" default+ >A %{ STORE("title"); } :> ")" ) >X ;
         
     | 
| 
       72 
     | 
    
         
            -
              caps_noactions = upper{3,} ;
         
     | 
| 
       73 
     | 
    
         
            -
              caps = ( caps_noactions >A %*T ) >X ;
         
     | 
| 
       74 
     | 
    
         
            -
              dim_digit = [0-9.]+ ;
         
     | 
| 
       75 
     | 
    
         
            -
              prime = ("'" | '"')?;
         
     | 
| 
       76 
     | 
    
         
            -
              dim_noactions = dim_digit prime (("x" | " x ") dim_digit prime) %T (("x" | " x ") dim_digit prime)? ;
         
     | 
| 
       77 
     | 
    
         
            -
              dim = dim_noactions >X >A %T ;
         
     | 
| 
       78 
     | 
    
         
            -
              tm = [Tt] [Mm] ;
         
     | 
| 
       79 
     | 
    
         
            -
              trademark = " "? ( "[" tm "]" | "(" tm ")" ) ;
         
     | 
| 
       80 
     | 
    
         
            -
              reg = [Rr] ;
         
     | 
| 
       81 
     | 
    
         
            -
              registered = " "? ( "[" reg "]" | "(" reg ")" ) ;
         
     | 
| 
       82 
     | 
    
         
            -
              cee = [Cc] ;
         
     | 
| 
       83 
     | 
    
         
            -
              copyright = ( "[" cee "]" | "(" cee ")" ) ;
         
     | 
| 
       84 
     | 
    
         
            -
              entity = ( "&" %A ( '#' digit+ | ( alpha ( alpha | digit )+ ) ) %T ';' ) >X ;
         
     | 
| 
       85 
     | 
    
         
            -
              
         
     | 
| 
       86 
     | 
    
         
            -
              # info
         
     | 
| 
       87 
     | 
    
         
            -
              redcloth_version = "[RedCloth::VERSION]" ;
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
              other_phrase = phrase -- dim_noactions;
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
              code_tag := |*
         
     | 
| 
       92 
     | 
    
         
            -
                code_tag_end { CAT(block); fgoto main; };
         
     | 
| 
       93 
     | 
    
         
            -
                default => esc_pre;
         
     | 
| 
       94 
     | 
    
         
            -
              *|;
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
              main := |*
         
     | 
| 
       97 
     | 
    
         
            -
                
         
     | 
| 
       98 
     | 
    
         
            -
                image { PARSE_IMAGE_ATTR("src"); INLINE(block, "image"); };
         
     | 
| 
       99 
     | 
    
         
            -
                bracketed_image { PARSE_IMAGE_ATTR("src"); INLINE(block, "image"); };
         
     | 
| 
       100 
     | 
    
         
            -
                
         
     | 
| 
       101 
     | 
    
         
            -
                link { PARSE_LINK_ATTR("name"); PASS(block, "name", "link"); };
         
     | 
| 
       102 
     | 
    
         
            -
                bracketed_link { PARSE_LINK_ATTR("name"); PASS(block, "name", "link"); };
         
     | 
| 
       103 
     | 
    
         
            -
                
         
     | 
| 
       104 
     | 
    
         
            -
                code { PARSE_ATTR("text"); PASS_CODE(block, "text", "code", opts); };
         
     | 
| 
       105 
     | 
    
         
            -
                code_tag_start { CAT(block); fgoto code_tag; };
         
     | 
| 
       106 
     | 
    
         
            -
                notextile { INLINE(block, "notextile"); };
         
     | 
| 
       107 
     | 
    
         
            -
                strong { PARSE_ATTR("text"); PASS(block, "text", "strong"); };
         
     | 
| 
       108 
     | 
    
         
            -
                b { PARSE_ATTR("text"); PASS(block, "text", "b"); };
         
     | 
| 
       109 
     | 
    
         
            -
                em { PARSE_ATTR("text"); PASS(block, "text", "em"); };
         
     | 
| 
       110 
     | 
    
         
            -
                i { PARSE_ATTR("text"); PASS(block, "text", "i"); };
         
     | 
| 
       111 
     | 
    
         
            -
                del { PASS(block, "text", "del"); };
         
     | 
| 
       112 
     | 
    
         
            -
                del_phrase { PASS(block, "text", "del_phrase"); };
         
     | 
| 
       113 
     | 
    
         
            -
                ins { PARSE_ATTR("text"); PASS(block, "text", "ins"); };
         
     | 
| 
       114 
     | 
    
         
            -
                sup { PARSE_ATTR("text"); PASS(block, "text", "sup"); };
         
     | 
| 
       115 
     | 
    
         
            -
                sup_phrase { PARSE_ATTR("text"); PASS(block, "text", "sup_phrase"); };
         
     | 
| 
       116 
     | 
    
         
            -
                sub { PARSE_ATTR("text"); PASS(block, "text", "sub"); };
         
     | 
| 
       117 
     | 
    
         
            -
                sub_phrase { PARSE_ATTR("text"); PASS(block, "text", "sub_phrase"); };
         
     | 
| 
       118 
     | 
    
         
            -
                span { PARSE_ATTR("text"); PASS(block, "text", "span"); };
         
     | 
| 
       119 
     | 
    
         
            -
                span_phrase { PARSE_ATTR("text"); PASS(block, "text", "span_phrase"); };
         
     | 
| 
       120 
     | 
    
         
            -
                cite { PARSE_ATTR("text"); PASS(block, "text", "cite"); };
         
     | 
| 
       121 
     | 
    
         
            -
                ignore => ignore;
         
     | 
| 
       122 
     | 
    
         
            -
                snip { PASS(block, "text", "snip"); };
         
     | 
| 
       123 
     | 
    
         
            -
                quote1 { PASS(block, "text", "quote1"); };
         
     | 
| 
       124 
     | 
    
         
            -
                quote2 { PASS(block, "text", "quote2"); };
         
     | 
| 
       125 
     | 
    
         
            -
                multi_paragraph_quote { PASS(block, "text", "multi_paragraph_quote"); };
         
     | 
| 
       126 
     | 
    
         
            -
                
         
     | 
| 
       127 
     | 
    
         
            -
                ellipsis { INLINE(block, "ellipsis"); };
         
     | 
| 
       128 
     | 
    
         
            -
                emdash { INLINE(block, "emdash"); };
         
     | 
| 
       129 
     | 
    
         
            -
                endash { INLINE(block, "endash"); };
         
     | 
| 
       130 
     | 
    
         
            -
                arrow { INLINE(block, "arrow"); };
         
     | 
| 
       131 
     | 
    
         
            -
                caps { INLINE(block, "caps"); };
         
     | 
| 
       132 
     | 
    
         
            -
                acronym { INLINE(block, "acronym"); };
         
     | 
| 
       133 
     | 
    
         
            -
                dim { INLINE(block, "dim"); };
         
     | 
| 
       134 
     | 
    
         
            -
                trademark { INLINE(block, "trademark"); };
         
     | 
| 
       135 
     | 
    
         
            -
                registered { INLINE(block, "registered"); };
         
     | 
| 
       136 
     | 
    
         
            -
                copyright { INLINE(block, "copyright"); };
         
     | 
| 
       137 
     | 
    
         
            -
                footno { PASS(block, "text", "footno"); };
         
     | 
| 
       138 
     | 
    
         
            -
                entity { INLINE(block, "entity"); };
         
     | 
| 
       139 
     | 
    
         
            -
                
         
     | 
| 
       140 
     | 
    
         
            -
                script_tag { INLINE(block, "inline_html"); };
         
     | 
| 
       141 
     | 
    
         
            -
                start_tag { INLINE(block, "inline_html"); };
         
     | 
| 
       142 
     | 
    
         
            -
                end_tag { INLINE(block, "inline_html"); };
         
     | 
| 
       143 
     | 
    
         
            -
                empty_tag { INLINE(block, "inline_html"); };
         
     | 
| 
       144 
     | 
    
         
            -
                html_comment { INLINE(block, "inline_html"); };
         
     | 
| 
       145 
     | 
    
         
            -
                
         
     | 
| 
       146 
     | 
    
         
            -
                redcloth_version { INLINE(block, "inline_redcloth_version"); };
         
     | 
| 
       147 
     | 
    
         
            -
                
         
     | 
| 
       148 
     | 
    
         
            -
                other_phrase => esc;
         
     | 
| 
       149 
     | 
    
         
            -
                PUNCT => esc;
         
     | 
| 
       150 
     | 
    
         
            -
                space => esc;
         
     | 
| 
       151 
     | 
    
         
            -
                
         
     | 
| 
       152 
     | 
    
         
            -
                EOF;
         
     | 
| 
       153 
     | 
    
         
            -
                
         
     | 
| 
       154 
     | 
    
         
            -
              *|;
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
            }%%;
         
     | 
| 
         @@ -1,228 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            /*
         
     | 
| 
       2 
     | 
    
         
            -
             * redcloth_scan.c.rl
         
     | 
| 
       3 
     | 
    
         
            -
             *
         
     | 
| 
       4 
     | 
    
         
            -
             * Copyright (C) 2009 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 = 0;
         
     | 
| 
       35 
     | 
    
         
            -
              char *ts = NULL, *te = NULL, *reg = NULL, *bck = NULL, *eof = NULL;
         
     | 
| 
       36 
     | 
    
         
            -
              VALUE html = STR_NEW2("");
         
     | 
| 
       37 
     | 
    
         
            -
              VALUE table = STR_NEW2("");
         
     | 
| 
       38 
     | 
    
         
            -
              VALUE block = 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 = 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 Qnil;
         
     | 
| 
       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 = 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 Qnil;
         
     | 
| 
       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")), 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 
     | 
    
         
            -
            /*
         
     | 
| 
       198 
     | 
    
         
            -
             * Transforms a Textile document with +formatter+
         
     | 
| 
       199 
     | 
    
         
            -
             */
         
     | 
| 
       200 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       201 
     | 
    
         
            -
            redcloth_to(self, formatter)
         
     | 
| 
       202 
     | 
    
         
            -
              VALUE self, formatter;
         
     | 
| 
       203 
     | 
    
         
            -
            {
         
     | 
| 
       204 
     | 
    
         
            -
              rb_funcall(self, rb_intern("delete!"), 1, STR_NEW2("\r"));
         
     | 
| 
       205 
     | 
    
         
            -
              VALUE working_copy = rb_obj_clone(self);
         
     | 
| 
       206 
     | 
    
         
            -
              rb_extend_object(working_copy, formatter);
         
     | 
| 
       207 
     | 
    
         
            -
              
         
     | 
| 
       208 
     | 
    
         
            -
              if (rb_funcall(working_copy, rb_intern("lite_mode"), 0) == Qtrue) {
         
     | 
| 
       209 
     | 
    
         
            -
                return redcloth_inline2(working_copy, self, rb_hash_new());
         
     | 
| 
       210 
     | 
    
         
            -
              } else {
         
     | 
| 
       211 
     | 
    
         
            -
                return redcloth_transform2(working_copy, self);
         
     | 
| 
       212 
     | 
    
         
            -
              }
         
     | 
| 
       213 
     | 
    
         
            -
            }
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
            void Init_redcloth_scan()
         
     | 
| 
       216 
     | 
    
         
            -
            {
         
     | 
| 
       217 
     | 
    
         
            -
              mRedCloth = rb_define_module("RedCloth");
         
     | 
| 
       218 
     | 
    
         
            -
              /* A Textile document that can be converted to other formats. See
         
     | 
| 
       219 
     | 
    
         
            -
               the README for Textile syntax. */
         
     | 
| 
       220 
     | 
    
         
            -
              super_RedCloth = rb_define_class_under(mRedCloth, "TextileDoc", rb_cString);
         
     | 
| 
       221 
     | 
    
         
            -
              rb_define_method(super_RedCloth, "to", redcloth_to, 1);
         
     | 
| 
       222 
     | 
    
         
            -
              super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException);
         
     | 
| 
       223 
     | 
    
         
            -
              /* Escaping */
         
     | 
| 
       224 
     | 
    
         
            -
              rb_define_method(super_RedCloth, "html_esc", redcloth_html_esc, -1);
         
     | 
| 
       225 
     | 
    
         
            -
              rb_define_method(super_RedCloth, "latex_esc", redcloth_latex_esc, 1);
         
     | 
| 
       226 
     | 
    
         
            -
              SYM_escape_preformatted   = ID2SYM(rb_intern("html_escape_preformatted"));
         
     | 
| 
       227 
     | 
    
         
            -
              SYM_escape_attributes     = ID2SYM(rb_intern("html_escape_attributes"));
         
     | 
| 
       228 
     | 
    
         
            -
            }
         
     |