RedCloth 3.0.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of RedCloth might be problematic. Click here for more details.

Files changed (63) hide show
  1. data/CHANGELOG +17 -0
  2. data/COPYING +18 -0
  3. data/README +156 -0
  4. data/Rakefile +238 -0
  5. data/bin/redcloth +27 -2
  6. data/ext/redcloth_scan/extconf.rb +9 -0
  7. data/ext/redcloth_scan/redcloth.h +149 -0
  8. data/ext/redcloth_scan/redcloth_attributes.c +650 -0
  9. data/ext/redcloth_scan/redcloth_attributes.rl +78 -0
  10. data/ext/redcloth_scan/redcloth_common.rl +113 -0
  11. data/ext/redcloth_scan/redcloth_inline.c +5102 -0
  12. data/ext/redcloth_scan/redcloth_inline.rl +282 -0
  13. data/ext/redcloth_scan/redcloth_scan.c +9300 -0
  14. data/ext/redcloth_scan/redcloth_scan.rl +523 -0
  15. data/extras/mingw-rbconfig.rb +176 -0
  16. data/extras/ragel_profiler.rb +73 -0
  17. data/lib/redcloth.rb +22 -1128
  18. data/lib/redcloth/formatters/base.rb +50 -0
  19. data/lib/redcloth/formatters/html.rb +342 -0
  20. data/lib/redcloth/formatters/latex.rb +227 -0
  21. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  22. data/lib/redcloth/textile_doc.rb +105 -0
  23. data/lib/redcloth/version.rb +18 -0
  24. data/test/basic.yml +794 -0
  25. data/test/code.yml +195 -0
  26. data/test/definitions.yml +71 -0
  27. data/test/extra_whitespace.yml +64 -0
  28. data/test/filter_html.yml +177 -0
  29. data/test/filter_pba.yml +12 -0
  30. data/test/helper.rb +108 -0
  31. data/test/html.yml +271 -0
  32. data/test/images.yml +202 -0
  33. data/{tests → test}/instiki.yml +14 -15
  34. data/test/links.yml +214 -0
  35. data/test/lists.yml +283 -0
  36. data/test/poignant.yml +89 -0
  37. data/test/sanitize_html.yml +42 -0
  38. data/test/table.yml +267 -0
  39. data/test/test_custom_tags.rb +46 -0
  40. data/test/test_extensions.rb +31 -0
  41. data/test/test_formatters.rb +15 -0
  42. data/test/test_parser.rb +68 -0
  43. data/test/test_restrictions.rb +41 -0
  44. data/test/textism.yml +480 -0
  45. data/test/threshold.yml +772 -0
  46. data/test/validate_fixtures.rb +73 -0
  47. metadata +94 -60
  48. data/doc/CHANGELOG +0 -160
  49. data/doc/COPYING +0 -25
  50. data/doc/README +0 -106
  51. data/doc/REFERENCE +0 -216
  52. data/doc/make.rb +0 -359
  53. data/run-tests.rb +0 -28
  54. data/setup.rb +0 -1376
  55. data/tests/code.yml +0 -105
  56. data/tests/hard_breaks.yml +0 -26
  57. data/tests/images.yml +0 -171
  58. data/tests/links.yml +0 -155
  59. data/tests/lists.yml +0 -77
  60. data/tests/markdown.yml +0 -218
  61. data/tests/poignant.yml +0 -64
  62. data/tests/table.yml +0 -198
  63. data/tests/textism.yml +0 -406
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS << " -O2 "
4
+
5
+ ### It seems to work fine without these
6
+ # dir_config("redcloth_scan")
7
+ # have_library("c", "main")
8
+
9
+ create_makefile("redcloth_scan")
@@ -0,0 +1,149 @@
1
+ #ifndef redcloth_h
2
+ #define redcloth_h
3
+
4
+ /* variable defs */
5
+ #ifndef redcloth_scan_c
6
+ extern VALUE super_ParseError, mRedCloth, super_RedCloth;
7
+ extern int SYM_escape_preformatted;
8
+ #endif
9
+
10
+ /* function defs */
11
+ void rb_str_cat_escaped(VALUE self, VALUE str, char *ts, char *te);
12
+ void rb_str_cat_escaped_for_preformatted(VALUE self, VALUE str, char *ts, char *te);
13
+ VALUE redcloth_inline(VALUE, char *, char *, VALUE);
14
+ VALUE redcloth_inline2(VALUE, VALUE, VALUE);
15
+ VALUE redcloth_attribute_parser(int, VALUE, char *, char *);
16
+ VALUE redcloth_attributes(VALUE, VALUE);
17
+ VALUE redcloth_link_attributes(VALUE, VALUE);
18
+ VALUE redcloth_transform(VALUE, char *, char *, VALUE);
19
+ VALUE redcloth_transform2(VALUE, VALUE);
20
+ void red_inc(VALUE, VALUE);
21
+ VALUE red_block(VALUE, VALUE, VALUE, VALUE);
22
+ VALUE red_blockcode(VALUE, VALUE, VALUE);
23
+ VALUE red_pass(VALUE, VALUE, VALUE, ID, VALUE);
24
+ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
25
+
26
+ /* parser macros */
27
+ #define CLEAR_REGS() regs = rb_hash_new(); rb_hash_aset(regs, ID2SYM(rb_intern("restrictions")), rb_iv_get(self, "@restrictions"));
28
+ #define CAT(H) rb_str_cat(H, ts, te-ts)
29
+ #define CLEAR(H) H = rb_str_new2("")
30
+ #define INLINE(H, T) rb_str_append(H, rb_funcall(self, rb_intern(#T), 1, regs))
31
+ #define DONE(H) rb_str_append(html, H); CLEAR(H); CLEAR_REGS()
32
+ #define PASS(H, A, T) rb_str_append(H, red_pass(self, regs, ID2SYM(rb_intern(#A)), rb_intern(#T), refs))
33
+ #define PARSE_ATTR(A) red_parse_attr(self, regs, ID2SYM(rb_intern(#A)))
34
+ #define PARSE_LINK_ATTR(A) red_parse_link_attr(self, regs, ID2SYM(rb_intern(#A)))
35
+ #define PASS_CODE(H, A, T, O) rb_str_append(H, red_pass_code(self, regs, ID2SYM(rb_intern(#A)), rb_intern(#T)))
36
+ #define ADD_BLOCK() \
37
+ rb_str_append(html, red_block(self, regs, block, refs)); \
38
+ extend = Qnil; \
39
+ CLEAR(block); \
40
+ CLEAR_REGS()
41
+ #define ADD_EXTENDED_BLOCK() rb_str_append(html, red_block(self, regs, block, refs)); CLEAR(block);
42
+ #define END_EXTENDED() extend = Qnil; CLEAR_REGS();
43
+ #define ADD_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block); CLEAR_REGS()
44
+ #define ADD_EXTENDED_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block);
45
+ #define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(#T)), rb_str_new2(#V));
46
+ #define AINC(T) red_inc(regs, ID2SYM(rb_intern(#T)));
47
+ #define SET_ATTRIBUTES() \
48
+ VALUE buf = Qnil; \
49
+ SET_ATTRIBUTE("class_buf", "class"); \
50
+ SET_ATTRIBUTE("id_buf", "id"); \
51
+ SET_ATTRIBUTE("lang_buf", "lang"); \
52
+ SET_ATTRIBUTE("style_buf", "style");
53
+ #define SET_ATTRIBUTE(B, A) \
54
+ buf = rb_hash_aref(regs, ID2SYM(rb_intern(B))); \
55
+ if (buf != Qnil) rb_hash_aset(regs, ID2SYM(rb_intern(A)), buf);
56
+ #define TRANSFORM(T) \
57
+ if (p > reg && reg >= ts) { \
58
+ VALUE str = redcloth_transform(self, reg, p, refs); \
59
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \
60
+ /* printf("TRANSFORM(" #T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \
61
+ } else { \
62
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), Qnil); \
63
+ }
64
+ #define STORE(T) \
65
+ if (p > reg && reg >= ts) { \
66
+ VALUE str = rb_str_new(reg, p-reg); \
67
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \
68
+ /* printf("STORE(" #T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \
69
+ } else { \
70
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), Qnil); \
71
+ }
72
+ #define STORE_B(T) \
73
+ if (p > bck && bck >= ts) { \
74
+ VALUE str = rb_str_new(bck, p-bck); \
75
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \
76
+ /* printf("STORE_B(" #T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \
77
+ } else { \
78
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), Qnil); \
79
+ }
80
+ #define STORE_URL(T) \
81
+ if (p > reg && reg >= ts) { \
82
+ char punct = 1; \
83
+ while (p > reg && punct == 1) { \
84
+ switch (*(p - 1)) { \
85
+ case '!': case '"': case '#': case '$': case '%': case ']': case '[': case '&': case '\'': \
86
+ case '*': case '+': case ',': case '-': case '.': case ')': case '(': case ':': \
87
+ case ';': case '=': case '?': case '@': case '\\': case '^': case '_': \
88
+ case '`': case '|': case '~': p--; break; \
89
+ default: punct = 0; \
90
+ } \
91
+ } \
92
+ te = p; \
93
+ } \
94
+ STORE(T); \
95
+ if ( !NIL_P(refs) && rb_funcall(refs, rb_intern("has_key?"), 1, rb_hash_aref(regs, ID2SYM(rb_intern(#T)))) ) { \
96
+ rb_hash_aset(regs, ID2SYM(rb_intern(#T)), rb_hash_aref(refs, rb_hash_aref(regs, ID2SYM(rb_intern(#T))))); \
97
+ }
98
+ #define LIST_ITEM() \
99
+ int aint = 0; \
100
+ VALUE aval = rb_ary_entry(list_index, nest-1); \
101
+ if (aval != Qnil) aint = NUM2INT(aval); \
102
+ if (strcmp(list_type, "ol") == 0) \
103
+ { \
104
+ rb_ary_store(list_index, nest-1, INT2NUM(aint + 1)); \
105
+ } \
106
+ if (nest > RARRAY(list_layout)->len) \
107
+ { \
108
+ sprintf(listm, "%s_open", list_type); \
109
+ if (list_continue == 1) \
110
+ { \
111
+ list_continue = 0; \
112
+ rb_hash_aset(regs, ID2SYM(rb_intern("start")), rb_ary_entry(list_index, nest-1)); \
113
+ } \
114
+ else \
115
+ { \
116
+ VALUE start = rb_hash_aref(regs, ID2SYM(rb_intern("start"))); \
117
+ if (NIL_P(start) ) \
118
+ { \
119
+ rb_ary_store(list_index, nest-1, INT2NUM(1)); \
120
+ } \
121
+ else \
122
+ { \
123
+ VALUE start_num = rb_funcall(start,rb_intern("to_i"),0); \
124
+ rb_ary_store(list_index, nest-1, start_num); \
125
+ } \
126
+ } \
127
+ rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(nest)); \
128
+ rb_str_append(html, rb_funcall(self, rb_intern(listm), 1, regs)); \
129
+ rb_ary_store(list_layout, nest-1, rb_str_new2(list_type)); \
130
+ CLEAR_REGS(); \
131
+ ASET(first, true); \
132
+ } \
133
+ LIST_CLOSE(); \
134
+ rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(RARRAY(list_layout)->len)); \
135
+ ASET(type, li_open)
136
+ #define LIST_CLOSE() \
137
+ while (nest < RARRAY(list_layout)->len) \
138
+ { \
139
+ rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(RARRAY(list_layout)->len)); \
140
+ VALUE end_list = rb_ary_pop(list_layout); \
141
+ if (!NIL_P(end_list)) \
142
+ { \
143
+ StringValue(end_list); \
144
+ sprintf(listm, "%s_close", RSTRING(end_list)->ptr); \
145
+ rb_str_append(html, rb_funcall(self, rb_intern(listm), 1, regs)); \
146
+ } \
147
+ }
148
+
149
+ #endif
@@ -0,0 +1,650 @@
1
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
2
+ /*
3
+ * redcloth_attributes.rl
4
+ *
5
+ * Copyright (C) 2008 Jason Garber
6
+ */
7
+ #include <ruby.h>
8
+ #include "redcloth.h"
9
+
10
+ #line 37 "ext/redcloth_scan/redcloth_attributes.rl"
11
+
12
+
13
+
14
+ #line 15 "ext/redcloth_scan/redcloth_attributes.c"
15
+ static const char _redcloth_attributes_actions[] = {
16
+ 0, 1, 0, 1, 3, 1, 4, 1,
17
+ 5, 1, 6, 1, 7, 1, 9, 1,
18
+ 10, 1, 12, 1, 13, 1, 16, 1,
19
+ 17, 1, 22, 1, 23, 1, 24, 2,
20
+ 0, 9, 2, 2, 15, 2, 8, 20,
21
+ 2, 9, 21, 2, 10, 11, 2, 13,
22
+ 0, 2, 13, 1, 2, 13, 4, 2,
23
+ 13, 5, 2, 13, 6, 2, 13, 7,
24
+ 2, 13, 14, 2, 13, 18, 2, 13,
25
+ 19, 3, 8, 9, 20, 3, 13, 0,
26
+ 14, 3, 13, 0, 18, 3, 13, 0,
27
+ 19, 3, 13, 1, 19, 3, 13, 4,
28
+ 14, 3, 13, 4, 18, 3, 13, 4,
29
+ 19
30
+ };
31
+
32
+ static const short _redcloth_attributes_key_offsets[] = {
33
+ 0, 0, 6, 11, 13, 14, 15, 23,
34
+ 29, 34, 38, 46, 53, 60, 66, 72,
35
+ 73, 80, 86, 87, 94, 100, 108, 115,
36
+ 122, 128, 134, 139, 145, 153, 160, 167,
37
+ 173, 179, 186, 192, 199, 205, 212, 218,
38
+ 225, 231, 233, 235, 236, 237, 244, 250,
39
+ 255, 263, 270, 277, 283, 284, 291, 297,
40
+ 298, 305, 311, 312, 313, 320, 326, 334,
41
+ 342, 348, 356, 364, 371, 378, 388, 395,
42
+ 402, 409, 416, 423, 430, 437, 447, 453,
43
+ 461, 469, 476, 483, 493, 500, 507, 514,
44
+ 521, 528, 535, 542, 549, 556, 559, 565,
45
+ 573, 581, 588, 595, 604, 611, 618, 625
46
+ };
47
+
48
+ static const char _redcloth_attributes_trans_keys[] = {
49
+ 0, 9, 10, 32, 11, 13, 0, 9,
50
+ 32, 10, 13, 35, 41, 41, 41, 0,
51
+ 32, 40, 46, 91, 123, 9, 13, 0,
52
+ 9, 10, 32, 11, 13, 0, 9, 32,
53
+ 10, 13, 0, 32, 9, 13, 0, 9,
54
+ 10, 32, 35, 41, 11, 13, 0, 9,
55
+ 32, 35, 41, 10, 13, 0, 9, 10,
56
+ 32, 41, 11, 13, 0, 9, 32, 41,
57
+ 10, 13, 0, 9, 10, 32, 11, 13,
58
+ 93, 0, 9, 10, 32, 93, 11, 13,
59
+ 0, 9, 32, 93, 10, 13, 125, 0,
60
+ 9, 10, 32, 125, 11, 13, 0, 9,
61
+ 32, 125, 10, 13, 0, 9, 10, 32,
62
+ 35, 41, 11, 13, 0, 9, 32, 35,
63
+ 41, 10, 13, 0, 9, 10, 32, 41,
64
+ 11, 13, 0, 9, 32, 41, 10, 13,
65
+ 0, 9, 10, 32, 11, 13, 0, 9,
66
+ 32, 10, 13, 0, 9, 10, 32, 11,
67
+ 13, 0, 9, 10, 32, 35, 41, 11,
68
+ 13, 0, 9, 32, 35, 41, 10, 13,
69
+ 0, 9, 10, 32, 41, 11, 13, 0,
70
+ 9, 32, 41, 10, 13, 0, 9, 10,
71
+ 32, 11, 13, 0, 9, 10, 32, 93,
72
+ 11, 13, 0, 9, 32, 93, 10, 13,
73
+ 0, 9, 10, 32, 125, 11, 13, 0,
74
+ 9, 32, 125, 10, 13, 0, 9, 10,
75
+ 32, 93, 11, 13, 0, 9, 32, 93,
76
+ 10, 13, 0, 9, 10, 32, 125, 11,
77
+ 13, 0, 9, 32, 125, 10, 13, 35,
78
+ 41, 35, 41, 41, 41, 0, 32, 40,
79
+ 91, 123, 9, 13, 0, 9, 10, 32,
80
+ 11, 13, 0, 9, 32, 10, 13, 0,
81
+ 9, 10, 32, 35, 41, 11, 13, 0,
82
+ 9, 32, 35, 41, 10, 13, 0, 9,
83
+ 10, 32, 41, 11, 13, 0, 9, 32,
84
+ 41, 10, 13, 93, 0, 9, 10, 32,
85
+ 93, 11, 13, 0, 9, 32, 93, 10,
86
+ 13, 125, 0, 9, 10, 32, 125, 11,
87
+ 13, 0, 9, 32, 125, 10, 13, 93,
88
+ 125, 0, 32, 40, 91, 123, 9, 13,
89
+ 0, 9, 10, 32, 11, 13, 0, 9,
90
+ 10, 32, 35, 41, 11, 13, 0, 9,
91
+ 10, 32, 35, 41, 11, 13, 0, 9,
92
+ 10, 32, 11, 13, 0, 9, 10, 32,
93
+ 35, 41, 11, 13, 0, 9, 10, 32,
94
+ 35, 41, 11, 13, 0, 9, 10, 32,
95
+ 41, 11, 13, 0, 9, 10, 32, 41,
96
+ 11, 13, 0, 9, 10, 32, 40, 46,
97
+ 91, 123, 11, 13, 0, 9, 10, 32,
98
+ 46, 11, 13, 0, 9, 10, 32, 93,
99
+ 11, 13, 0, 9, 10, 32, 93, 11,
100
+ 13, 0, 9, 10, 32, 125, 11, 13,
101
+ 0, 9, 10, 32, 125, 11, 13, 0,
102
+ 9, 10, 32, 41, 11, 13, 0, 9,
103
+ 10, 32, 41, 11, 13, 0, 9, 10,
104
+ 32, 40, 46, 91, 123, 11, 13, 0,
105
+ 9, 10, 32, 11, 13, 0, 9, 10,
106
+ 32, 35, 41, 11, 13, 0, 9, 10,
107
+ 32, 35, 41, 11, 13, 0, 9, 10,
108
+ 32, 41, 11, 13, 0, 9, 10, 32,
109
+ 41, 11, 13, 0, 9, 10, 32, 40,
110
+ 46, 91, 123, 11, 13, 0, 9, 10,
111
+ 32, 46, 11, 13, 0, 9, 10, 32,
112
+ 93, 11, 13, 0, 9, 10, 32, 93,
113
+ 11, 13, 0, 9, 10, 32, 125, 11,
114
+ 13, 0, 9, 10, 32, 125, 11, 13,
115
+ 0, 9, 10, 32, 93, 11, 13, 0,
116
+ 9, 10, 32, 93, 11, 13, 0, 9,
117
+ 10, 32, 125, 11, 13, 0, 9, 10,
118
+ 32, 125, 11, 13, 40, 91, 123, 0,
119
+ 9, 10, 32, 11, 13, 0, 9, 10,
120
+ 32, 35, 41, 11, 13, 0, 9, 10,
121
+ 32, 35, 41, 11, 13, 0, 9, 10,
122
+ 32, 41, 11, 13, 0, 9, 10, 32,
123
+ 41, 11, 13, 0, 9, 10, 32, 40,
124
+ 91, 123, 11, 13, 0, 9, 10, 32,
125
+ 93, 11, 13, 0, 9, 10, 32, 93,
126
+ 11, 13, 0, 9, 10, 32, 125, 11,
127
+ 13, 0, 9, 10, 32, 125, 11, 13,
128
+ 0
129
+ };
130
+
131
+ static const char _redcloth_attributes_single_lengths[] = {
132
+ 0, 4, 3, 2, 1, 1, 6, 4,
133
+ 3, 2, 6, 5, 5, 4, 4, 1,
134
+ 5, 4, 1, 5, 4, 6, 5, 5,
135
+ 4, 4, 3, 4, 6, 5, 5, 4,
136
+ 4, 5, 4, 5, 4, 5, 4, 5,
137
+ 4, 2, 2, 1, 1, 5, 4, 3,
138
+ 6, 5, 5, 4, 1, 5, 4, 1,
139
+ 5, 4, 1, 1, 5, 4, 6, 6,
140
+ 4, 6, 6, 5, 5, 8, 5, 5,
141
+ 5, 5, 5, 5, 5, 8, 4, 6,
142
+ 6, 5, 5, 8, 5, 5, 5, 5,
143
+ 5, 5, 5, 5, 5, 3, 4, 6,
144
+ 6, 5, 5, 7, 5, 5, 5, 5
145
+ };
146
+
147
+ static const char _redcloth_attributes_range_lengths[] = {
148
+ 0, 1, 1, 0, 0, 0, 1, 1,
149
+ 1, 1, 1, 1, 1, 1, 1, 0,
150
+ 1, 1, 0, 1, 1, 1, 1, 1,
151
+ 1, 1, 1, 1, 1, 1, 1, 1,
152
+ 1, 1, 1, 1, 1, 1, 1, 1,
153
+ 1, 0, 0, 0, 0, 1, 1, 1,
154
+ 1, 1, 1, 1, 0, 1, 1, 0,
155
+ 1, 1, 0, 0, 1, 1, 1, 1,
156
+ 1, 1, 1, 1, 1, 1, 1, 1,
157
+ 1, 1, 1, 1, 1, 1, 1, 1,
158
+ 1, 1, 1, 1, 1, 1, 1, 1,
159
+ 1, 1, 1, 1, 1, 0, 1, 1,
160
+ 1, 1, 1, 1, 1, 1, 1, 1
161
+ };
162
+
163
+ static const short _redcloth_attributes_index_offsets[] = {
164
+ 0, 0, 6, 11, 14, 16, 18, 26,
165
+ 32, 37, 41, 49, 56, 63, 69, 75,
166
+ 77, 84, 90, 92, 99, 105, 113, 120,
167
+ 127, 133, 139, 144, 150, 158, 165, 172,
168
+ 178, 184, 191, 197, 204, 210, 217, 223,
169
+ 230, 236, 239, 242, 244, 246, 253, 259,
170
+ 264, 272, 279, 286, 292, 294, 301, 307,
171
+ 309, 316, 322, 324, 326, 333, 339, 347,
172
+ 355, 361, 369, 377, 384, 391, 401, 408,
173
+ 415, 422, 429, 436, 443, 450, 460, 466,
174
+ 474, 482, 489, 496, 506, 513, 520, 527,
175
+ 534, 541, 548, 555, 562, 569, 573, 579,
176
+ 587, 595, 602, 609, 618, 625, 632, 639
177
+ };
178
+
179
+ static const unsigned char _redcloth_attributes_indicies[] = {
180
+ 0, 2, 3, 2, 0, 1, 0, 2,
181
+ 2, 0, 1, 6, 7, 5, 4, 8,
182
+ 10, 9, 4, 12, 13, 14, 15, 16,
183
+ 4, 11, 17, 19, 20, 19, 17, 18,
184
+ 17, 19, 19, 17, 18, 4, 12, 4,
185
+ 11, 5, 22, 23, 22, 24, 25, 5,
186
+ 21, 5, 22, 22, 24, 25, 5, 21,
187
+ 9, 27, 28, 27, 29, 9, 26, 9,
188
+ 27, 27, 29, 9, 26, 17, 19, 20,
189
+ 30, 17, 11, 32, 31, 31, 34, 35,
190
+ 34, 36, 31, 33, 31, 34, 34, 36,
191
+ 31, 33, 38, 37, 37, 40, 41, 40,
192
+ 42, 37, 39, 37, 40, 40, 42, 37,
193
+ 39, 5, 44, 45, 44, 46, 47, 5,
194
+ 43, 5, 44, 44, 46, 47, 5, 43,
195
+ 9, 49, 50, 49, 51, 9, 48, 9,
196
+ 49, 49, 51, 9, 48, 17, 53, 54,
197
+ 53, 17, 52, 17, 53, 53, 17, 52,
198
+ 0, 2, 3, 56, 0, 55, 5, 58,
199
+ 59, 58, 60, 61, 5, 57, 5, 58,
200
+ 58, 60, 61, 5, 57, 9, 63, 64,
201
+ 63, 65, 9, 62, 9, 63, 63, 65,
202
+ 9, 62, 17, 53, 54, 66, 17, 55,
203
+ 31, 68, 69, 68, 70, 31, 67, 31,
204
+ 68, 68, 70, 31, 67, 37, 72, 73,
205
+ 72, 74, 37, 71, 37, 72, 72, 74,
206
+ 37, 71, 31, 76, 77, 76, 78, 31,
207
+ 75, 31, 76, 76, 78, 31, 75, 37,
208
+ 80, 81, 80, 82, 37, 79, 37, 80,
209
+ 80, 82, 37, 79, 84, 85, 83, 88,
210
+ 89, 87, 86, 90, 92, 91, 86, 86,
211
+ 94, 95, 96, 86, 93, 97, 99, 100,
212
+ 99, 97, 98, 97, 99, 99, 97, 98,
213
+ 87, 102, 103, 102, 104, 105, 87, 101,
214
+ 87, 102, 102, 104, 105, 87, 101, 91,
215
+ 107, 108, 107, 109, 91, 106, 91, 107,
216
+ 107, 109, 91, 106, 111, 110, 110, 113,
217
+ 114, 113, 115, 110, 112, 110, 113, 113,
218
+ 115, 110, 112, 117, 116, 116, 119, 120,
219
+ 119, 121, 116, 118, 116, 119, 119, 121,
220
+ 116, 118, 123, 122, 123, 124, 123, 123,
221
+ 126, 127, 128, 123, 125, 129, 2, 3,
222
+ 2, 129, 1, 131, 132, 133, 132, 134,
223
+ 135, 131, 130, 136, 44, 45, 44, 46,
224
+ 47, 136, 43, 137, 19, 20, 19, 137,
225
+ 18, 139, 140, 141, 140, 142, 143, 139,
226
+ 138, 5, 22, 23, 22, 24, 25, 5,
227
+ 21, 8, 145, 146, 145, 18, 8, 144,
228
+ 9, 27, 28, 27, 29, 9, 26, 137,
229
+ 19, 20, 30, 13, 14, 15, 16, 137,
230
+ 11, 137, 19, 20, 30, 14, 137, 11,
231
+ 148, 149, 150, 149, 18, 148, 147, 31,
232
+ 34, 35, 34, 36, 31, 33, 152, 153,
233
+ 154, 153, 18, 152, 151, 37, 40, 41,
234
+ 40, 42, 37, 39, 156, 157, 158, 157,
235
+ 1, 156, 155, 159, 49, 50, 49, 51,
236
+ 159, 48, 129, 2, 3, 56, 160, 161,
237
+ 162, 163, 129, 55, 164, 53, 54, 53,
238
+ 164, 52, 131, 166, 167, 166, 168, 169,
239
+ 131, 165, 136, 58, 59, 58, 60, 61,
240
+ 136, 57, 156, 171, 172, 171, 52, 156,
241
+ 170, 159, 63, 64, 63, 65, 159, 62,
242
+ 164, 53, 54, 66, 160, 161, 162, 163,
243
+ 164, 55, 164, 53, 54, 66, 161, 164,
244
+ 55, 174, 175, 176, 175, 52, 174, 173,
245
+ 177, 68, 69, 68, 70, 177, 67, 179,
246
+ 180, 181, 180, 52, 179, 178, 182, 72,
247
+ 73, 72, 74, 182, 71, 174, 184, 185,
248
+ 184, 1, 174, 183, 177, 76, 77, 76,
249
+ 78, 177, 75, 179, 187, 188, 187, 1,
250
+ 179, 186, 182, 80, 81, 80, 82, 182,
251
+ 79, 189, 190, 191, 123, 192, 99, 100,
252
+ 99, 192, 98, 83, 194, 195, 194, 196,
253
+ 197, 83, 193, 87, 102, 103, 102, 104,
254
+ 105, 87, 101, 90, 199, 200, 199, 98,
255
+ 90, 198, 91, 107, 108, 107, 109, 91,
256
+ 106, 192, 99, 100, 99, 94, 95, 96,
257
+ 192, 93, 122, 202, 203, 202, 98, 122,
258
+ 201, 110, 113, 114, 113, 115, 110, 112,
259
+ 124, 205, 206, 205, 98, 124, 204, 116,
260
+ 119, 120, 119, 121, 116, 118, 0
261
+ };
262
+
263
+ static const char _redcloth_attributes_trans_targs[] = {
264
+ 60, 61, 1, 2, 60, 3, 4, 6,
265
+ 5, 5, 6, 64, 9, 65, 70, 71,
266
+ 73, 60, 64, 7, 8, 66, 10, 11,
267
+ 67, 69, 68, 12, 13, 69, 14, 15,
268
+ 6, 72, 16, 17, 69, 18, 6, 74,
269
+ 19, 20, 69, 63, 21, 22, 75, 77,
270
+ 76, 23, 24, 77, 78, 25, 26, 78,
271
+ 27, 80, 28, 29, 81, 83, 82, 30,
272
+ 31, 83, 32, 86, 33, 34, 83, 88,
273
+ 35, 36, 83, 90, 37, 38, 77, 92,
274
+ 39, 40, 77, 42, 43, 45, 93, 42,
275
+ 43, 45, 44, 44, 45, 94, 95, 100,
276
+ 102, 93, 94, 46, 47, 96, 48, 49,
277
+ 97, 99, 98, 50, 51, 99, 52, 45,
278
+ 101, 53, 54, 99, 55, 45, 103, 56,
279
+ 57, 99, 52, 0, 55, 61, 62, 89,
280
+ 91, 60, 63, 3, 21, 22, 75, 77,
281
+ 3, 60, 66, 3, 10, 11, 67, 69,
282
+ 68, 12, 13, 72, 15, 16, 17, 74,
283
+ 18, 19, 20, 76, 5, 23, 24, 5,
284
+ 79, 84, 85, 87, 60, 80, 28, 29,
285
+ 81, 83, 82, 30, 31, 86, 15, 33,
286
+ 34, 15, 88, 18, 35, 36, 18, 90,
287
+ 37, 38, 92, 39, 40, 41, 58, 59,
288
+ 93, 96, 48, 49, 97, 99, 98, 50,
289
+ 51, 101, 53, 54, 103, 56, 57
290
+ };
291
+
292
+ static const char _redcloth_attributes_trans_actions[] = {
293
+ 27, 19, 0, 0, 29, 0, 5, 5,
294
+ 1, 0, 7, 46, 0, 81, 46, 81,
295
+ 81, 25, 19, 0, 0, 67, 0, 0,
296
+ 97, 52, 67, 0, 0, 55, 0, 0,
297
+ 9, 67, 0, 0, 58, 0, 11, 67,
298
+ 0, 0, 61, 70, 0, 0, 101, 52,
299
+ 70, 0, 0, 55, 19, 0, 0, 46,
300
+ 0, 67, 0, 0, 97, 52, 67, 0,
301
+ 0, 55, 0, 67, 0, 0, 58, 67,
302
+ 0, 0, 61, 70, 0, 0, 58, 70,
303
+ 0, 0, 61, 1, 0, 0, 23, 0,
304
+ 5, 5, 1, 0, 7, 46, 77, 77,
305
+ 77, 21, 19, 0, 0, 64, 0, 0,
306
+ 93, 52, 64, 0, 0, 55, 0, 9,
307
+ 64, 0, 0, 58, 0, 11, 64, 0,
308
+ 0, 61, 1, 0, 1, 49, 89, 89,
309
+ 89, 40, 85, 31, 1, 1, 70, 19,
310
+ 13, 37, 81, 1, 1, 1, 67, 19,
311
+ 81, 1, 1, 81, 1, 1, 1, 81,
312
+ 1, 1, 1, 85, 31, 1, 1, 13,
313
+ 81, 46, 81, 81, 73, 81, 1, 1,
314
+ 67, 19, 81, 1, 1, 81, 31, 1,
315
+ 1, 13, 81, 31, 1, 1, 13, 85,
316
+ 1, 1, 85, 1, 1, 3, 3, 3,
317
+ 34, 77, 1, 1, 64, 19, 77, 1,
318
+ 1, 77, 1, 1, 77, 1, 1
319
+ };
320
+
321
+ static const char _redcloth_attributes_to_state_actions[] = {
322
+ 0, 0, 0, 0, 0, 0, 0, 0,
323
+ 0, 0, 0, 0, 0, 0, 0, 0,
324
+ 0, 0, 0, 0, 0, 0, 0, 0,
325
+ 0, 0, 0, 0, 0, 0, 0, 0,
326
+ 0, 0, 0, 0, 0, 0, 0, 0,
327
+ 0, 0, 0, 0, 0, 0, 0, 0,
328
+ 0, 0, 0, 0, 0, 0, 0, 0,
329
+ 0, 0, 0, 0, 15, 0, 0, 0,
330
+ 0, 0, 0, 0, 0, 0, 0, 0,
331
+ 0, 0, 0, 0, 0, 0, 0, 0,
332
+ 0, 0, 0, 0, 0, 0, 0, 0,
333
+ 0, 0, 0, 0, 0, 43, 0, 0,
334
+ 0, 0, 0, 0, 0, 0, 0, 0
335
+ };
336
+
337
+ static const char _redcloth_attributes_from_state_actions[] = {
338
+ 0, 0, 0, 0, 0, 0, 0, 0,
339
+ 0, 0, 0, 0, 0, 0, 0, 0,
340
+ 0, 0, 0, 0, 0, 0, 0, 0,
341
+ 0, 0, 0, 0, 0, 0, 0, 0,
342
+ 0, 0, 0, 0, 0, 0, 0, 0,
343
+ 0, 0, 0, 0, 0, 0, 0, 0,
344
+ 0, 0, 0, 0, 0, 0, 0, 0,
345
+ 0, 0, 0, 0, 17, 0, 0, 0,
346
+ 0, 0, 0, 0, 0, 0, 0, 0,
347
+ 0, 0, 0, 0, 0, 0, 0, 0,
348
+ 0, 0, 0, 0, 0, 0, 0, 0,
349
+ 0, 0, 0, 0, 0, 17, 0, 0,
350
+ 0, 0, 0, 0, 0, 0, 0, 0
351
+ };
352
+
353
+ static const short _redcloth_attributes_eof_trans[] = {
354
+ 0, 1, 1, 5, 5, 5, 5, 18,
355
+ 18, 5, 18, 18, 18, 18, 18, 5,
356
+ 18, 18, 5, 18, 18, 1, 1, 1,
357
+ 1, 18, 18, 1, 18, 18, 18, 18,
358
+ 18, 18, 18, 18, 18, 1, 1, 1,
359
+ 1, 0, 87, 87, 87, 87, 98, 98,
360
+ 98, 98, 98, 98, 87, 98, 98, 87,
361
+ 98, 98, 0, 0, 0, 130, 130, 130,
362
+ 138, 138, 138, 138, 138, 138, 138, 138,
363
+ 138, 138, 138, 130, 130, 130, 165, 165,
364
+ 165, 165, 165, 165, 165, 165, 165, 165,
365
+ 165, 130, 130, 130, 130, 0, 193, 193,
366
+ 193, 193, 193, 193, 193, 193, 193, 193
367
+ };
368
+
369
+ static const int redcloth_attributes_start = 60;
370
+ static const int redcloth_attributes_error = 0;
371
+
372
+ static const int redcloth_attributes_en_inline = 93;
373
+ static const int redcloth_attributes_en_link_says = 60;
374
+
375
+ #line 40 "ext/redcloth_scan/redcloth_attributes.rl"
376
+
377
+
378
+ VALUE
379
+ redcloth_attribute_parser(machine, self, p, pe)
380
+ int machine;
381
+ VALUE self;
382
+ char *p, *pe;
383
+ {
384
+ int cs, act;
385
+ char *ts, *te, *reg, *bck, *eof;
386
+ VALUE regs = rb_hash_new();
387
+ VALUE buf = Qnil;
388
+
389
+
390
+ #line 391 "ext/redcloth_scan/redcloth_attributes.c"
391
+ {
392
+ cs = redcloth_attributes_start;
393
+ ts = 0;
394
+ te = 0;
395
+ act = 0;
396
+ }
397
+ #line 54 "ext/redcloth_scan/redcloth_attributes.rl"
398
+
399
+ cs = machine;
400
+
401
+
402
+ #line 403 "ext/redcloth_scan/redcloth_attributes.c"
403
+ {
404
+ int _klen;
405
+ unsigned int _trans;
406
+ const char *_acts;
407
+ unsigned int _nacts;
408
+ const char *_keys;
409
+
410
+ if ( p == pe )
411
+ goto _test_eof;
412
+ if ( cs == 0 )
413
+ goto _out;
414
+ _resume:
415
+ _acts = _redcloth_attributes_actions + _redcloth_attributes_from_state_actions[cs];
416
+ _nacts = (unsigned int) *_acts++;
417
+ while ( _nacts-- > 0 ) {
418
+ switch ( *_acts++ ) {
419
+ case 12:
420
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
421
+ {ts = p;}
422
+ break;
423
+ #line 424 "ext/redcloth_scan/redcloth_attributes.c"
424
+ }
425
+ }
426
+
427
+ _keys = _redcloth_attributes_trans_keys + _redcloth_attributes_key_offsets[cs];
428
+ _trans = _redcloth_attributes_index_offsets[cs];
429
+
430
+ _klen = _redcloth_attributes_single_lengths[cs];
431
+ if ( _klen > 0 ) {
432
+ const char *_lower = _keys;
433
+ const char *_mid;
434
+ const char *_upper = _keys + _klen - 1;
435
+ while (1) {
436
+ if ( _upper < _lower )
437
+ break;
438
+
439
+ _mid = _lower + ((_upper-_lower) >> 1);
440
+ if ( (*p) < *_mid )
441
+ _upper = _mid - 1;
442
+ else if ( (*p) > *_mid )
443
+ _lower = _mid + 1;
444
+ else {
445
+ _trans += (_mid - _keys);
446
+ goto _match;
447
+ }
448
+ }
449
+ _keys += _klen;
450
+ _trans += _klen;
451
+ }
452
+
453
+ _klen = _redcloth_attributes_range_lengths[cs];
454
+ if ( _klen > 0 ) {
455
+ const char *_lower = _keys;
456
+ const char *_mid;
457
+ const char *_upper = _keys + (_klen<<1) - 2;
458
+ while (1) {
459
+ if ( _upper < _lower )
460
+ break;
461
+
462
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
463
+ if ( (*p) < _mid[0] )
464
+ _upper = _mid - 2;
465
+ else if ( (*p) > _mid[1] )
466
+ _lower = _mid + 2;
467
+ else {
468
+ _trans += ((_mid - _keys)>>1);
469
+ goto _match;
470
+ }
471
+ }
472
+ _trans += _klen;
473
+ }
474
+
475
+ _match:
476
+ _trans = _redcloth_attributes_indicies[_trans];
477
+ _eof_trans:
478
+ cs = _redcloth_attributes_trans_targs[_trans];
479
+
480
+ if ( _redcloth_attributes_trans_actions[_trans] == 0 )
481
+ goto _again;
482
+
483
+ _acts = _redcloth_attributes_actions + _redcloth_attributes_trans_actions[_trans];
484
+ _nacts = (unsigned int) *_acts++;
485
+ while ( _nacts-- > 0 )
486
+ {
487
+ switch ( *_acts++ )
488
+ {
489
+ case 0:
490
+ #line 5 "ext/redcloth_scan/redcloth_attributes.rl"
491
+ { reg = p; }
492
+ break;
493
+ case 1:
494
+ #line 6 "ext/redcloth_scan/redcloth_attributes.rl"
495
+ { bck = p; }
496
+ break;
497
+ case 2:
498
+ #line 7 "ext/redcloth_scan/redcloth_attributes.rl"
499
+ { STORE(text); }
500
+ break;
501
+ case 3:
502
+ #line 8 "ext/redcloth_scan/redcloth_attributes.rl"
503
+ { CLEAR_REGS(); reg = NULL; }
504
+ break;
505
+ case 4:
506
+ #line 14 "ext/redcloth_scan/redcloth_attributes.rl"
507
+ { STORE(class_buf) }
508
+ break;
509
+ case 5:
510
+ #line 14 "ext/redcloth_scan/redcloth_attributes.rl"
511
+ {STORE(id_buf)}
512
+ break;
513
+ case 6:
514
+ #line 15 "ext/redcloth_scan/redcloth_attributes.rl"
515
+ { STORE(lang_buf) }
516
+ break;
517
+ case 7:
518
+ #line 16 "ext/redcloth_scan/redcloth_attributes.rl"
519
+ { STORE(style_buf) }
520
+ break;
521
+ case 8:
522
+ #line 27 "ext/redcloth_scan/redcloth_attributes.rl"
523
+ { STORE(name) }
524
+ break;
525
+ case 9:
526
+ #line 28 "ext/redcloth_scan/redcloth_attributes.rl"
527
+ { STORE_B(name_without_attributes) }
528
+ break;
529
+ case 13:
530
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
531
+ {te = p+1;}
532
+ break;
533
+ case 14:
534
+ #line 23 "ext/redcloth_scan/redcloth_attributes.rl"
535
+ {act = 1;}
536
+ break;
537
+ case 15:
538
+ #line 23 "ext/redcloth_scan/redcloth_attributes.rl"
539
+ {te = p;p--;{ SET_ATTRIBUTES(); }}
540
+ break;
541
+ case 16:
542
+ #line 23 "ext/redcloth_scan/redcloth_attributes.rl"
543
+ {{p = ((te))-1;}{ SET_ATTRIBUTES(); }}
544
+ break;
545
+ case 17:
546
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
547
+ { switch( act ) {
548
+ case 0:
549
+ {{cs = 0; goto _again;}}
550
+ break;
551
+ case 1:
552
+ {{p = ((te))-1;} SET_ATTRIBUTES(); }
553
+ break;
554
+ }
555
+ }
556
+ break;
557
+ case 18:
558
+ #line 32 "ext/redcloth_scan/redcloth_attributes.rl"
559
+ {act = 2;}
560
+ break;
561
+ case 19:
562
+ #line 33 "ext/redcloth_scan/redcloth_attributes.rl"
563
+ {act = 3;}
564
+ break;
565
+ case 20:
566
+ #line 32 "ext/redcloth_scan/redcloth_attributes.rl"
567
+ {te = p;p--;{ SET_ATTRIBUTES(); }}
568
+ break;
569
+ case 21:
570
+ #line 33 "ext/redcloth_scan/redcloth_attributes.rl"
571
+ {te = p;p--;{ SET_ATTRIBUTE("name_without_attributes", "name"); }}
572
+ break;
573
+ case 22:
574
+ #line 32 "ext/redcloth_scan/redcloth_attributes.rl"
575
+ {{p = ((te))-1;}{ SET_ATTRIBUTES(); }}
576
+ break;
577
+ case 23:
578
+ #line 33 "ext/redcloth_scan/redcloth_attributes.rl"
579
+ {{p = ((te))-1;}{ SET_ATTRIBUTE("name_without_attributes", "name"); }}
580
+ break;
581
+ case 24:
582
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
583
+ { switch( act ) {
584
+ case 2:
585
+ {{p = ((te))-1;} SET_ATTRIBUTES(); }
586
+ break;
587
+ case 3:
588
+ {{p = ((te))-1;} SET_ATTRIBUTE("name_without_attributes", "name"); }
589
+ break;
590
+ }
591
+ }
592
+ break;
593
+ #line 594 "ext/redcloth_scan/redcloth_attributes.c"
594
+ }
595
+ }
596
+
597
+ _again:
598
+ _acts = _redcloth_attributes_actions + _redcloth_attributes_to_state_actions[cs];
599
+ _nacts = (unsigned int) *_acts++;
600
+ while ( _nacts-- > 0 ) {
601
+ switch ( *_acts++ ) {
602
+ case 10:
603
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
604
+ {ts = 0;}
605
+ break;
606
+ case 11:
607
+ #line 1 "ext/redcloth_scan/redcloth_attributes.rl"
608
+ {act = 0;}
609
+ break;
610
+ #line 611 "ext/redcloth_scan/redcloth_attributes.c"
611
+ }
612
+ }
613
+
614
+ if ( cs == 0 )
615
+ goto _out;
616
+ if ( ++p != pe )
617
+ goto _resume;
618
+ _test_eof: {}
619
+ if ( p == eof )
620
+ {
621
+ if ( _redcloth_attributes_eof_trans[cs] > 0 ) {
622
+ _trans = _redcloth_attributes_eof_trans[cs] - 1;
623
+ goto _eof_trans;
624
+ }
625
+ }
626
+
627
+ _out: {}
628
+ }
629
+ #line 58 "ext/redcloth_scan/redcloth_attributes.rl"
630
+
631
+ return regs;
632
+ }
633
+
634
+ VALUE
635
+ redcloth_attributes(self, str)
636
+ VALUE self, str;
637
+ {
638
+ StringValue(str);
639
+ int cs = redcloth_attributes_en_inline;
640
+ return redcloth_attribute_parser(cs, self, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1);
641
+ }
642
+
643
+ VALUE
644
+ redcloth_link_attributes(self, str)
645
+ VALUE self, str;
646
+ {
647
+ StringValue(str);
648
+ int cs = redcloth_attributes_en_link_says;
649
+ return redcloth_attribute_parser(cs, self, RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1);
650
+ }