RedCloth 4.0.4-x86-mswin32-60 → 4.1.0-x86-mswin32-60
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 +18 -5
- data/Manifest +57 -0
- data/Rakefile +141 -173
- data/RedCloth.gemspec +37 -0
- data/{extras → ext}/mingw-rbconfig.rb +0 -0
- data/ext/redcloth_scan/redcloth.h +27 -20
- data/ext/redcloth_scan/redcloth_attributes.c.rl +56 -0
- data/ext/redcloth_scan/redcloth_attributes.java.rl +96 -0
- data/ext/redcloth_scan/redcloth_attributes.rl +6 -51
- data/ext/redcloth_scan/redcloth_common.c.rl +18 -0
- data/ext/redcloth_scan/redcloth_common.java.rl +18 -0
- data/ext/redcloth_scan/redcloth_common.rl +17 -27
- data/ext/redcloth_scan/redcloth_inline.c.rl +159 -0
- data/ext/redcloth_scan/redcloth_inline.java.rl +108 -0
- data/ext/redcloth_scan/redcloth_inline.rl +49 -198
- data/ext/redcloth_scan/redcloth_scan.c.rl +230 -0
- data/ext/redcloth_scan/redcloth_scan.java.rl +555 -0
- data/ext/redcloth_scan/redcloth_scan.rl +66 -282
- data/lib/redcloth.rb +6 -0
- data/lib/redcloth/erb_extension.rb +27 -0
- data/lib/redcloth/version.rb +2 -2
- data/lib/redcloth_scan.so +0 -0
- data/setup.rb +1585 -0
- data/test/basic.yml +3 -4
- data/test/code.yml +28 -2
- data/test/test_erb.rb +13 -0
- metadata +76 -43
- data/ext/redcloth_scan/redcloth_attributes.c +0 -650
- data/ext/redcloth_scan/redcloth_inline.c +0 -10494
- data/ext/redcloth_scan/redcloth_scan.c +0 -11254
- data/lib/redcloth_scan.bundle +0 -0
| @@ -3,39 +3,28 @@ | |
| 3 3 | 
             
             *
         | 
| 4 4 | 
             
             * Copyright (C) 2008 Jason Garber
         | 
| 5 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 6 | 
             
            %%{
         | 
| 15 7 |  | 
| 16 8 | 
             
              machine redcloth_scan;
         | 
| 17 | 
            -
              include redcloth_common "redcloth_common.rl";
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              action extend { extend = rb_hash_aref(regs, ID2SYM(rb_intern("type"))); }
         | 
| 20 9 |  | 
| 21 10 | 
             
              # blocks
         | 
| 22 11 | 
             
              notextile_tag_start = "<notextile>" ;
         | 
| 23 12 | 
             
              notextile_tag_end = "</notextile>" LF? ;
         | 
| 24 13 | 
             
              noparagraph_line_start = " "+ ;
         | 
| 25 | 
            -
              notextile_block_start = ( "notextile" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 14 | 
            +
              notextile_block_start = ( "notextile" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 26 15 | 
             
              pre_tag_start = "<pre" [^>]* ">" (space* "<code>")? ;
         | 
| 27 16 | 
             
              pre_tag_end = ("</code>" space*)? "</pre>" LF? ;
         | 
| 28 | 
            -
              pre_block_start = ( "pre" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 29 | 
            -
              bc_start = ( "bc" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 30 | 
            -
              bq_start = ( "bq" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) ( ":" %A uri %{ STORE(cite) } )? " "+ ) ;
         | 
| 17 | 
            +
              pre_block_start = ( "pre" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 18 | 
            +
              bc_start = ( "bc" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
         | 
| 19 | 
            +
              bq_start = ( "bq" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) ( ":" %A uri %{ STORE("cite"); } )? " "+ ) ;
         | 
| 31 20 | 
             
              non_ac_btype = ( "bq" | "bc" | "pre" | "notextile" );
         | 
| 32 21 | 
             
              btype = (alpha alnum*) -- (non_ac_btype | "fn" digit+);
         | 
| 33 | 
            -
              block_start = ( btype >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) >B %{ STORE_B(fallback) };
         | 
| 22 | 
            +
              block_start = ( btype >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) >B %{ STORE_B("fallback"); };
         | 
| 34 23 | 
             
              all_btypes = btype | non_ac_btype;
         | 
| 35 24 | 
             
              next_block_start = ( all_btypes A_noactions C_noactions :> "."+ " " ) >A @{ p = reg - 1; } ;
         | 
| 36 25 | 
             
              double_return = LF{2,} ;
         | 
| 37 26 | 
             
              block_end = ( double_return | EOF );
         | 
| 38 | 
            -
              ftype = ( "fn" >A %{ STORE(type) } digit+ >A %{ STORE(id) } ) ;
         | 
| 27 | 
            +
              ftype = ( "fn" >A %{ STORE("type"); } digit+ >A %{ STORE("id"); } ) ;
         | 
| 39 28 | 
             
              footnote_start = ( ftype A C :> dotspace ) ;
         | 
| 40 29 | 
             
              ul = "*" %{nest++; list_type = "ul";};
         | 
| 41 30 | 
             
              ol = "#" %{nest++; list_type = "ol";};
         | 
| @@ -44,14 +33,14 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 44 33 | 
             
              list_start  = ( ul_start | ol_start ) >{nest = 0;} ;
         | 
| 45 34 | 
             
              dt_start = "-" . " "+ ;
         | 
| 46 35 | 
             
              dd_start = ":=" ;
         | 
| 47 | 
            -
              long_dd  = dd_start " "* LF %{ ADD_BLOCK(); ASET(type, dd); } any+ >A %{ TRANSFORM(text) } :>> "=:" ;
         | 
| 36 | 
            +
              long_dd  = dd_start " "* LF %{ ADD_BLOCK(); ASET("type", "dd"); } any+ >A %{ TRANSFORM("text"); } :>> "=:" ;
         | 
| 48 37 | 
             
              dl_start = (dt_start mtext (LF dt_start mtext)* " "* dd_start)  ;
         | 
| 49 38 | 
             
              blank_line = LF;
         | 
| 50 | 
            -
              link_alias = ( "[" >{ ASET(type, ignore) } %A chars %T "]" %A uri %{ STORE_URL(href); } ) ;
         | 
| 39 | 
            +
              link_alias = ( "[" >{ ASET("type", "ignore"); } %A chars %T "]" %A uri %{ STORE_URL("href"); } ) ;
         | 
| 51 40 |  | 
| 52 41 | 
             
              # image lookahead
         | 
| 53 | 
            -
              IMG_A_LEFT = "<" %{ ASET(float, left) } ;
         | 
| 54 | 
            -
              IMG_A_RIGHT = ">" %{ ASET(float, right) } ;
         | 
| 42 | 
            +
              IMG_A_LEFT = "<" %{ ASET("float", "left"); } ;
         | 
| 43 | 
            +
              IMG_A_RIGHT = ">" %{ ASET("float", "right"); } ;
         | 
| 55 44 | 
             
              aligned_image = ( "["? "!" (IMG_A_LEFT | IMG_A_RIGHT) ) >A @{ p = reg - 1; } ;
         | 
| 56 45 |  | 
| 57 46 | 
             
              # html blocks
         | 
| @@ -59,24 +48,24 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 59 48 | 
             
              block_start_tag = "<" BlockTagName space+ AttrSet* (AttrEnd)? ">" | "<" BlockTagName ">";
         | 
| 60 49 | 
             
              block_empty_tag = "<" BlockTagName space+ AttrSet* (AttrEnd)? "/>" | "<" BlockTagName "/>" ;
         | 
| 61 50 | 
             
              block_end_tag = "</" BlockTagName space* ">" ;
         | 
| 62 | 
            -
              html_start = indent >B %{STORE_B(indent_before_start)} block_start_tag >B %{STORE_B(start_tag)}  indent >B %{STORE_B(indent_after_start)} ;
         | 
| 63 | 
            -
              html_end = indent >B %{STORE_B(indent_before_end)} block_end_tag >B %{STORE_B(end_tag)} (indent LF?) >B %{STORE_B(indent_after_end)} ;
         | 
| 64 | 
            -
              standalone_html = indent (block_start_tag | block_empty_tag | block_end_tag) indent LF | 
| 51 | 
            +
              html_start = indent >B %{STORE_B("indent_before_start");} block_start_tag >B %{STORE_B("start_tag");}  indent >B %{STORE_B("indent_after_start");} ;
         | 
| 52 | 
            +
              html_end = indent >B %{STORE_B("indent_before_end");} block_end_tag >B %{STORE_B("end_tag");} (indent LF?) >B %{STORE_B("indent_after_end");} ;
         | 
| 53 | 
            +
              standalone_html = indent (block_start_tag | block_empty_tag | block_end_tag) indent (LF+ | EOF);
         | 
| 65 54 | 
             
              html_end_terminating_block = ( LF indent block_end_tag ) >A @{ p = reg - 1; } ;
         | 
| 66 55 |  | 
| 67 56 | 
             
              # tables
         | 
| 68 57 | 
             
              para = ( default+ ) -- LF ;
         | 
| 69 58 | 
             
              btext = para ( LF{2} )? ;
         | 
| 70 59 | 
             
              tddef = ( D? S A C :> dotspace ) ;
         | 
| 71 | 
            -
              td = ( tddef? btext >A %T :> "|" >{PASS(table, text, td);} ) >X ;
         | 
| 60 | 
            +
              td = ( tddef? btext >A %T :> "|" >{PASS(table, "text", "td");} ) >X ;
         | 
| 72 61 | 
             
              trdef = ( A C :> dotspace ) ;
         | 
| 73 | 
            -
              tr = ( trdef? "|" %{INLINE(table, tr_open);} td+ ) >X %{INLINE(table, tr_close);} ;
         | 
| 62 | 
            +
              tr = ( trdef? "|" %{INLINE(table, "tr_open");} td+ ) >X %{INLINE(table, "tr_close");} ;
         | 
| 74 63 | 
             
              trows = ( tr (LF >X tr)* ) ;
         | 
| 75 64 | 
             
              tdef = ( "table" >X A C :> dotspace LF ) ;
         | 
| 76 | 
            -
              table = ( tdef? trows >{table | 
| 65 | 
            +
              table = ( tdef? trows >{CLEAR(table); INLINE(table, "table_open"); RESET_REG();} ) ;
         | 
| 77 66 |  | 
| 78 67 | 
             
              # info
         | 
| 79 | 
            -
              redcloth_version = ("RedCloth" >A ("::" | " " ) "VERSION"i ":"? " ")? %{STORE(prefix)} "RedCloth::VERSION" (LF* EOF | double_return) ;
         | 
| 68 | 
            +
              redcloth_version = ("RedCloth" >A ("::" | " " ) "VERSION"i ":"? " ")? %{STORE("prefix");} "RedCloth::VERSION" (LF* EOF | double_return) ;
         | 
| 80 69 |  | 
| 81 70 | 
             
              pre_tag := |*
         | 
| 82 71 | 
             
                pre_tag_end         { CAT(block); DONE(block); fgoto main; };
         | 
| @@ -89,7 +78,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 89 78 | 
             
                  fgoto main; 
         | 
| 90 79 | 
             
                };
         | 
| 91 80 | 
             
                double_return { 
         | 
| 92 | 
            -
                  if ( | 
| 81 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 93 82 | 
             
                    ADD_BLOCKCODE(); 
         | 
| 94 83 | 
             
                    fgoto main; 
         | 
| 95 84 | 
             
                  } else { 
         | 
| @@ -97,7 +86,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 97 86 | 
             
                  } 
         | 
| 98 87 | 
             
                };
         | 
| 99 88 | 
             
                double_return next_block_start { 
         | 
| 100 | 
            -
                  if ( | 
| 89 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 101 90 | 
             
                    ADD_BLOCKCODE(); 
         | 
| 102 91 | 
             
                    fgoto main; 
         | 
| 103 92 | 
             
                  } else { 
         | 
| @@ -110,8 +99,8 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 110 99 | 
             
              *|;
         | 
| 111 100 |  | 
| 112 101 | 
             
              script_tag := |*
         | 
| 113 | 
            -
                script_tag_end   { CAT(block); ASET(type, ignore); ADD_BLOCK(); fgoto main; };
         | 
| 114 | 
            -
                EOF              { ASET(type, ignore); ADD_BLOCK(); fgoto main; };
         | 
| 102 | 
            +
                script_tag_end   { CAT(block); ASET("type", "ignore"); ADD_BLOCK(); fgoto main; };
         | 
| 103 | 
            +
                EOF              { ASET("type", "ignore"); ADD_BLOCK(); fgoto main; };
         | 
| 115 104 | 
             
                default => cat;
         | 
| 116 105 | 
             
              *|;
         | 
| 117 106 |  | 
| @@ -131,7 +120,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 131 120 | 
             
                  fgoto main;
         | 
| 132 121 | 
             
                };
         | 
| 133 122 | 
             
                double_return {
         | 
| 134 | 
            -
                  if ( | 
| 123 | 
            +
                  if (IS_NOT_EXTENDED()) {
         | 
| 135 124 | 
             
                    ADD_BLOCK();
         | 
| 136 125 | 
             
                    CAT(html);
         | 
| 137 126 | 
             
                    fgoto main;
         | 
| @@ -142,7 +131,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 142 131 | 
             
                  }
         | 
| 143 132 | 
             
                };
         | 
| 144 133 | 
             
                double_return next_block_start {
         | 
| 145 | 
            -
                  if ( | 
| 134 | 
            +
                  if (IS_NOT_EXTENDED()) {
         | 
| 146 135 | 
             
                    ADD_BLOCK();
         | 
| 147 136 | 
             
                    CAT(html);
         | 
| 148 137 | 
             
                    fgoto main;
         | 
| @@ -164,15 +153,15 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 164 153 | 
             
              bc := |*
         | 
| 165 154 | 
             
                EOF { 
         | 
| 166 155 | 
             
                  ADD_BLOCKCODE(); 
         | 
| 167 | 
            -
                  INLINE(html, bc_close); 
         | 
| 168 | 
            -
                   | 
| 156 | 
            +
                  INLINE(html, "bc_close"); 
         | 
| 157 | 
            +
                  SET_PLAIN_BLOCK("p");
         | 
| 169 158 | 
             
                  fgoto main;
         | 
| 170 159 | 
             
                };
         | 
| 171 160 | 
             
                double_return { 
         | 
| 172 | 
            -
                  if ( | 
| 161 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 173 162 | 
             
                    ADD_BLOCKCODE(); 
         | 
| 174 | 
            -
                    INLINE(html, bc_close); 
         | 
| 175 | 
            -
                     | 
| 163 | 
            +
                    INLINE(html, "bc_close"); 
         | 
| 164 | 
            +
                    SET_PLAIN_BLOCK("p");
         | 
| 176 165 | 
             
                    fgoto main; 
         | 
| 177 166 | 
             
                  } else { 
         | 
| 178 167 | 
             
                    ADD_EXTENDED_BLOCKCODE(); 
         | 
| @@ -180,16 +169,16 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 180 169 | 
             
                  } 
         | 
| 181 170 | 
             
                };
         | 
| 182 171 | 
             
                double_return next_block_start { 
         | 
| 183 | 
            -
                  if ( | 
| 172 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 184 173 | 
             
                    ADD_BLOCKCODE(); 
         | 
| 185 | 
            -
                    INLINE(html, bc_close); 
         | 
| 186 | 
            -
                     | 
| 174 | 
            +
                    INLINE(html, "bc_close"); 
         | 
| 175 | 
            +
                    SET_PLAIN_BLOCK("p");
         | 
| 187 176 | 
             
                    fgoto main; 
         | 
| 188 177 | 
             
                  } else { 
         | 
| 189 178 | 
             
                    ADD_EXTENDED_BLOCKCODE(); 
         | 
| 190 179 | 
             
                    CAT(html); 
         | 
| 191 | 
            -
                    INLINE(html, bc_close); 
         | 
| 192 | 
            -
                     | 
| 180 | 
            +
                    INLINE(html, "bc_close"); 
         | 
| 181 | 
            +
                    SET_PLAIN_BLOCK("p");
         | 
| 193 182 | 
             
                    END_EXTENDED(); 
         | 
| 194 183 | 
             
                    fgoto main; 
         | 
| 195 184 | 
             
                  } 
         | 
| @@ -200,38 +189,38 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 200 189 | 
             
              bq := |*
         | 
| 201 190 | 
             
                EOF { 
         | 
| 202 191 | 
             
                  ADD_BLOCK(); 
         | 
| 203 | 
            -
                  INLINE(html, bq_close); 
         | 
| 192 | 
            +
                  INLINE(html, "bq_close"); 
         | 
| 204 193 | 
             
                  fgoto main; 
         | 
| 205 194 | 
             
                };
         | 
| 206 195 | 
             
                double_return { 
         | 
| 207 | 
            -
                  if ( | 
| 196 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 208 197 | 
             
                    ADD_BLOCK(); 
         | 
| 209 | 
            -
                    INLINE(html, bq_close); 
         | 
| 198 | 
            +
                    INLINE(html, "bq_close"); 
         | 
| 210 199 | 
             
                    fgoto main; 
         | 
| 211 200 | 
             
                  } else { 
         | 
| 212 201 | 
             
                    ADD_EXTENDED_BLOCK(); 
         | 
| 213 202 | 
             
                  } 
         | 
| 214 203 | 
             
                };
         | 
| 215 204 | 
             
                double_return next_block_start { 
         | 
| 216 | 
            -
                  if ( | 
| 205 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 217 206 | 
             
                    ADD_BLOCK(); 
         | 
| 218 | 
            -
                    INLINE(html, bq_close); 
         | 
| 207 | 
            +
                    INLINE(html, "bq_close"); 
         | 
| 219 208 | 
             
                    fgoto main; 
         | 
| 220 209 | 
             
                  } else {
         | 
| 221 210 | 
             
                    ADD_EXTENDED_BLOCK(); 
         | 
| 222 | 
            -
                    INLINE(html, bq_close); 
         | 
| 211 | 
            +
                    INLINE(html, "bq_close"); 
         | 
| 223 212 | 
             
                    END_EXTENDED(); 
         | 
| 224 213 | 
             
                    fgoto main; 
         | 
| 225 214 | 
             
                  }
         | 
| 226 215 | 
             
                };
         | 
| 227 216 | 
             
                html_end_terminating_block { 
         | 
| 228 | 
            -
                    if ( | 
| 217 | 
            +
                    if (IS_NOT_EXTENDED()) { 
         | 
| 229 218 | 
             
                      ADD_BLOCK(); 
         | 
| 230 | 
            -
                      INLINE(html, bq_close); 
         | 
| 219 | 
            +
                      INLINE(html, "bq_close"); 
         | 
| 231 220 | 
             
                      fgoto main; 
         | 
| 232 221 | 
             
                    } else {
         | 
| 233 222 | 
             
                      ADD_EXTENDED_BLOCK(); 
         | 
| 234 | 
            -
                      INLINE(html, bq_close); 
         | 
| 223 | 
            +
                      INLINE(html, "bq_close"); 
         | 
| 235 224 | 
             
                      END_EXTENDED(); 
         | 
| 236 225 | 
             
                      fgoto main; 
         | 
| 237 226 | 
             
                    }
         | 
| @@ -245,7 +234,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 245 234 | 
             
                  fgoto main;
         | 
| 246 235 | 
             
                };
         | 
| 247 236 | 
             
                double_return {
         | 
| 248 | 
            -
                  if ( | 
| 237 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 249 238 | 
             
                    ADD_BLOCK(); 
         | 
| 250 239 | 
             
                    fgoto main; 
         | 
| 251 240 | 
             
                  } else { 
         | 
| @@ -253,7 +242,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 253 242 | 
             
                  } 
         | 
| 254 243 | 
             
                };
         | 
| 255 244 | 
             
                double_return next_block_start { 
         | 
| 256 | 
            -
                  if ( | 
| 245 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 257 246 | 
             
                    ADD_BLOCK(); 
         | 
| 258 247 | 
             
                    fgoto main; 
         | 
| 259 248 | 
             
                  } else { 
         | 
| @@ -263,7 +252,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 263 252 | 
             
                  }      
         | 
| 264 253 | 
             
                };
         | 
| 265 254 | 
             
                html_end_terminating_block { 
         | 
| 266 | 
            -
                  if ( | 
| 255 | 
            +
                  if (IS_NOT_EXTENDED()) { 
         | 
| 267 256 | 
             
                    ADD_BLOCK(); 
         | 
| 268 257 | 
             
                    fgoto main; 
         | 
| 269 258 | 
             
                  } else { 
         | 
| @@ -274,7 +263,7 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 274 263 | 
             
                };
         | 
| 275 264 | 
             
                LF list_start { 
         | 
| 276 265 | 
             
                  ADD_BLOCK(); 
         | 
| 277 | 
            -
                   | 
| 266 | 
            +
                  CLEAR_LIST(); 
         | 
| 278 267 | 
             
                  LIST_ITEM(); 
         | 
| 279 268 | 
             
                  fgoto list; 
         | 
| 280 269 | 
             
                };
         | 
| @@ -294,246 +283,41 @@ int SYM_escape_preformatted, SYM_escape_attributes; | |
| 294 283 | 
             
              *|;
         | 
| 295 284 |  | 
| 296 285 | 
             
              dl := |*
         | 
| 297 | 
            -
                LF dt_start     { ADD_BLOCK(); ASET(type, dt); };
         | 
| 298 | 
            -
                dd_start        { ADD_BLOCK(); ASET(type, dd); };
         | 
| 299 | 
            -
                long_dd         { INLINE(html, dd); CLEAR_REGS(); };
         | 
| 300 | 
            -
                block_end       { ADD_BLOCK(); INLINE(html, dl_close);  fgoto main; };
         | 
| 286 | 
            +
                LF dt_start     { ADD_BLOCK(); ASET("type", "dt"); };
         | 
| 287 | 
            +
                dd_start        { ADD_BLOCK(); ASET("type", "dd"); };
         | 
| 288 | 
            +
                long_dd         { INLINE(html, "dd"); CLEAR_REGS(); };
         | 
| 289 | 
            +
                block_end       { ADD_BLOCK(); INLINE(html, "dl_close");  fgoto main; };
         | 
| 301 290 | 
             
                default => cat;
         | 
| 302 291 | 
             
              *|;
         | 
| 303 292 |  | 
| 304 293 | 
             
              main := |*
         | 
| 305 | 
            -
                noparagraph_line_start  { ASET(type, ignored_line); fgoto noparagraph_line; };
         | 
| 306 | 
            -
                notextile_tag_start { ASET(type, notextile); fgoto notextile_tag; };
         | 
| 307 | 
            -
                notextile_block_start { ASET(type, notextile); fgoto notextile_block; };
         | 
| 294 | 
            +
                noparagraph_line_start  { ASET("type", "ignored_line"); fgoto noparagraph_line; };
         | 
| 295 | 
            +
                notextile_tag_start { ASET("type", "notextile"); fgoto notextile_tag; };
         | 
| 296 | 
            +
                notextile_block_start { ASET("type", "notextile"); fgoto notextile_block; };
         | 
| 308 297 | 
             
                script_tag_start { CAT(block); fgoto script_tag; };
         | 
| 309 | 
            -
                pre_tag_start       { ASET(type, notextile); CAT(block); fgoto pre_tag; };
         | 
| 298 | 
            +
                pre_tag_start       { ASET("type", "notextile"); CAT(block); fgoto pre_tag; };
         | 
| 310 299 | 
             
                pre_block_start { fgoto pre_block; };
         | 
| 311 | 
            -
                standalone_html { ASET(type, html); CAT(block); ADD_BLOCK(); };
         | 
| 312 | 
            -
                html_start      { ASET(type, html_block); fgoto html; };
         | 
| 313 | 
            -
                bc_start        { INLINE(html, bc_open); ASET(type, code);  | 
| 314 | 
            -
                bq_start        { INLINE(html, bq_open); ASET(type, p); fgoto bq; };
         | 
| 300 | 
            +
                standalone_html { ASET("type", "html"); CAT(block); ADD_BLOCK(); };
         | 
| 301 | 
            +
                html_start      { ASET("type", "html_block"); fgoto html; };
         | 
| 302 | 
            +
                bc_start        { INLINE(html, "bc_open"); ASET("type", "code"); SET_PLAIN_BLOCK("code"); fgoto bc; };
         | 
| 303 | 
            +
                bq_start        { INLINE(html, "bq_open"); ASET("type", "p"); fgoto bq; };
         | 
| 315 304 | 
             
                block_start     { fgoto block; };
         | 
| 316 305 | 
             
                footnote_start  { fgoto footnote; };
         | 
| 317 | 
            -
                list_start      {  | 
| 318 | 
            -
                dl_start        { p = ts; INLINE(html, dl_open); ASET(type, dt); fgoto dl; };
         | 
| 319 | 
            -
                table           { INLINE(table, table_close); DONE(table); fgoto block; };
         | 
| 320 | 
            -
                link_alias      {  | 
| 321 | 
            -
                aligned_image   {  | 
| 322 | 
            -
                redcloth_version { INLINE(html, redcloth_version); };
         | 
| 306 | 
            +
                list_start      { CLEAR_LIST(); LIST_ITEM(); fgoto list; };
         | 
| 307 | 
            +
                dl_start        { p = ts; INLINE(html, "dl_open"); ASET("type", "dt"); fgoto dl; };
         | 
| 308 | 
            +
                table           { INLINE(table, "table_close"); DONE(table); fgoto block; };
         | 
| 309 | 
            +
                link_alias      { STORE_LINK_ALIAS(); DONE(block); };
         | 
| 310 | 
            +
                aligned_image   { RESET_TYPE(); fgoto block; };
         | 
| 311 | 
            +
                redcloth_version { INLINE(html, "redcloth_version"); };
         | 
| 323 312 | 
             
                blank_line => cat;
         | 
| 324 313 | 
             
                default
         | 
| 325 314 | 
             
                { 
         | 
| 326 315 | 
             
                  CLEAR_REGS();
         | 
| 327 | 
            -
                   | 
| 316 | 
            +
                  RESET_TYPE();
         | 
| 328 317 | 
             
                  CAT(block);
         | 
| 329 318 | 
             
                  fgoto block;
         | 
| 330 319 | 
             
                };
         | 
| 331 320 | 
             
                EOF;
         | 
| 332 321 | 
             
              *|;
         | 
| 333 322 |  | 
| 334 | 
            -
            } | 
| 335 | 
            -
             | 
| 336 | 
            -
            %% write data nofinal;
         | 
| 337 | 
            -
             | 
| 338 | 
            -
            VALUE
         | 
| 339 | 
            -
            redcloth_transform(self, p, pe, refs)
         | 
| 340 | 
            -
              VALUE self;
         | 
| 341 | 
            -
              char *p, *pe;
         | 
| 342 | 
            -
              VALUE refs;
         | 
| 343 | 
            -
            {
         | 
| 344 | 
            -
              char *orig_p = p, *orig_pe = pe;
         | 
| 345 | 
            -
              int cs, act, nest;
         | 
| 346 | 
            -
              char *ts = NULL, *te = NULL, *reg = NULL, *bck = NULL, *eof = NULL;
         | 
| 347 | 
            -
              VALUE html = rb_str_new2("");
         | 
| 348 | 
            -
              VALUE table = rb_str_new2("");
         | 
| 349 | 
            -
              VALUE block = rb_str_new2("");
         | 
| 350 | 
            -
              VALUE regs; CLEAR_REGS()
         | 
| 351 | 
            -
              
         | 
| 352 | 
            -
              
         | 
| 353 | 
            -
              VALUE list_layout = Qnil;
         | 
| 354 | 
            -
              char *list_type = NULL;
         | 
| 355 | 
            -
              VALUE list_index = rb_ary_new();
         | 
| 356 | 
            -
              int list_continue = 0;
         | 
| 357 | 
            -
              VALUE plain_block = rb_str_new2("p");
         | 
| 358 | 
            -
              VALUE extend = Qnil;
         | 
| 359 | 
            -
              char listm[10] = "";
         | 
| 360 | 
            -
              VALUE refs_found = rb_hash_new();
         | 
| 361 | 
            -
              
         | 
| 362 | 
            -
              %% write init;
         | 
| 363 | 
            -
             | 
| 364 | 
            -
              %% write exec;
         | 
| 365 | 
            -
             | 
| 366 | 
            -
              if (RSTRING_LEN(block) > 0)
         | 
| 367 | 
            -
              {
         | 
| 368 | 
            -
                ADD_BLOCK();
         | 
| 369 | 
            -
              }
         | 
| 370 | 
            -
             | 
| 371 | 
            -
              if ( NIL_P(refs) && rb_funcall(refs_found, rb_intern("empty?"), 0) == Qfalse ) {
         | 
| 372 | 
            -
                return redcloth_transform(self, orig_p, orig_pe, refs_found);
         | 
| 373 | 
            -
              } else {
         | 
| 374 | 
            -
                rb_funcall(self, rb_intern("after_transform"), 1, html);
         | 
| 375 | 
            -
                return html;
         | 
| 376 | 
            -
              }
         | 
| 377 | 
            -
            }
         | 
| 378 | 
            -
             | 
| 379 | 
            -
            VALUE
         | 
| 380 | 
            -
            redcloth_transform2(self, str)
         | 
| 381 | 
            -
              VALUE self, str;
         | 
| 382 | 
            -
            {
         | 
| 383 | 
            -
              rb_str_cat2(str, "\n");
         | 
| 384 | 
            -
              StringValue(str);
         | 
| 385 | 
            -
              rb_funcall(self, rb_intern("before_transform"), 1, str);
         | 
| 386 | 
            -
              return redcloth_transform(self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1, Qnil);
         | 
| 387 | 
            -
            }
         | 
| 388 | 
            -
             | 
| 389 | 
            -
            /*
         | 
| 390 | 
            -
             * Converts special characters into HTML entities.
         | 
| 391 | 
            -
             */
         | 
| 392 | 
            -
            static VALUE
         | 
| 393 | 
            -
            redcloth_html_esc(int argc, VALUE* argv, VALUE self) //(self, str, level)
         | 
| 394 | 
            -
            {
         | 
| 395 | 
            -
              VALUE str, level;
         | 
| 396 | 
            -
              
         | 
| 397 | 
            -
              rb_scan_args(argc, argv, "11", &str, &level);
         | 
| 398 | 
            -
              
         | 
| 399 | 
            -
              VALUE new_str = rb_str_new2("");
         | 
| 400 | 
            -
              if (str == Qnil)
         | 
| 401 | 
            -
                return new_str;
         | 
| 402 | 
            -
                
         | 
| 403 | 
            -
              StringValue(str);
         | 
| 404 | 
            -
              
         | 
| 405 | 
            -
              if (RSTRING_LEN(str) == 0)
         | 
| 406 | 
            -
                return new_str;
         | 
| 407 | 
            -
              
         | 
| 408 | 
            -
              char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
         | 
| 409 | 
            -
              char *t = ts, *t2 = ts, *ch = NULL;
         | 
| 410 | 
            -
              if (te <= ts) return;
         | 
| 411 | 
            -
             | 
| 412 | 
            -
              while (t2 < te) {
         | 
| 413 | 
            -
                ch = NULL;
         | 
| 414 | 
            -
                
         | 
| 415 | 
            -
                // normal + pre
         | 
| 416 | 
            -
                switch (*t2)
         | 
| 417 | 
            -
                {
         | 
| 418 | 
            -
                  case '&':  ch = "amp";    break;
         | 
| 419 | 
            -
                  case '>':  ch = "gt";     break;
         | 
| 420 | 
            -
                  case '<':  ch = "lt";     break;
         | 
| 421 | 
            -
                }
         | 
| 422 | 
            -
                
         | 
| 423 | 
            -
                // normal (non-pre)
         | 
| 424 | 
            -
                if (level != SYM_escape_preformatted) {
         | 
| 425 | 
            -
                  switch (*t2)
         | 
| 426 | 
            -
                  {
         | 
| 427 | 
            -
                    case '\n': ch = "br";     break;
         | 
| 428 | 
            -
                    case '"' : ch = "quot";   break;
         | 
| 429 | 
            -
                    case '\'': 
         | 
| 430 | 
            -
                      ch = (level == SYM_escape_attributes) ? "apos" : "squot";
         | 
| 431 | 
            -
                      break;
         | 
| 432 | 
            -
                  }
         | 
| 433 | 
            -
                }
         | 
| 434 | 
            -
                
         | 
| 435 | 
            -
                if (ch != NULL)
         | 
| 436 | 
            -
                {
         | 
| 437 | 
            -
                  if (t2 > t)
         | 
| 438 | 
            -
                    rb_str_cat(new_str, t, t2-t);
         | 
| 439 | 
            -
                  rb_str_concat(new_str, rb_funcall(self, rb_intern(ch), 1, rb_hash_new()));
         | 
| 440 | 
            -
                  t = t2 + 1;
         | 
| 441 | 
            -
                }
         | 
| 442 | 
            -
             | 
| 443 | 
            -
                t2++;
         | 
| 444 | 
            -
              }
         | 
| 445 | 
            -
              if (t2 > t)
         | 
| 446 | 
            -
                rb_str_cat(new_str, t, t2-t);
         | 
| 447 | 
            -
              
         | 
| 448 | 
            -
              return new_str;
         | 
| 449 | 
            -
            }
         | 
| 450 | 
            -
             | 
| 451 | 
            -
            /*
         | 
| 452 | 
            -
             * Converts special characters into LaTeX entities.
         | 
| 453 | 
            -
             */
         | 
| 454 | 
            -
            static VALUE
         | 
| 455 | 
            -
            redcloth_latex_esc(VALUE self, VALUE str)
         | 
| 456 | 
            -
            {  
         | 
| 457 | 
            -
              VALUE new_str = rb_str_new2("");
         | 
| 458 | 
            -
              
         | 
| 459 | 
            -
              if (str == Qnil)
         | 
| 460 | 
            -
                return new_str;
         | 
| 461 | 
            -
                
         | 
| 462 | 
            -
              StringValue(str);
         | 
| 463 | 
            -
              
         | 
| 464 | 
            -
              if (RSTRING_LEN(str) == 0)
         | 
| 465 | 
            -
                return new_str;
         | 
| 466 | 
            -
              
         | 
| 467 | 
            -
              char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
         | 
| 468 | 
            -
              char *t = ts, *t2 = ts, *ch = NULL;
         | 
| 469 | 
            -
              if (te <= ts) return;
         | 
| 470 | 
            -
             | 
| 471 | 
            -
              while (t2 < te) {
         | 
| 472 | 
            -
                ch = NULL;
         | 
| 473 | 
            -
                
         | 
| 474 | 
            -
                switch (*t2) 
         | 
| 475 | 
            -
                { 
         | 
| 476 | 
            -
                  case '{':  ch = "#123";   break;
         | 
| 477 | 
            -
                  case '}':  ch = "#125";   break;
         | 
| 478 | 
            -
                  case '\\': ch = "#92";    break;
         | 
| 479 | 
            -
                  case '#':  ch = "#35";    break;
         | 
| 480 | 
            -
                  case '$':  ch = "#36";    break;
         | 
| 481 | 
            -
                  case '%':  ch = "#37";    break;
         | 
| 482 | 
            -
                  case '&':  ch = "amp";    break;
         | 
| 483 | 
            -
                  case '_':  ch = "#95";    break;
         | 
| 484 | 
            -
                  case '^':  ch = "circ";   break;
         | 
| 485 | 
            -
                  case '~':  ch = "tilde";  break;
         | 
| 486 | 
            -
                  case '<':  ch = "lt";     break;
         | 
| 487 | 
            -
                  case '>':  ch = "gt";     break;
         | 
| 488 | 
            -
                  case '\n': ch = "#10";    break;
         | 
| 489 | 
            -
                }
         | 
| 490 | 
            -
             | 
| 491 | 
            -
                if (ch != NULL)
         | 
| 492 | 
            -
                {
         | 
| 493 | 
            -
                  if (t2 > t)
         | 
| 494 | 
            -
                    rb_str_cat(new_str, t, t2-t);
         | 
| 495 | 
            -
                  VALUE opts = rb_hash_new();
         | 
| 496 | 
            -
                  rb_hash_aset(opts, ID2SYM(rb_intern("text")), rb_str_new2(ch));
         | 
| 497 | 
            -
                  rb_str_concat(new_str, rb_funcall(self, rb_intern("entity"), 1, opts));
         | 
| 498 | 
            -
                  t = t2 + 1;
         | 
| 499 | 
            -
                }
         | 
| 500 | 
            -
             | 
| 501 | 
            -
                t2++;
         | 
| 502 | 
            -
              }
         | 
| 503 | 
            -
              if (t2 > t)
         | 
| 504 | 
            -
                rb_str_cat(new_str, t, t2-t);
         | 
| 505 | 
            -
              
         | 
| 506 | 
            -
              return new_str;
         | 
| 507 | 
            -
            }
         | 
| 508 | 
            -
             | 
| 509 | 
            -
            static VALUE
         | 
| 510 | 
            -
            redcloth_to(self, formatter)
         | 
| 511 | 
            -
              VALUE self, formatter;
         | 
| 512 | 
            -
            {
         | 
| 513 | 
            -
              char *pe, *p;
         | 
| 514 | 
            -
              int len = 0;
         | 
| 515 | 
            -
              
         | 
| 516 | 
            -
              rb_funcall(self, rb_intern("delete!"), 1, rb_str_new2("\r"));
         | 
| 517 | 
            -
              VALUE working_copy = rb_obj_clone(self);
         | 
| 518 | 
            -
              rb_extend_object(working_copy, formatter);
         | 
| 519 | 
            -
              if (rb_funcall(working_copy, rb_intern("lite_mode"), 0) == Qtrue) {
         | 
| 520 | 
            -
                return redcloth_inline2(working_copy, self, rb_hash_new());
         | 
| 521 | 
            -
              } else {
         | 
| 522 | 
            -
                return redcloth_transform2(working_copy, self);
         | 
| 523 | 
            -
              }
         | 
| 524 | 
            -
            }
         | 
| 525 | 
            -
             | 
| 526 | 
            -
            void Init_redcloth_scan()
         | 
| 527 | 
            -
            {
         | 
| 528 | 
            -
              mRedCloth = rb_define_module("RedCloth");
         | 
| 529 | 
            -
              /* A Textile document that can be converted to other formats. See
         | 
| 530 | 
            -
               the README for Textile syntax. */
         | 
| 531 | 
            -
              super_RedCloth = rb_define_class_under(mRedCloth, "TextileDoc", rb_cString);
         | 
| 532 | 
            -
              rb_define_method(super_RedCloth, "to", redcloth_to, 1);
         | 
| 533 | 
            -
              super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException);
         | 
| 534 | 
            -
              /* Escaping */
         | 
| 535 | 
            -
              rb_define_method(super_RedCloth, "html_esc", redcloth_html_esc, -1);
         | 
| 536 | 
            -
              rb_define_method(super_RedCloth, "latex_esc", redcloth_latex_esc, 1);
         | 
| 537 | 
            -
              SYM_escape_preformatted   = ID2SYM(rb_intern("html_escape_preformatted"));
         | 
| 538 | 
            -
              SYM_escape_attributes     = ID2SYM(rb_intern("html_escape_attributes"));
         | 
| 539 | 
            -
            }
         | 
| 323 | 
            +
            }%%;
         |