raf 0.1.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -1
- data/History.rdoc +2 -20
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -16
- data/RELEASE +1 -1
- data/VERSION +1 -1
- data/raf.gemspec +3 -1
- metadata +32 -63
- data/.document +0 -5
- data/bin/raf +0 -19
- data/bin/raf2html +0 -29
- data/lib/parserutility.rb +0 -21
- data/lib/raf.rb +0 -7
- data/lib/raf2html.rb +0 -157
- data/lib/raf2html_element.rb +0 -198
- data/lib/rafblockparser.output +0 -670
- data/lib/rafblockparser.ry +0 -358
- data/lib/rafblockparser.tab.rb +0 -715
- data/lib/rafelement.rb +0 -229
- data/lib/rafinlineparser.output +0 -1804
- data/lib/rafinlineparser.ry +0 -415
- data/lib/rafinlineparser.tab.rb +0 -972
- data/sample.raf +0 -4
- data/test/helper.rb +0 -18
- data/test/test_descblock.rb +0 -88
- data/test/test_emphasis.rb +0 -76
- data/test/test_erb.rb +0 -23
- data/test/test_footnote.rb +0 -38
- data/test/test_headline.rb +0 -43
- data/test/test_helper.rb +0 -2
- data/test/test_image.rb +0 -81
- data/test/test_italic.rb +0 -76
- data/test/test_itemlistblock.rb +0 -151
- data/test/test_numlistblock.rb +0 -342
- data/test/test_paragraph.rb +0 -76
- data/test/test_quoteblock.rb +0 -109
- data/test/test_reference.rb +0 -47
- data/test/test_ruby.rb +0 -66
- data/test/test_strike.rb +0 -76
- data/test/test_tableblock.rb +0 -63
- data/test/test_verb.rb +0 -86
- data/test/ts_block.rb +0 -10
- data/test/ts_inline.rb +0 -8
- data/test/ts_rafparser.rb +0 -4
data/lib/rafinlineparser.ry
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
# Copyright (C) garin <garin54@gmail.com> 2011
|
|
2
|
-
# See the included file COPYING for details.
|
|
3
|
-
class InlineParser
|
|
4
|
-
token EM_OPEN EM_CLOSE ITALIC_OPEN ITALIC_CLOSE STRIKE_OPEN STRIKE_CLOSE LABEL_OPEN LABEL_CLOSE REFERENCE_OPEN REFERENCE_CLOSE VERB_OPEN VERB_CLOSE ERB_OPEN ERB_CLOSE HERB_OPEN FOOTNOTE_OPEN FOOTNOTE_CLOSE RUBY_OPEN RUBY_CLOSE IMAGE_OPEN IMAGE_CLOSE MANUEDO_OPEN MANUEDO_CLOSE OTHER
|
|
5
|
-
options no_result_var
|
|
6
|
-
rule
|
|
7
|
-
content :
|
|
8
|
-
| elements
|
|
9
|
-
|
|
10
|
-
elements : elements element { val[0].push(val[1]) }
|
|
11
|
-
| element { val }
|
|
12
|
-
|
|
13
|
-
element : emphasis
|
|
14
|
-
| italic
|
|
15
|
-
| strike
|
|
16
|
-
| label
|
|
17
|
-
| reference
|
|
18
|
-
| ruby
|
|
19
|
-
| footnote
|
|
20
|
-
| image
|
|
21
|
-
| verb
|
|
22
|
-
| erb
|
|
23
|
-
| herb
|
|
24
|
-
| manuedo
|
|
25
|
-
| normal_strings
|
|
26
|
-
|
|
27
|
-
# --- inline
|
|
28
|
-
emphasis : EM_OPEN content EM_CLOSE { Emphasis.new(val[1]) }
|
|
29
|
-
italic : ITALIC_OPEN content ITALIC_CLOSE { Italic.new(val[1]) }
|
|
30
|
-
strike : STRIKE_OPEN content STRIKE_CLOSE { Strike.new(val[1]) }
|
|
31
|
-
footnote : FOOTNOTE_OPEN content FOOTNOTE_CLOSE {
|
|
32
|
-
@index[:footnote] ||= []
|
|
33
|
-
@index[:footnote] << {:content => val[1] }
|
|
34
|
-
Footnote.new([val[1], @index[:footnote].size])
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
# --- inline end
|
|
38
|
-
|
|
39
|
-
# --- image
|
|
40
|
-
image_string : OTHER
|
|
41
|
-
| EM_OPEN
|
|
42
|
-
| EM_CLOSE
|
|
43
|
-
| ITALIC_OPEN
|
|
44
|
-
| ITALIC_CLOSE
|
|
45
|
-
| STRIKE_OPEN
|
|
46
|
-
| STRIKE_CLOSE
|
|
47
|
-
| RUBY_OPEN
|
|
48
|
-
| RUBY_CLOSE
|
|
49
|
-
| MANUEDO_OPEN
|
|
50
|
-
| MANUEDO_CLOSE
|
|
51
|
-
| ERB_OPEN
|
|
52
|
-
| ERB_CLOSE
|
|
53
|
-
| HERB_OPEN
|
|
54
|
-
| REFERENCE_OPEN
|
|
55
|
-
| REFERENCE_CLOSE
|
|
56
|
-
| LABEL_OPEN
|
|
57
|
-
| LABEL_CLOSE
|
|
58
|
-
| FOOTNOTE_OPEN
|
|
59
|
-
| FOOTNOTE_CLOSE
|
|
60
|
-
| VERB_OPEN
|
|
61
|
-
| VERB_CLOSE
|
|
62
|
-
| IMAGE_OPEN
|
|
63
|
-
|
|
64
|
-
image_strings : image_strings image_string { val.join }
|
|
65
|
-
| image_string { val[0] }
|
|
66
|
-
image : IMAGE_OPEN image_strings IMAGE_CLOSE { Image.new(val[1]) }
|
|
67
|
-
|
|
68
|
-
# --- image end
|
|
69
|
-
# --- ruby
|
|
70
|
-
ruby_string : OTHER
|
|
71
|
-
| EM_OPEN
|
|
72
|
-
| EM_CLOSE
|
|
73
|
-
| ITALIC_OPEN
|
|
74
|
-
| ITALIC_CLOSE
|
|
75
|
-
| STRIKE_OPEN
|
|
76
|
-
| STRIKE_CLOSE
|
|
77
|
-
| IMAGE_OPEN
|
|
78
|
-
| IMAGE_CLOSE
|
|
79
|
-
| MANUEDO_OPEN
|
|
80
|
-
| MANUEDO_CLOSE
|
|
81
|
-
| ERB_OPEN
|
|
82
|
-
| ERB_CLOSE
|
|
83
|
-
| HERB_OPEN
|
|
84
|
-
| REFERENCE_OPEN
|
|
85
|
-
| REFERENCE_CLOSE
|
|
86
|
-
| LABEL_OPEN
|
|
87
|
-
| LABEL_CLOSE
|
|
88
|
-
| RUBY_OPEN
|
|
89
|
-
| FOOTNOTE_OPEN
|
|
90
|
-
| FOOTNOTE_CLOSE
|
|
91
|
-
| VERB_OPEN
|
|
92
|
-
| VERB_CLOSE
|
|
93
|
-
|
|
94
|
-
ruby_strings : ruby_strings ruby_string { val.join }
|
|
95
|
-
| ruby_string { val[0] }
|
|
96
|
-
|
|
97
|
-
ruby : RUBY_OPEN ruby_strings RUBY_CLOSE {
|
|
98
|
-
base, text = val[1].split("|",2)
|
|
99
|
-
text ||= base
|
|
100
|
-
Ruby.new([base, text])
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
# --- ruby end
|
|
104
|
-
# --- erb
|
|
105
|
-
erb : ERB_OPEN verb_string ERB_CLOSE {
|
|
106
|
-
e = ERB.new("<%= #{val[1]} %>")
|
|
107
|
-
Plain.new(e.result) }
|
|
108
|
-
herb : HERB_OPEN verb_string ERB_CLOSE {
|
|
109
|
-
e = ERB.new("<% #{val[1]} %>")
|
|
110
|
-
Plain.new(e.result) }
|
|
111
|
-
# --- erb end
|
|
112
|
-
# --- manuedo
|
|
113
|
-
manuedo : MANUEDO_OPEN content MANUEDO_CLOSE { Manuedo.new(val[1]) }
|
|
114
|
-
|
|
115
|
-
# --- manuedo end
|
|
116
|
-
|
|
117
|
-
# --- label
|
|
118
|
-
label_string : OTHER { val[0] }
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
label_strings : label_strings label_string { val.join }
|
|
122
|
-
| label_string { val[0] }
|
|
123
|
-
|
|
124
|
-
label : LABEL_OPEN label_strings LABEL_CLOSE {
|
|
125
|
-
label, title = val[1].split("|",2)
|
|
126
|
-
title ||= label
|
|
127
|
-
@index[:label] ||= []
|
|
128
|
-
@index[:label] << {:title => title }
|
|
129
|
-
Label.new([label.to_code, title, @index[:label].size])
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
# --- labe end
|
|
133
|
-
# --- reference : start
|
|
134
|
-
reference_string : OTHER { val[0] }
|
|
135
|
-
|
|
136
|
-
reference_strings : reference_strings reference_string { val.join }
|
|
137
|
-
| reference_string { val[0] }
|
|
138
|
-
|
|
139
|
-
reference : REFERENCE_OPEN reference_strings REFERENCE_CLOSE {
|
|
140
|
-
title, uri = val[1].split("|",2)
|
|
141
|
-
uri ||= title
|
|
142
|
-
uri = "#" + uri.to_code if uri.gsub(/^\s*https*:\/\//,"") == uri
|
|
143
|
-
Reference.new([title, uri])
|
|
144
|
-
}
|
|
145
|
-
# --- reference : end
|
|
146
|
-
# --- verb
|
|
147
|
-
verb_string : OTHER
|
|
148
|
-
| EM_OPEN
|
|
149
|
-
| EM_CLOSE
|
|
150
|
-
| ITALIC_OPEN
|
|
151
|
-
| ITALIC_CLOSE
|
|
152
|
-
| STRIKE_OPEN
|
|
153
|
-
| STRIKE_CLOSE
|
|
154
|
-
| IMAGE_OPEN
|
|
155
|
-
| IMAGE_CLOSE
|
|
156
|
-
| MANUEDO_OPEN
|
|
157
|
-
| MANUEDO_CLOSE
|
|
158
|
-
| ERB_OPEN
|
|
159
|
-
| ERB_CLOSE
|
|
160
|
-
| HERB_OPEN
|
|
161
|
-
| REFERENCE_OPEN
|
|
162
|
-
| REFERENCE_CLOSE
|
|
163
|
-
| LABEL_OPEN
|
|
164
|
-
| LABEL_CLOSE
|
|
165
|
-
| RUBY_OPEN
|
|
166
|
-
| RUBY_CLOSE
|
|
167
|
-
| FOOTNOTE_OPEN
|
|
168
|
-
| FOOTNOTE_CLOSE
|
|
169
|
-
| VERB_OPEN
|
|
170
|
-
|
|
171
|
-
verb_strings : verb_string
|
|
172
|
-
| verb_strings verb_string { val }
|
|
173
|
-
|
|
174
|
-
verb : VERB_OPEN verb_strings VERB_CLOSE { Verb.new(val[1])}
|
|
175
|
-
|
|
176
|
-
# --- verb end
|
|
177
|
-
# --- normal
|
|
178
|
-
normal_strings : normal_string { Plain.new(val[0]) }
|
|
179
|
-
| normal_strings normal_string { Plain.new([val[0].contents, val[1]]) }
|
|
180
|
-
|
|
181
|
-
normal_string : OTHER { val[0] }
|
|
182
|
-
# --- normal end
|
|
183
|
-
|
|
184
|
-
---- inner
|
|
185
|
-
include ParserUtility
|
|
186
|
-
|
|
187
|
-
EM_OPEN = '((*'
|
|
188
|
-
EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
|
|
189
|
-
EM_CLOSE = '*))'
|
|
190
|
-
EM_CLOSE_RE = /\A#{Regexp.quote(EM_CLOSE)}/
|
|
191
|
-
|
|
192
|
-
ITALIC_OPEN = '((_'
|
|
193
|
-
ITALIC_OPEN_RE = /\A#{Regexp.quote(ITALIC_OPEN)}/
|
|
194
|
-
ITALIC_CLOSE = '_))'
|
|
195
|
-
ITALIC_CLOSE_RE = /\A#{Regexp.quote(ITALIC_CLOSE)}/
|
|
196
|
-
|
|
197
|
-
STRIKE_OPEN = '((-'
|
|
198
|
-
STRIKE_OPEN_RE = /\A#{Regexp.quote(STRIKE_OPEN)}/
|
|
199
|
-
STRIKE_CLOSE = '-))'
|
|
200
|
-
STRIKE_CLOSE_RE = /\A#{Regexp.quote(STRIKE_CLOSE)}/
|
|
201
|
-
|
|
202
|
-
RUBY_OPEN = '((^'
|
|
203
|
-
RUBY_OPEN_RE = /\A#{Regexp.quote(RUBY_OPEN)}/
|
|
204
|
-
RUBY_CLOSE = '^))'
|
|
205
|
-
RUBY_CLOSE_RE = /\A#{Regexp.quote(RUBY_CLOSE)}/
|
|
206
|
-
|
|
207
|
-
FOOTNOTE_OPEN = '((['
|
|
208
|
-
FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
|
|
209
|
-
FOOTNOTE_CLOSE = ']))'
|
|
210
|
-
FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
|
|
211
|
-
|
|
212
|
-
IMAGE_OPEN = '(($'
|
|
213
|
-
IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
|
|
214
|
-
IMAGE_CLOSE = '$))'
|
|
215
|
-
IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
|
|
216
|
-
|
|
217
|
-
LABEL_OPEN = '((>'
|
|
218
|
-
LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
|
|
219
|
-
LABEL_CLOSE = '<))'
|
|
220
|
-
LABEL_CLOSE_RE = /\A#{Regexp.quote(LABEL_CLOSE)}/
|
|
221
|
-
|
|
222
|
-
LABEL_HTML_OPEN = '((>'
|
|
223
|
-
LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
|
|
224
|
-
LABEL_HTML_CLOSE = '<))'
|
|
225
|
-
LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
|
|
226
|
-
|
|
227
|
-
REFERENCE_OPEN = '((<'
|
|
228
|
-
REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
|
|
229
|
-
REFERENCE_CLOSE = '>))'
|
|
230
|
-
REFERENCE_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_CLOSE)}/
|
|
231
|
-
|
|
232
|
-
REFERENCE_HTML_OPEN = '((<'
|
|
233
|
-
REFERENCE_HTML_OPEN_RE = /\A#{Regexp.quote(REFERENCE_HTML_OPEN)}/
|
|
234
|
-
REFERENCE_HTML_CLOSE = '>))'
|
|
235
|
-
REFERENCE_HTML_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_HTML_CLOSE)}/
|
|
236
|
-
|
|
237
|
-
VERB_OPEN = "(('"
|
|
238
|
-
VERB_OPEN_RE = /\A#{Regexp.quote(VERB_OPEN)}/
|
|
239
|
-
VERB_CLOSE = "'))"
|
|
240
|
-
VERB_CLOSE_RE = /\A#{Regexp.quote(VERB_CLOSE)}/
|
|
241
|
-
|
|
242
|
-
MANUEDO_OPEN = "((/"
|
|
243
|
-
MANUEDO_OPEN_RE = /\A#{Regexp.quote(MANUEDO_OPEN)}/
|
|
244
|
-
MANUEDO_CLOSE = "/))"
|
|
245
|
-
MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
|
|
246
|
-
|
|
247
|
-
ERB_OPEN = "<%="
|
|
248
|
-
ERB_OPEN_RE = /\A#{Regexp.quote(ERB_OPEN)}/
|
|
249
|
-
ERB_CLOSE = "%>"
|
|
250
|
-
ERB_CLOSE_RE = /\A#{Regexp.quote(ERB_CLOSE)}/
|
|
251
|
-
|
|
252
|
-
HERB_OPEN = "<%"
|
|
253
|
-
HERB_OPEN_RE = /\A#{Regexp.quote(HERB_OPEN)}/
|
|
254
|
-
|
|
255
|
-
# URL = "URL:"
|
|
256
|
-
# URL_RE = /\A#{Regexp.quote(URL)}/
|
|
257
|
-
|
|
258
|
-
#other_re_mode = Regexp::EXTENDED
|
|
259
|
-
other_re_mode = Regexp::MULTILINE
|
|
260
|
-
OTHER_RE = Regexp.new(
|
|
261
|
-
"\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|#{Regexp.quote(ITALIC_OPEN)}|#{Regexp.quote(ITALIC_CLOSE)}|#{Regexp.quote(STRIKE_OPEN)}|#{Regexp.quote(STRIKE_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(IMAGE_OPEN)}|#{Regexp.quote(IMAGE_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_HTML_OPEN)}|#{Regexp.quote(LABEL_HTML_CLOSE)}|#{Regexp.quote(REFERENCE_OPEN)}|#{Regexp.quote(REFERENCE_CLOSE)}|#{Regexp.quote(REFERENCE_HTML_OPEN)}|#{Regexp.quote(REFERENCE_HTML_CLOSE)}|#{Regexp.quote(MANUEDO_OPEN)}|#{Regexp.quote(MANUEDO_CLOSE)}|#{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}|#{Regexp.quote(ERB_OPEN)}|#{Regexp.quote(ERB_CLOSE)}|#{Regexp.quote(HERB_OPEN)})", other_re_mode)
|
|
262
|
-
|
|
263
|
-
def parse(src)
|
|
264
|
-
@src = StringScanner.new(Array(src).join)
|
|
265
|
-
@pre = ""
|
|
266
|
-
@@yydebug = false
|
|
267
|
-
@view_token_type = false
|
|
268
|
-
do_parse
|
|
269
|
-
end
|
|
270
|
-
def initialize
|
|
271
|
-
@index = {}
|
|
272
|
-
end
|
|
273
|
-
attr_reader :index
|
|
274
|
-
|
|
275
|
-
def next_token
|
|
276
|
-
return [false, false] if @src.eos?
|
|
277
|
-
if ret = @src.scan(EM_OPEN_RE)
|
|
278
|
-
puts "i: EM_OPEN: #{ret}" if @view_token_type
|
|
279
|
-
@pre << ret
|
|
280
|
-
[:EM_OPEN, ret]
|
|
281
|
-
elsif ret = @src.scan(EM_CLOSE_RE)
|
|
282
|
-
puts "i: EM_CLOSE: #{ret}" if @view_token_type
|
|
283
|
-
@pre << ret
|
|
284
|
-
[:EM_CLOSE, ret]
|
|
285
|
-
elsif ret = @src.scan(ITALIC_OPEN_RE)
|
|
286
|
-
puts "i: ITALIC_OPEN: #{ret}" if @view_token_type
|
|
287
|
-
@pre << ret
|
|
288
|
-
[:ITALIC_OPEN, ret]
|
|
289
|
-
elsif ret = @src.scan(ITALIC_CLOSE_RE)
|
|
290
|
-
puts "i: ITALIC_CLOSE: #{ret}" if @view_token_type
|
|
291
|
-
@pre << ret
|
|
292
|
-
[:ITALIC_CLOSE, ret]
|
|
293
|
-
elsif ret = @src.scan(STRIKE_OPEN_RE)
|
|
294
|
-
@pre << ret
|
|
295
|
-
puts "i: STRIKE_OPEN: #{ret}" if @view_token_type
|
|
296
|
-
[:STRIKE_OPEN, ret]
|
|
297
|
-
elsif ret = @src.scan(STRIKE_CLOSE_RE)
|
|
298
|
-
@pre << ret
|
|
299
|
-
puts "i: STRIKE_CLOSE: #{ret}" if @view_token_type
|
|
300
|
-
[:STRIKE_CLOSE, ret]
|
|
301
|
-
elsif ret = @src.scan(LABEL_OPEN_RE)
|
|
302
|
-
@pre << ret
|
|
303
|
-
puts "i: LABEL_OPEN: #{ret}" if @view_token_type
|
|
304
|
-
[:LABEL_OPEN, ret]
|
|
305
|
-
elsif ret = @src.scan(LABEL_CLOSE_RE)
|
|
306
|
-
puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
|
|
307
|
-
@pre << ret
|
|
308
|
-
[:LABEL_CLOSE, ret]
|
|
309
|
-
elsif ret = @src.scan(LABEL_HTML_OPEN_RE)
|
|
310
|
-
@pre << ret
|
|
311
|
-
puts "i: LABEL_OPEN: #{ret}" if @view_token_type
|
|
312
|
-
[:LABEL_OPEN, ret]
|
|
313
|
-
elsif ret = @src.scan(LABEL_HTML_CLOSE_RE)
|
|
314
|
-
puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
|
|
315
|
-
@pre << ret
|
|
316
|
-
[:LABEL_CLOSE, ret]
|
|
317
|
-
elsif ret = @src.scan(REFERENCE_OPEN_RE)
|
|
318
|
-
puts "i: REFERENCE_OPEN: #{ret}" if @view_token_type
|
|
319
|
-
@pre << ret
|
|
320
|
-
[:REFERENCE_OPEN, ret]
|
|
321
|
-
elsif ret = @src.scan(REFERENCE_CLOSE_RE)
|
|
322
|
-
puts "i: REFERENCE_CLOSE: #{ret}" if @view_token_type
|
|
323
|
-
@pre << ret
|
|
324
|
-
[:REFERENCE_CLOSE, ret]
|
|
325
|
-
elsif ret = @src.scan(REFERENCE_HTML_OPEN_RE)
|
|
326
|
-
puts "i: REFERENCE_HTML_OPEN: #{ret}" if @view_token_type
|
|
327
|
-
@pre << ret
|
|
328
|
-
[:REFERENCE_OPEN, ret]
|
|
329
|
-
elsif ret = @src.scan(REFERENCE_HTML_CLOSE_RE)
|
|
330
|
-
puts "i: REFERENCE_HTML_CLOSE: #{ret}" if @view_token_type
|
|
331
|
-
@pre << ret
|
|
332
|
-
[:REFERENCE_CLOSE, ret]
|
|
333
|
-
elsif ret = @src.scan(VERB_OPEN_RE)
|
|
334
|
-
puts "i: VERB_OPEN: #{ret}" if @view_token_type
|
|
335
|
-
@pre << ret
|
|
336
|
-
[:VERB_OPEN, ret]
|
|
337
|
-
elsif ret = @src.scan(VERB_CLOSE_RE)
|
|
338
|
-
puts "i: VERB_CLOSE: #{ret}" if @view_token_type
|
|
339
|
-
@pre << ret
|
|
340
|
-
[:VERB_CLOSE, ret]
|
|
341
|
-
elsif ret = @src.scan(RUBY_OPEN_RE)
|
|
342
|
-
puts "i: RUBY_OPEN: #{ret}" if @view_token_type
|
|
343
|
-
@pre << ret
|
|
344
|
-
[:RUBY_OPEN, ret]
|
|
345
|
-
elsif ret = @src.scan(RUBY_CLOSE_RE)
|
|
346
|
-
puts "i: RUBY_CLOSE: #{ret}" if @view_token_type
|
|
347
|
-
@pre << ret
|
|
348
|
-
[:RUBY_CLOSE, ret]
|
|
349
|
-
elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
|
|
350
|
-
puts "i: FOOTNOTE_OPEN: #{ret}" if @view_token_type
|
|
351
|
-
@pre << ret
|
|
352
|
-
[:FOOTNOTE_OPEN, ret]
|
|
353
|
-
elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
|
|
354
|
-
puts "i: FOOTNOTE_CLOSE: #{ret}" if @view_token_type
|
|
355
|
-
@pre << ret
|
|
356
|
-
[:FOOTNOTE_CLOSE, ret]
|
|
357
|
-
elsif ret = @src.scan(IMAGE_OPEN_RE)
|
|
358
|
-
puts "i: IMAGE_OPEN: #{ret}" if @view_token_type
|
|
359
|
-
@pre << ret
|
|
360
|
-
[:IMAGE_OPEN, ret]
|
|
361
|
-
elsif ret = @src.scan(IMAGE_CLOSE_RE)
|
|
362
|
-
puts "i: IMAGE_CLOSE: #{ret}" if @view_token_type
|
|
363
|
-
@pre << ret
|
|
364
|
-
[:IMAGE_CLOSE, ret]
|
|
365
|
-
elsif ret = @src.scan(MANUEDO_OPEN_RE)
|
|
366
|
-
puts "i: MANUEDO_OPEN: #{ret}" if @view_token_type
|
|
367
|
-
@pre << ret
|
|
368
|
-
[:MANUEDO_OPEN, ret]
|
|
369
|
-
elsif ret = @src.scan(MANUEDO_CLOSE_RE)
|
|
370
|
-
puts "i: MANUED_CLOSE: #{ret}" if @view_token_type
|
|
371
|
-
@pre << ret
|
|
372
|
-
[:MANUEDO_CLOSE, ret]
|
|
373
|
-
elsif ret = @src.scan(ERB_OPEN_RE)
|
|
374
|
-
puts "i: ERB_OPEN: #{ret}" if @view_token_type
|
|
375
|
-
@pre << ret
|
|
376
|
-
[:ERB_OPEN, ret]
|
|
377
|
-
elsif ret = @src.scan(ERB_CLOSE_RE)
|
|
378
|
-
puts "i: ERB_CLOSE: #{ret}" if @view_token_type
|
|
379
|
-
@pre << ret
|
|
380
|
-
[:ERB_CLOSE, ret]
|
|
381
|
-
elsif ret = @src.scan(HERB_OPEN_RE)
|
|
382
|
-
puts "i: HERB_OPEN: #{ret}" if @view_token_type
|
|
383
|
-
@pre << ret
|
|
384
|
-
[:HERB_OPEN, ret]
|
|
385
|
-
elsif ret = @src.scan(OTHER_RE)
|
|
386
|
-
puts "i: OTHER_RE: #{ret}" if @view_token_type
|
|
387
|
-
@pre << ret
|
|
388
|
-
[:OTHER, ret]
|
|
389
|
-
else
|
|
390
|
-
puts "i: OTHER_RE(else): #{ret}" if @view_token_type
|
|
391
|
-
ret = @src.rest
|
|
392
|
-
@pre << ret
|
|
393
|
-
@src.terminate
|
|
394
|
-
[:OTHER, ret]
|
|
395
|
-
end
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
---- header
|
|
399
|
-
require "parserutility"
|
|
400
|
-
require 'strscan'
|
|
401
|
-
require 'erb'
|
|
402
|
-
require 'rafelement'
|
|
403
|
-
|
|
404
|
-
module Raf
|
|
405
|
-
---- footer
|
|
406
|
-
if __FILE__ == $0
|
|
407
|
-
raf = InlineParser.new
|
|
408
|
-
src = $stdin.readline
|
|
409
|
-
nodes = raf.parse(src)
|
|
410
|
-
puts "----- output -----"
|
|
411
|
-
nodes.each do |n|
|
|
412
|
-
puts n.apply
|
|
413
|
-
end
|
|
414
|
-
end
|
|
415
|
-
end # end of module Raf
|