#line 1 "ragel/redcloth_attributes.c.rl" /* * redcloth_attributes.c.rl * * Copyright (C) 2009 Jason Garber */ #define RSTRING_NOT_MODIFIED #include #include "redcloth.h" #line 16 "ragel/redcloth_attributes.c.rl" #line 18 "ext/redcloth_scan/redcloth_attributes.c" static const char _redcloth_attributes_actions[] = { 0, 1, 2, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 10, 1, 11, 1, 13, 1, 14, 1, 17, 1, 18, 1, 23, 1, 24, 1, 25, 2, 2, 10, 2, 3, 16, 2, 9, 21, 2, 10, 22, 2, 11, 12, 2, 14, 0, 2, 14, 1, 2, 14, 2, 2, 14, 5, 2, 14, 6, 2, 14, 7, 2, 14, 8, 2, 14, 15, 2, 14, 19, 2, 14, 20, 3, 9, 10, 21, 3, 14, 0, 15, 3, 14, 0, 19, 3, 14, 1, 20, 3, 14, 2, 15, 3, 14, 2, 19, 3, 14, 2, 20 }; static const short _redcloth_attributes_key_offsets[] = { 0, 0, 6, 11, 27, 33, 38, 44, 60, 66, 71, 79, 85, 90, 94, 110, 116, 125, 134, 143, 153, 164, 172, 181, 188, 194, 199, 215, 220, 229, 233, 238, 243, 250, 256, 271, 285, 300, 310, 316, 331, 345, 360, 370, 377, 387, 398, 407, 416, 422, 437, 451, 466, 476, 483, 493, 504, 513, 522, 538, 554, 570, 580, 591, 600, 609, 612, 618, 633, 647, 662, 671, 681, 692, 701, 710 }; static const char _redcloth_attributes_trans_keys[] = { 0, 9, 10, 32, 11, 13, 0, 9, 32, 10, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 11, 13, 0, 9, 32, 10, 13, 0, 9, 10, 32, 11, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 11, 13, 13, 123, 125, 10, 11, 0, 32, 40, 46, 91, 123, 9, 13, 0, 9, 10, 32, 11, 13, 0, 9, 32, 10, 13, 0, 32, 9, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 32, 35, 45, 95, 48, 57, 65, 90, 97, 122, 32, 35, 41, 45, 95, 48, 57, 65, 90, 97, 122, 45, 95, 48, 57, 65, 90, 97, 122, 41, 45, 95, 48, 57, 65, 90, 97, 122, 0, 32, 40, 91, 123, 9, 13, 0, 9, 10, 32, 11, 13, 0, 9, 32, 10, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 13, 123, 125, 10, 11, 0, 9, 10, 12, 32, 123, 125, 11, 13, 45, 95, 97, 122, 45, 93, 95, 97, 122, 13, 123, 125, 10, 11, 0, 32, 40, 91, 123, 9, 13, 0, 9, 10, 32, 11, 13, 0, 9, 10, 32, 35, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 40, 46, 91, 123, 11, 13, 0, 9, 10, 32, 11, 13, 0, 9, 10, 32, 35, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 40, 46, 91, 123, 11, 13, 0, 9, 10, 32, 46, 11, 13, 0, 9, 10, 32, 45, 95, 11, 13, 97, 122, 0, 9, 10, 32, 45, 93, 95, 11, 13, 97, 122, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 32, 11, 13, 0, 9, 10, 32, 35, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 40, 46, 91, 123, 11, 13, 0, 9, 10, 32, 46, 11, 13, 0, 9, 10, 32, 45, 95, 11, 13, 97, 122, 0, 9, 10, 32, 45, 93, 95, 11, 13, 97, 122, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 45, 95, 11, 13, 97, 122, 0, 9, 10, 32, 45, 93, 95, 11, 13, 97, 122, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 40, 91, 123, 0, 9, 10, 32, 11, 13, 0, 9, 10, 32, 35, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0, 9, 10, 32, 40, 91, 123, 11, 13, 0, 9, 10, 32, 45, 95, 11, 13, 97, 122, 0, 9, 10, 32, 45, 93, 95, 11, 13, 97, 122, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 12, 32, 123, 125, 11, 13, 0, 9, 10, 32, 35, 41, 45, 95, 11, 13, 48, 57, 65, 90, 97, 122, 0 }; static const char _redcloth_attributes_single_lengths[] = { 0, 4, 3, 8, 4, 3, 4, 8, 4, 3, 6, 4, 3, 2, 8, 4, 7, 7, 7, 4, 5, 2, 3, 5, 4, 3, 8, 3, 7, 2, 3, 3, 5, 4, 7, 6, 7, 8, 4, 7, 6, 7, 8, 5, 6, 7, 7, 7, 4, 7, 6, 7, 8, 5, 6, 7, 7, 7, 8, 8, 8, 6, 7, 7, 7, 3, 4, 7, 6, 7, 7, 6, 7, 7, 7, 8 }; static const char _redcloth_attributes_range_lengths[] = { 0, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 4, 4, 4, 1, 1, 2, 2, 1, 1, 1, 4, 4, 4, 1, 1, 2, 2, 1, 1, 4, 4, 4, 2, 2, 1, 1, 0, 1, 4, 4, 4, 1, 2, 2, 1, 1, 4 }; static const short _redcloth_attributes_index_offsets[] = { 0, 0, 6, 11, 24, 30, 35, 41, 54, 60, 65, 73, 79, 84, 88, 101, 107, 116, 125, 134, 142, 151, 157, 164, 171, 177, 182, 195, 200, 209, 213, 218, 223, 230, 236, 248, 259, 271, 281, 287, 299, 310, 322, 332, 339, 348, 358, 367, 376, 382, 394, 405, 417, 427, 434, 443, 453, 462, 471, 484, 497, 510, 519, 529, 538, 547, 551, 557, 569, 580, 592, 601, 610, 620, 629, 638 }; static const unsigned char _redcloth_attributes_indicies[] = { 0, 2, 3, 2, 0, 1, 0, 2, 2, 0, 1, 0, 2, 3, 4, 5, 6, 7, 7, 0, 7, 7, 7, 1, 8, 10, 11, 10, 8, 9, 8, 10, 10, 8, 9, 0, 2, 3, 13, 0, 12, 8, 10, 11, 14, 15, 16, 17, 17, 8, 17, 17, 17, 9, 8, 10, 11, 18, 8, 12, 19, 19, 21, 19, 20, 19, 23, 24, 25, 26, 27, 19, 22, 8, 29, 30, 29, 8, 28, 8, 29, 29, 8, 28, 19, 23, 19, 22, 8, 29, 30, 31, 32, 33, 34, 34, 8, 34, 34, 34, 28, 8, 29, 30, 35, 8, 22, 20, 37, 30, 20, 37, 28, 38, 8, 36, 20, 40, 11, 20, 40, 9, 41, 8, 39, 20, 43, 3, 20, 43, 1, 44, 0, 42, 45, 47, 45, 45, 45, 45, 45, 46, 48, 49, 50, 48, 48, 48, 48, 48, 46, 51, 51, 51, 51, 51, 46, 52, 53, 53, 53, 53, 53, 46, 54, 54, 56, 57, 58, 54, 55, 59, 61, 62, 61, 59, 60, 59, 61, 61, 59, 60, 59, 61, 62, 63, 64, 65, 66, 66, 59, 66, 66, 66, 60, 54, 54, 68, 54, 67, 67, 70, 62, 67, 70, 60, 71, 59, 69, 72, 72, 72, 46, 73, 74, 73, 73, 46, 46, 46, 46, 46, 75, 46, 46, 77, 78, 79, 46, 76, 80, 2, 3, 2, 80, 1, 80, 2, 3, 81, 82, 83, 83, 80, 83, 83, 83, 1, 80, 2, 3, 2, 84, 84, 80, 84, 84, 84, 1, 80, 2, 3, 2, 85, 86, 86, 80, 86, 86, 86, 1, 80, 2, 3, 13, 87, 88, 89, 90, 80, 12, 91, 10, 11, 10, 91, 9, 91, 10, 11, 92, 93, 94, 94, 91, 94, 94, 94, 9, 91, 10, 11, 10, 95, 95, 91, 95, 95, 95, 9, 91, 10, 11, 10, 96, 97, 97, 91, 97, 97, 97, 9, 91, 10, 11, 18, 87, 88, 89, 90, 91, 12, 91, 10, 11, 18, 88, 91, 12, 91, 10, 11, 10, 98, 98, 91, 98, 9, 91, 10, 11, 10, 99, 100, 99, 91, 99, 9, 102, 103, 11, 102, 103, 9, 9, 91, 101, 104, 40, 11, 104, 40, 9, 41, 91, 39, 105, 29, 30, 29, 105, 28, 105, 29, 30, 106, 107, 108, 108, 105, 108, 108, 108, 28, 105, 29, 30, 29, 109, 109, 105, 109, 109, 109, 28, 105, 29, 30, 29, 110, 111, 111, 105, 111, 111, 111, 28, 105, 29, 30, 35, 24, 25, 26, 27, 105, 22, 105, 29, 30, 35, 25, 105, 22, 105, 29, 30, 29, 112, 112, 105, 112, 28, 105, 29, 30, 29, 113, 114, 113, 105, 113, 28, 116, 117, 30, 116, 117, 28, 28, 105, 115, 20, 37, 30, 20, 37, 28, 38, 105, 36, 105, 29, 30, 31, 32, 33, 34, 34, 105, 34, 34, 34, 28, 91, 10, 11, 14, 15, 16, 17, 17, 91, 17, 17, 17, 9, 80, 2, 3, 4, 5, 6, 7, 7, 80, 7, 7, 7, 1, 80, 2, 3, 2, 118, 118, 80, 118, 1, 80, 2, 3, 2, 119, 120, 119, 80, 119, 1, 102, 122, 3, 102, 122, 1, 1, 80, 121, 104, 43, 3, 104, 43, 1, 44, 80, 42, 123, 124, 125, 46, 126, 61, 62, 61, 126, 60, 126, 61, 62, 127, 128, 129, 129, 126, 129, 129, 129, 60, 126, 61, 62, 61, 130, 130, 126, 130, 130, 130, 60, 126, 61, 62, 61, 131, 132, 132, 126, 132, 132, 132, 60, 126, 61, 62, 61, 56, 57, 58, 126, 55, 126, 61, 62, 61, 133, 133, 126, 133, 60, 126, 61, 62, 61, 134, 135, 134, 126, 134, 60, 75, 137, 62, 75, 137, 60, 60, 126, 136, 67, 70, 62, 67, 70, 60, 71, 126, 69, 126, 61, 62, 63, 64, 65, 66, 66, 126, 66, 66, 66, 60, 0 }; static const char _redcloth_attributes_trans_targs[] = { 32, 33, 1, 2, 3, 35, 37, 60, 32, 38, 4, 5, 38, 6, 7, 40, 42, 59, 8, 32, 9, 10, 48, 13, 49, 53, 54, 56, 48, 11, 12, 14, 50, 52, 58, 15, 57, 16, 52, 47, 17, 42, 64, 18, 37, 20, 0, 21, 20, 21, 23, 22, 23, 22, 65, 66, 67, 71, 73, 65, 66, 24, 25, 26, 68, 70, 75, 27, 23, 74, 28, 70, 30, 30, 23, 27, 33, 34, 61, 63, 32, 3, 35, 60, 36, 37, 36, 39, 43, 44, 46, 32, 7, 40, 59, 41, 42, 41, 45, 45, 42, 47, 9, 17, 9, 32, 14, 50, 58, 51, 52, 51, 55, 55, 52, 57, 9, 16, 62, 62, 37, 64, 18, 19, 29, 31, 65, 26, 68, 75, 69, 70, 69, 72, 72, 70, 74, 28 }; static const char _redcloth_attributes_trans_actions[] = { 27, 19, 0, 0, 0, 55, 55, 19, 25, 19, 0, 0, 46, 0, 0, 55, 55, 19, 0, 29, 0, 11, 46, 0, 46, 46, 46, 84, 19, 0, 0, 0, 55, 55, 19, 0, 70, 0, 64, 70, 0, 64, 73, 0, 64, 1, 0, 0, 0, 5, 5, 1, 7, 0, 23, 46, 46, 46, 80, 21, 19, 0, 0, 0, 55, 55, 19, 0, 11, 67, 0, 64, 1, 0, 9, 1, 49, 49, 49, 88, 40, 1, 19, 52, 52, 58, 19, 46, 46, 46, 84, 76, 1, 19, 52, 52, 58, 19, 52, 19, 61, 96, 31, 1, 13, 37, 1, 19, 52, 52, 58, 19, 52, 19, 61, 96, 1, 1, 52, 19, 61, 100, 1, 3, 3, 3, 34, 1, 19, 52, 52, 58, 19, 52, 19, 61, 92, 1 }; static const char _redcloth_attributes_to_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char _redcloth_attributes_from_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const short _redcloth_attributes_eof_trans[] = { 0, 1, 1, 1, 9, 9, 1, 9, 9, 20, 20, 9, 9, 20, 9, 9, 9, 9, 1, 0, 0, 0, 0, 55, 60, 60, 60, 55, 60, 0, 0, 0, 0, 81, 81, 81, 81, 81, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 92, 81, 81, 81, 81, 81, 0, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 }; static const int redcloth_attributes_start = 32; static const int redcloth_attributes_error = 0; static const int redcloth_attributes_en_inline = 65; static const int redcloth_attributes_en_link_says = 32; #line 19 "ragel/redcloth_attributes.c.rl" VALUE redcloth_attribute_parser(machine, self, p, pe) int machine; VALUE self; char *p, *pe; { int cs, act; char *ts = 0, *te = 0, *reg = 0, *bck = NULL, *attr_reg = NULL, *eof = NULL; VALUE regs = rb_hash_new(); VALUE attr_regs = rb_hash_new(); #line 370 "ext/redcloth_scan/redcloth_attributes.c" { cs = redcloth_attributes_start; ts = 0; te = 0; act = 0; } #line 33 "ragel/redcloth_attributes.c.rl" cs = machine; #line 383 "ext/redcloth_scan/redcloth_attributes.c" { int _klen; unsigned int _trans; const char *_acts; unsigned int _nacts; const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: _acts = _redcloth_attributes_actions + _redcloth_attributes_from_state_actions[cs]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 13: #line 1 "NONE" {ts = p;} break; #line 404 "ext/redcloth_scan/redcloth_attributes.c" } } _keys = _redcloth_attributes_trans_keys + _redcloth_attributes_key_offsets[cs]; _trans = _redcloth_attributes_index_offsets[cs]; _klen = _redcloth_attributes_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + _klen - 1; while (1) { if ( _upper < _lower ) break; _mid = _lower + ((_upper-_lower) >> 1); if ( (*p) < *_mid ) _upper = _mid - 1; else if ( (*p) > *_mid ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } _keys += _klen; _trans += _klen; } _klen = _redcloth_attributes_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + (_klen<<1) - 2; while (1) { if ( _upper < _lower ) break; _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( (*p) < _mid[0] ) _upper = _mid - 2; else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); goto _match; } } _trans += _klen; } _match: _trans = _redcloth_attributes_indicies[_trans]; _eof_trans: cs = _redcloth_attributes_trans_targs[_trans]; if ( _redcloth_attributes_trans_actions[_trans] == 0 ) goto _again; _acts = _redcloth_attributes_actions + _redcloth_attributes_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: #line 5 "ragel/redcloth_common.rl" { MARK(); } break; case 1: #line 6 "ragel/redcloth_common.rl" { MARK_B(); } break; case 2: #line 7 "ragel/redcloth_common.rl" { MARK_ATTR(); } break; case 3: #line 9 "ragel/redcloth_common.rl" { STORE("text"); } break; case 4: #line 10 "ragel/redcloth_common.rl" { CLEAR_REGS(); RESET_REG(); } break; case 5: #line 35 "ragel/redcloth_common.rl" { STORE_ATTR("class"); } break; case 6: #line 36 "ragel/redcloth_common.rl" { STORE_ATTR("id"); } break; case 7: #line 38 "ragel/redcloth_common.rl" { STORE_ATTR("lang"); } break; case 8: #line 39 "ragel/redcloth_common.rl" { STORE_ATTR("style"); } break; case 9: #line 20 "ragel/redcloth_attributes.rl" { STORE("name"); } break; case 10: #line 21 "ragel/redcloth_attributes.rl" { STORE_B("name_without_attributes"); } break; case 14: #line 1 "NONE" {te = p+1;} break; case 15: #line 16 "ragel/redcloth_attributes.rl" {act = 1;} break; case 16: #line 16 "ragel/redcloth_attributes.rl" {te = p;p--;{ SET_ATTRIBUTES(); }} break; case 17: #line 16 "ragel/redcloth_attributes.rl" {{p = ((te))-1;}{ SET_ATTRIBUTES(); }} break; case 18: #line 1 "NONE" { switch( act ) { case 0: {{cs = 0; goto _again;}} break; case 1: {{p = ((te))-1;} SET_ATTRIBUTES(); } break; } } break; case 19: #line 25 "ragel/redcloth_attributes.rl" {act = 2;} break; case 20: #line 26 "ragel/redcloth_attributes.rl" {act = 3;} break; case 21: #line 25 "ragel/redcloth_attributes.rl" {te = p;p--;{ SET_ATTRIBUTES(); }} break; case 22: #line 26 "ragel/redcloth_attributes.rl" {te = p;p--;{ SET_ATTRIBUTE("name_without_attributes", "name"); }} break; case 23: #line 25 "ragel/redcloth_attributes.rl" {{p = ((te))-1;}{ SET_ATTRIBUTES(); }} break; case 24: #line 26 "ragel/redcloth_attributes.rl" {{p = ((te))-1;}{ SET_ATTRIBUTE("name_without_attributes", "name"); }} break; case 25: #line 1 "NONE" { switch( act ) { case 2: {{p = ((te))-1;} SET_ATTRIBUTES(); } break; case 3: {{p = ((te))-1;} SET_ATTRIBUTE("name_without_attributes", "name"); } break; } } break; #line 578 "ext/redcloth_scan/redcloth_attributes.c" } } _again: _acts = _redcloth_attributes_actions + _redcloth_attributes_to_state_actions[cs]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 11: #line 1 "NONE" {ts = 0;} break; case 12: #line 1 "NONE" {act = 0;} break; #line 595 "ext/redcloth_scan/redcloth_attributes.c" } } if ( cs == 0 ) goto _out; if ( ++p != pe ) goto _resume; _test_eof: {} if ( p == eof ) { if ( _redcloth_attributes_eof_trans[cs] > 0 ) { _trans = _redcloth_attributes_eof_trans[cs] - 1; goto _eof_trans; } } _out: {} } #line 37 "ragel/redcloth_attributes.c.rl" return regs; } VALUE redcloth_attributes(self, str) VALUE self, str; { StringValue(str); int cs = redcloth_attributes_en_inline; return redcloth_attribute_parser(cs, self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1); } VALUE redcloth_link_attributes(self, str) VALUE self, str; { StringValue(str); int cs = redcloth_attributes_en_link_says; return redcloth_attribute_parser(cs, self, RSTRING_PTR(str), RSTRING_PTR(str) + RSTRING_LEN(str) + 1); }