mediacloth 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mediacloth/mediawikiast.rb +5 -1
- data/lib/mediacloth/mediawikihtmlgenerator.rb +8 -2
- data/lib/mediacloth/mediawikilexer.rb +82 -7
- data/lib/mediacloth/mediawikiparser.rb +211 -139
- data/lib/mediacloth/mediawikiparser.y +36 -3
- data/lib/mediacloth/mediawikiwalker.rb +6 -0
- data/test/data/html1 +4 -19
- data/test/data/html2 +2 -2
- data/test/data/html3 +1 -1
- data/test/data/html4 +1 -1
- data/test/data/html5 +14 -0
- data/test/data/html6 +4 -4
- data/test/data/html7 +2 -1
- data/test/data/html8 +1 -0
- data/test/data/input5 +2 -0
- data/test/data/input8 +1 -0
- data/test/data/lex1 +10 -11
- data/test/data/lex2 +2 -2
- data/test/data/lex3 +1 -1
- data/test/data/lex4 +1 -1
- data/test/data/lex6 +4 -4
- data/test/data/lex7 +2 -2
- data/test/data/lex8 +1 -0
- data/test/dataproducers/html.rb +6 -5
- data/test/dataproducers/lex.rb +2 -2
- data/test/debugwalker.rb +5 -0
- data/test/lexer.rb +12 -3
- data/test/testhelper.rb +1 -1
- metadata +6 -12
- data/lib/mediacloth/mediawikihtmlgenerator.rb~ +0 -105
- data/lib/mediacloth/mediawikiparser.y~ +0 -172
- data/lib/mediacloth/mediawikiwalker.rb~ +0 -62
- data/lib/mediacloth.rb~ +0 -23
- data/test/dataproducers/html.rb~ +0 -23
- data/test/debugwalker.rb~ +0 -63
- data/test/htmlgenerator.rb~ +0 -25
- data/test/lexer.rb~ +0 -57
- data/test/parser.rb~ +0 -23
- data/test/testhelper.rb~ +0 -28
@@ -12,7 +12,7 @@ require 'mediacloth/mediawikiast'
|
|
12
12
|
|
13
13
|
class MediaWikiParser < Racc::Parser
|
14
14
|
|
15
|
-
module_eval <<'..end mediawikiparser.y modeval..
|
15
|
+
module_eval <<'..end mediawikiparser.y modeval..id823eb1450e', 'mediawikiparser.y', 186
|
16
16
|
|
17
17
|
attr_accessor :lexer
|
18
18
|
|
@@ -33,103 +33,124 @@ end
|
|
33
33
|
def next_token
|
34
34
|
return @lexer.lex
|
35
35
|
end
|
36
|
-
..end mediawikiparser.y modeval..
|
36
|
+
..end mediawikiparser.y modeval..id823eb1450e
|
37
37
|
|
38
38
|
##### racc 1.4.5 generates ###
|
39
39
|
|
40
40
|
racc_reduce_table = [
|
41
41
|
0, 0, :racc_error,
|
42
|
-
1,
|
43
|
-
1,
|
44
|
-
1,
|
45
|
-
1,
|
46
|
-
1,
|
47
|
-
1,
|
48
|
-
|
49
|
-
|
50
|
-
1,
|
51
|
-
|
52
|
-
|
53
|
-
1,
|
54
|
-
1,
|
55
|
-
|
56
|
-
|
57
|
-
1,
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
3,
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
42
|
+
1, 27, :_reduce_1,
|
43
|
+
1, 29, :_reduce_2,
|
44
|
+
1, 29, :_reduce_3,
|
45
|
+
1, 29, :_reduce_4,
|
46
|
+
1, 29, :_reduce_5,
|
47
|
+
1, 29, :_reduce_6,
|
48
|
+
3, 29, :_reduce_7,
|
49
|
+
0, 35, :_reduce_8,
|
50
|
+
1, 35, :_reduce_9,
|
51
|
+
1, 28, :_reduce_10,
|
52
|
+
2, 28, :_reduce_11,
|
53
|
+
1, 30, :_reduce_12,
|
54
|
+
1, 30, :_reduce_13,
|
55
|
+
3, 36, :_reduce_14,
|
56
|
+
3, 36, :_reduce_15,
|
57
|
+
1, 36, :_reduce_16,
|
58
|
+
1, 36, :_reduce_17,
|
59
|
+
1, 36, :_reduce_18,
|
60
|
+
1, 36, :_reduce_19,
|
61
|
+
1, 36, :_reduce_20,
|
62
|
+
3, 37, :_reduce_21,
|
63
|
+
3, 37, :_reduce_22,
|
64
|
+
4, 31, :_reduce_23,
|
65
|
+
4, 32, :_reduce_24,
|
66
|
+
0, 40, :_reduce_25,
|
67
|
+
3, 39, :_reduce_26,
|
68
|
+
0, 39, :_reduce_27,
|
69
|
+
3, 38, :_reduce_28,
|
70
|
+
1, 33, :_reduce_29,
|
71
|
+
3, 34, :_reduce_30 ]
|
72
|
+
|
73
|
+
racc_reduce_n = 31
|
74
|
+
|
75
|
+
racc_shift_n = 53
|
71
76
|
|
72
77
|
racc_action_table = [
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
6, 36, 10, -27, 16, 35, 20, 26, 23, 41,
|
79
|
+
3, 5, 8, 11, 13, 15, 18, 6, 32, 10,
|
80
|
+
1, 16, 7, 20, 31, 23, 43, 3, 5, 8,
|
81
|
+
11, 13, 15, 18, 44, -27, 50, 1, 6, 7,
|
82
|
+
10, 46, 16, 47, 20, 48, 23, 26, 3, 5,
|
83
|
+
8, 11, 13, 15, 18, 6, 26, 10, 1, 16,
|
84
|
+
7, 20, 51, 23, -25, 3, 5, 8, 11, 13,
|
85
|
+
15, 18, 6, nil, 10, 1, 16, 7, 20, nil,
|
86
|
+
23, nil, 3, 5, 8, 11, 13, 15, 18, nil,
|
87
|
+
nil, nil, 1, 6, 7, 10, 42, 16, nil, 20,
|
88
|
+
nil, 23, nil, 3, 5, 8, 11, 13, 15, 18,
|
89
|
+
6, nil, 10, 1, 16, 7, 20, nil, 23, nil,
|
90
|
+
3, 5, 8, 11, 13, 15, 18, 6, nil, 10,
|
91
|
+
1, 16, 7, 20, nil, 23, nil, 3, 5, 8,
|
92
|
+
11, 13, 15, 18, 6, nil, 10, 1, 16, 7,
|
93
|
+
20, nil, 23, nil, 3, 5, 8, 11, 13, 15,
|
94
|
+
18, 6, 40, 10, 1, 16, 7, 20, nil, 23,
|
95
|
+
nil, 3, 5, 8, 11, 13, 15, 18, nil, nil,
|
96
|
+
nil, 1, nil, 7 ]
|
86
97
|
|
87
98
|
racc_action_check = [
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
0, 23, 0, 25, 0, 20, 0, 18, 0, 28,
|
100
|
+
0, 0, 0, 0, 0, 0, 0, 39, 16, 39,
|
101
|
+
0, 39, 0, 39, 14, 39, 31, 39, 39, 39,
|
102
|
+
39, 39, 39, 39, 32, 34, 39, 39, 6, 39,
|
103
|
+
6, 35, 6, 36, 6, 37, 6, 38, 6, 6,
|
104
|
+
6, 6, 6, 6, 6, 7, 1, 7, 6, 7,
|
105
|
+
6, 7, 45, 7, 49, 7, 7, 7, 7, 7,
|
106
|
+
7, 7, 10, nil, 10, 7, 10, 7, 10, nil,
|
107
|
+
10, nil, 10, 10, 10, 10, 10, 10, 10, nil,
|
108
|
+
nil, nil, 10, 30, 10, 30, 30, 30, nil, 30,
|
109
|
+
nil, 30, nil, 30, 30, 30, 30, 30, 30, 30,
|
110
|
+
29, nil, 29, 30, 29, 30, 29, nil, 29, nil,
|
111
|
+
29, 29, 29, 29, 29, 29, 29, 17, nil, 17,
|
112
|
+
29, 17, 29, 17, nil, 17, nil, 17, 17, 17,
|
113
|
+
17, 17, 17, 17, 26, nil, 26, 17, 26, 17,
|
114
|
+
26, nil, 26, nil, 26, 26, 26, 26, 26, 26,
|
115
|
+
26, 27, 27, 27, 26, 27, 26, 27, nil, 27,
|
116
|
+
nil, 27, 27, 27, 27, 27, 27, 27, nil, nil,
|
117
|
+
nil, 27, nil, 27 ]
|
101
118
|
|
102
119
|
racc_action_pointer = [
|
103
|
-
|
104
|
-
nil, nil, nil,
|
105
|
-
-
|
106
|
-
|
107
|
-
nil,
|
120
|
+
-2, 36, nil, nil, nil, nil, 36, 53, nil, nil,
|
121
|
+
70, nil, nil, nil, 24, nil, 6, 125, -13, nil,
|
122
|
+
-7, nil, nil, -11, nil, -20, 142, 159, -16, 108,
|
123
|
+
91, 26, 27, nil, 16, 32, 32, 22, 27, 15,
|
124
|
+
nil, nil, nil, nil, nil, 43, nil, nil, nil, 44,
|
125
|
+
nil, nil, nil ]
|
108
126
|
|
109
127
|
racc_action_default = [
|
110
|
-
-
|
111
|
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
128
|
+
-31, -31, -5, -16, -6, -29, -31, -8, -17, -12,
|
129
|
+
-31, -19, -13, -18, -31, -20, -31, -1, -31, -10,
|
130
|
+
-31, -2, -3, -31, -4, -25, -31, -31, -31, -9,
|
131
|
+
-31, -31, -31, -11, -25, -31, -31, -31, -31, -31,
|
132
|
+
-21, -7, -22, 53, -14, -31, -15, -30, -24, -27,
|
133
|
+
-28, -23, -26 ]
|
115
134
|
|
116
135
|
racc_goto_table = [
|
117
|
-
|
118
|
-
nil,
|
119
|
-
|
136
|
+
25, 17, 33, 28, 37, 14, nil, 27, 29, nil,
|
137
|
+
nil, 30, 33, 45, 33, 33, nil, 34, nil, nil,
|
138
|
+
nil, nil, nil, nil, 33, nil, nil, 39, 52, nil,
|
139
|
+
nil, nil, nil, nil, nil, nil, nil, 49 ]
|
120
140
|
|
121
141
|
racc_goto_check = [
|
122
|
-
|
123
|
-
nil,
|
124
|
-
|
142
|
+
12, 2, 3, 9, 13, 1, nil, 2, 2, nil,
|
143
|
+
nil, 2, 3, 13, 3, 3, nil, 12, nil, nil,
|
144
|
+
nil, nil, nil, nil, 3, nil, nil, 2, 13, nil,
|
145
|
+
nil, nil, nil, nil, nil, nil, nil, 12 ]
|
125
146
|
|
126
147
|
racc_goto_pointer = [
|
127
|
-
nil,
|
128
|
-
-
|
148
|
+
nil, 5, 1, -15, nil, nil, nil, nil, nil, -4,
|
149
|
+
nil, nil, -1, -21, nil ]
|
129
150
|
|
130
151
|
racc_goto_default = [
|
131
|
-
nil, nil, nil,
|
132
|
-
nil, nil,
|
152
|
+
nil, nil, nil, 19, 21, 22, 24, 2, 4, nil,
|
153
|
+
9, 12, nil, nil, 38 ]
|
133
154
|
|
134
155
|
racc_token_table = {
|
135
156
|
false => 0,
|
@@ -142,23 +163,26 @@ racc_token_table = {
|
|
142
163
|
:LINKEND => 7,
|
143
164
|
:INTLINKSTART => 8,
|
144
165
|
:INTLINKEND => 9,
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
166
|
+
:SECTION_START => 10,
|
167
|
+
:SECTION_END => 11,
|
168
|
+
:TEXT => 12,
|
169
|
+
:PRE => 13,
|
170
|
+
:HLINE => 14,
|
171
|
+
:SIGNATURE_NAME => 15,
|
172
|
+
:SIGNATURE_DATE => 16,
|
173
|
+
:SIGNATURE_FULL => 17,
|
174
|
+
:UL_START => 18,
|
175
|
+
:UL_END => 19,
|
176
|
+
:LI_START => 20,
|
177
|
+
:LI_END => 21,
|
178
|
+
:OL_START => 22,
|
179
|
+
:OL_END => 23,
|
180
|
+
:PARA_START => 24,
|
181
|
+
:PARA_END => 25 }
|
158
182
|
|
159
183
|
racc_use_result_var = true
|
160
184
|
|
161
|
-
racc_nt_base =
|
185
|
+
racc_nt_base = 26
|
162
186
|
|
163
187
|
Racc_arg = [
|
164
188
|
racc_action_table,
|
@@ -187,7 +211,8 @@ Racc_token_to_s_table = [
|
|
187
211
|
'LINKEND',
|
188
212
|
'INTLINKSTART',
|
189
213
|
'INTLINKEND',
|
190
|
-
'
|
214
|
+
'SECTION_START',
|
215
|
+
'SECTION_END',
|
191
216
|
'TEXT',
|
192
217
|
'PRE',
|
193
218
|
'HLINE',
|
@@ -200,14 +225,18 @@ Racc_token_to_s_table = [
|
|
200
225
|
'LI_END',
|
201
226
|
'OL_START',
|
202
227
|
'OL_END',
|
228
|
+
'PARA_START',
|
229
|
+
'PARA_END',
|
203
230
|
'$start',
|
204
231
|
'wiki',
|
205
232
|
'repeated_contents',
|
206
233
|
'contents',
|
207
234
|
'text',
|
208
235
|
'bulleted_list',
|
236
|
+
'numbered_list',
|
209
237
|
'preformatted',
|
210
238
|
'section',
|
239
|
+
'para_contents',
|
211
240
|
'element',
|
212
241
|
'formatted_element',
|
213
242
|
'list_item',
|
@@ -220,7 +249,7 @@ Racc_debug_parser = false
|
|
220
249
|
|
221
250
|
# reduce 0 omitted
|
222
251
|
|
223
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
252
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 26
|
224
253
|
def _reduce_1( val, _values, result )
|
225
254
|
@nodes.push WikiAST.new
|
226
255
|
#@nodes.last.children.insert(0, val[0])
|
@@ -230,22 +259,29 @@ module_eval <<'.,.,', 'mediawikiparser.y', 25
|
|
230
259
|
end
|
231
260
|
.,.,
|
232
261
|
|
233
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
262
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 33
|
234
263
|
def _reduce_2( val, _values, result )
|
235
264
|
result = val[0]
|
236
265
|
result
|
237
266
|
end
|
238
267
|
.,.,
|
239
268
|
|
240
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
269
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 37
|
241
270
|
def _reduce_3( val, _values, result )
|
242
271
|
result = val[0]
|
243
272
|
result
|
244
273
|
end
|
245
274
|
.,.,
|
246
275
|
|
247
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
276
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 41
|
248
277
|
def _reduce_4( val, _values, result )
|
278
|
+
result = val[0]
|
279
|
+
result
|
280
|
+
end
|
281
|
+
.,.,
|
282
|
+
|
283
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 47
|
284
|
+
def _reduce_5( val, _values, result )
|
249
285
|
p = PreformattedAST.new
|
250
286
|
p.contents = val[0]
|
251
287
|
result = p
|
@@ -253,8 +289,8 @@ module_eval <<'.,.,', 'mediawikiparser.y', 42
|
|
253
289
|
end
|
254
290
|
.,.,
|
255
291
|
|
256
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
257
|
-
def
|
292
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 54
|
293
|
+
def _reduce_6( val, _values, result )
|
258
294
|
s = SectionAST.new
|
259
295
|
s.contents = val[0][0]
|
260
296
|
s.level = val[0][1]
|
@@ -263,16 +299,41 @@ module_eval <<'.,.,', 'mediawikiparser.y', 49
|
|
263
299
|
end
|
264
300
|
.,.,
|
265
301
|
|
266
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
267
|
-
def
|
302
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 62
|
303
|
+
def _reduce_7( val, _values, result )
|
304
|
+
if val[1]
|
305
|
+
p = ParagraphAST.new
|
306
|
+
p.children = val[1]
|
307
|
+
result = p
|
308
|
+
end
|
309
|
+
result
|
310
|
+
end
|
311
|
+
.,.,
|
312
|
+
|
313
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 69
|
314
|
+
def _reduce_8( val, _values, result )
|
315
|
+
result = nil
|
316
|
+
result
|
317
|
+
end
|
318
|
+
.,.,
|
319
|
+
|
320
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 73
|
321
|
+
def _reduce_9( val, _values, result )
|
322
|
+
result = val[0]
|
323
|
+
result
|
324
|
+
end
|
325
|
+
.,.,
|
326
|
+
|
327
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 79
|
328
|
+
def _reduce_10( val, _values, result )
|
268
329
|
result = []
|
269
330
|
result << val[0]
|
270
331
|
result
|
271
332
|
end
|
272
333
|
.,.,
|
273
334
|
|
274
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
275
|
-
def
|
335
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 85
|
336
|
+
def _reduce_11( val, _values, result )
|
276
337
|
result = []
|
277
338
|
result += val[0]
|
278
339
|
result << val[1]
|
@@ -280,8 +341,8 @@ module_eval <<'.,.,', 'mediawikiparser.y', 62
|
|
280
341
|
end
|
281
342
|
.,.,
|
282
343
|
|
283
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
284
|
-
def
|
344
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 94
|
345
|
+
def _reduce_12( val, _values, result )
|
285
346
|
p = TextAST.new
|
286
347
|
p.formatting = val[0][0]
|
287
348
|
p.contents = val[0][1]
|
@@ -290,64 +351,64 @@ module_eval <<'.,.,', 'mediawikiparser.y', 71
|
|
290
351
|
end
|
291
352
|
.,.,
|
292
353
|
|
293
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
294
|
-
def
|
354
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 98
|
355
|
+
def _reduce_13( val, _values, result )
|
295
356
|
result = val[0]
|
296
357
|
result
|
297
358
|
end
|
298
359
|
.,.,
|
299
360
|
|
300
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
301
|
-
def
|
361
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 101
|
362
|
+
def _reduce_14( val, _values, result )
|
302
363
|
return [:Link, val[1]]
|
303
364
|
result
|
304
365
|
end
|
305
366
|
.,.,
|
306
367
|
|
307
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
308
|
-
def
|
368
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 103
|
369
|
+
def _reduce_15( val, _values, result )
|
309
370
|
return [:InternalLink, val[1]]
|
310
371
|
result
|
311
372
|
end
|
312
373
|
.,.,
|
313
374
|
|
314
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
315
|
-
def
|
375
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 105
|
376
|
+
def _reduce_16( val, _values, result )
|
316
377
|
return [:None, val[0]]
|
317
378
|
result
|
318
379
|
end
|
319
380
|
.,.,
|
320
381
|
|
321
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
322
|
-
def
|
382
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 107
|
383
|
+
def _reduce_17( val, _values, result )
|
323
384
|
return [:HLine, val[0]]
|
324
385
|
result
|
325
386
|
end
|
326
387
|
.,.,
|
327
388
|
|
328
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
329
|
-
def
|
389
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 109
|
390
|
+
def _reduce_18( val, _values, result )
|
330
391
|
return [:SignatureDate, val[0]]
|
331
392
|
result
|
332
393
|
end
|
333
394
|
.,.,
|
334
395
|
|
335
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
336
|
-
def
|
396
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 111
|
397
|
+
def _reduce_19( val, _values, result )
|
337
398
|
return [:SignatureName, val[0]]
|
338
399
|
result
|
339
400
|
end
|
340
401
|
.,.,
|
341
402
|
|
342
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
343
|
-
def
|
403
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 113
|
404
|
+
def _reduce_20( val, _values, result )
|
344
405
|
return [:SignatureFull, val[0]]
|
345
406
|
result
|
346
407
|
end
|
347
408
|
.,.,
|
348
409
|
|
349
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
350
|
-
def
|
410
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 123
|
411
|
+
def _reduce_21( val, _values, result )
|
351
412
|
p = FormattedAST.new
|
352
413
|
p.formatting = :Bold
|
353
414
|
p.children += val[1]
|
@@ -356,8 +417,8 @@ module_eval <<'.,.,', 'mediawikiparser.y', 100
|
|
356
417
|
end
|
357
418
|
.,.,
|
358
419
|
|
359
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
360
|
-
def
|
420
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 130
|
421
|
+
def _reduce_22( val, _values, result )
|
361
422
|
p = FormattedAST.new
|
362
423
|
p.formatting = :Italic
|
363
424
|
p.children += val[1]
|
@@ -366,10 +427,10 @@ module_eval <<'.,.,', 'mediawikiparser.y', 107
|
|
366
427
|
end
|
367
428
|
.,.,
|
368
429
|
|
369
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
370
|
-
def
|
430
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 140
|
431
|
+
def _reduce_23( val, _values, result )
|
371
432
|
list = ListAST.new
|
372
|
-
list.
|
433
|
+
list.list_type = :Bulleted
|
373
434
|
list.children << val[1]
|
374
435
|
list.children += val[2]
|
375
436
|
result = list
|
@@ -377,30 +438,41 @@ module_eval <<'.,.,', 'mediawikiparser.y', 117
|
|
377
438
|
end
|
378
439
|
.,.,
|
379
440
|
|
380
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
381
|
-
def
|
441
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 150
|
442
|
+
def _reduce_24( val, _values, result )
|
443
|
+
list = ListAST.new
|
444
|
+
list.list_type = :Numbered
|
445
|
+
list.children << val[1]
|
446
|
+
list.children += val[2]
|
447
|
+
result = list
|
448
|
+
result
|
449
|
+
end
|
450
|
+
.,.,
|
451
|
+
|
452
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 153
|
453
|
+
def _reduce_25( val, _values, result )
|
382
454
|
result = []
|
383
455
|
result
|
384
456
|
end
|
385
457
|
.,.,
|
386
458
|
|
387
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
388
|
-
def
|
459
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 159
|
460
|
+
def _reduce_26( val, _values, result )
|
389
461
|
result << val[1]
|
390
462
|
result += val[2]
|
391
463
|
result
|
392
464
|
end
|
393
465
|
.,.,
|
394
466
|
|
395
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
396
|
-
def
|
467
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 160
|
468
|
+
def _reduce_27( val, _values, result )
|
397
469
|
result = []
|
398
470
|
result
|
399
471
|
end
|
400
472
|
.,.,
|
401
473
|
|
402
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
403
|
-
def
|
474
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 169
|
475
|
+
def _reduce_28( val, _values, result )
|
404
476
|
li = ListItemAST.new
|
405
477
|
li.children += val[1]
|
406
478
|
result = li
|
@@ -408,15 +480,15 @@ module_eval <<'.,.,', 'mediawikiparser.y', 136
|
|
408
480
|
end
|
409
481
|
.,.,
|
410
482
|
|
411
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
412
|
-
def
|
483
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 172
|
484
|
+
def _reduce_29( val, _values, result )
|
413
485
|
result = val[0]
|
414
486
|
result
|
415
487
|
end
|
416
488
|
.,.,
|
417
489
|
|
418
|
-
module_eval <<'.,.,', 'mediawikiparser.y',
|
419
|
-
def
|
490
|
+
module_eval <<'.,.,', 'mediawikiparser.y', 176
|
491
|
+
def _reduce_30( val, _values, result )
|
420
492
|
result = [val[1], val[0].length]
|
421
493
|
result
|
422
494
|
end
|
@@ -9,9 +9,10 @@
|
|
9
9
|
class MediaWikiParser
|
10
10
|
|
11
11
|
token BOLDSTART BOLDEND ITALICSTART ITALICEND LINKSTART LINKEND
|
12
|
-
INTLINKSTART INTLINKEND
|
12
|
+
INTLINKSTART INTLINKEND SECTION_START SECTION_END TEXT PRE
|
13
13
|
HLINE SIGNATURE_NAME SIGNATURE_DATE SIGNATURE_FULL
|
14
14
|
UL_START UL_END LI_START LI_END OL_START OL_END
|
15
|
+
PARA_START PARA_END
|
15
16
|
|
16
17
|
rule
|
17
18
|
|
@@ -34,6 +35,10 @@ contents:
|
|
34
35
|
{
|
35
36
|
result = val[0]
|
36
37
|
}
|
38
|
+
| numbered_list
|
39
|
+
{
|
40
|
+
result = val[0]
|
41
|
+
}
|
37
42
|
| preformatted
|
38
43
|
{
|
39
44
|
p = PreformattedAST.new
|
@@ -47,8 +52,26 @@ contents:
|
|
47
52
|
s.level = val[0][1]
|
48
53
|
result = s
|
49
54
|
}
|
55
|
+
| PARA_START para_contents PARA_END
|
56
|
+
{
|
57
|
+
if val[1]
|
58
|
+
p = ParagraphAST.new
|
59
|
+
p.children = val[1]
|
60
|
+
result = p
|
61
|
+
end
|
62
|
+
}
|
50
63
|
;
|
51
64
|
|
65
|
+
#TODO: remove empty paragraphs in lexer
|
66
|
+
para_contents:
|
67
|
+
{
|
68
|
+
result = nil
|
69
|
+
}
|
70
|
+
| repeated_contents
|
71
|
+
{
|
72
|
+
result = val[0]
|
73
|
+
}
|
74
|
+
|
52
75
|
repeated_contents: contents
|
53
76
|
{
|
54
77
|
result = []
|
@@ -110,7 +133,17 @@ formatted_element: BOLDSTART repeated_contents BOLDEND
|
|
110
133
|
bulleted_list: UL_START list_item list_contents UL_END
|
111
134
|
{
|
112
135
|
list = ListAST.new
|
113
|
-
list.
|
136
|
+
list.list_type = :Bulleted
|
137
|
+
list.children << val[1]
|
138
|
+
list.children += val[2]
|
139
|
+
result = list
|
140
|
+
}
|
141
|
+
;
|
142
|
+
|
143
|
+
numbered_list: OL_START list_item list_contents OL_END
|
144
|
+
{
|
145
|
+
list = ListAST.new
|
146
|
+
list.list_type = :Numbered
|
114
147
|
list.children << val[1]
|
115
148
|
list.children += val[2]
|
116
149
|
result = list
|
@@ -140,7 +173,7 @@ preformatted: PRE
|
|
140
173
|
{ result = val[0] }
|
141
174
|
;
|
142
175
|
|
143
|
-
section:
|
176
|
+
section: SECTION_START TEXT SECTION_END
|
144
177
|
{ result = [val[1], val[0].length] }
|
145
178
|
;
|
146
179
|
|
@@ -27,9 +27,15 @@ protected
|
|
27
27
|
parse_list(c) if c.class == ListAST
|
28
28
|
parse_preformatted(c) if c.class == PreformattedAST
|
29
29
|
parse_section(c) if c.class == SectionAST
|
30
|
+
parse_paragraph(c) if c.class == ParagraphAST
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
34
|
+
#Reimplement this
|
35
|
+
def parse_paragraph(ast)
|
36
|
+
parse_wiki_ast(ast)
|
37
|
+
end
|
38
|
+
|
33
39
|
#Reimplement this
|
34
40
|
def parse_formatted(ast)
|
35
41
|
parse_wiki_ast(ast)
|