raf-parser 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6113f8995ef114b34f297e77f0240802da0d82df
4
- data.tar.gz: 54ee9948faae6027e31b0fa0f41a1542c35c5021
3
+ metadata.gz: 9ff8bb7faa523d2198e34fc5adb121ccf7a7a2fa
4
+ data.tar.gz: 774ea71d98e597b853dad20421e131ca97c3cffe
5
5
  SHA512:
6
- metadata.gz: f654a881270669c0d686846d08c545346ad57e2a8213bf3fb8c4e82622ffaec4632a3c2b6f64fed46464f6b1ac93dbb7f8ee19b213f515dcd50ae961958839b3
7
- data.tar.gz: 5fb90c38dd38e60ad874f7af49a9eca1949a13fe4bdeaa47a326135cc13639018b3c71f9468997db18c942234fd46a5ba1578204ea6c98f23881417595a731dd
6
+ metadata.gz: 2e50178436176af3197cd9e30cb9d7657a6dc8f53df3bdebb7ca3e365414d1e6fdaea0d77b0549777814e3d6c8c083eee27a935dc13d0d5fbfefc61bee188b40
7
+ data.tar.gz: 7f6adf1e900ab173b585ef905d189597e9d94a768abce57cbd688ead348a3f8366387e07f3fd61d4584ce8419a9668a9b86dde94d565cc2173c511983225dfd0
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raf (0.2.0)
4
+ raf-parser (0.2.2)
5
+ mimemagic
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ mimemagic (0.2.1)
9
11
  rake (10.1.0)
10
12
 
11
13
  PLATFORMS
@@ -13,5 +15,5 @@ PLATFORMS
13
15
 
14
16
  DEPENDENCIES
15
17
  bundler (~> 1.3)
16
- raf!
18
+ raf-parser!
17
19
  rake
data/History.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ == 0.2.3 2013-12-10
2
+ * new: メディアファイルを置くディレクトリを指定する @options[:media_directory] を 追加
3
+ * new: ラベルリンク(LabelLink)用の構文((=..=))を追加
4
+ * new: .% 構文用の @options[:extension] を追加
5
+ * new: URI形式で指定した Reference の拡張子に .% 構文の追加
6
+ * new: 依存関係に mimemagic パッケージを追加
7
+ * change: IMAGEエレメントを廃止して、MEDIAエレメントを追加
8
+ * change: label_link の label の先頭から "#" を削除
9
+ * change: リファレンス構文((<..>)) からラベルリンクの機能を削除
10
+ * change: reference を http[s]:// だけでなく URI 形式は全て外部への参照とするように変更
11
+ * change: variables書式((@..@))の変数定義でも値を表示するように変更
12
+ * change: ERBで可能な処理をセーフレベル4に限定
13
+
1
14
  == 0.2.2 2013-12-05
2
15
  * 変数定義の VARIABLE((@..|..@))書式を追加
3
16
  * 空文字を返す Empty クラスを追加
data/RELEASE CHANGED
@@ -1 +1 @@
1
- 2013-12-04
1
+ 2013-12-10
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
data/lib/raf-parser.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) garin <garin54@gmail.com> 2011-2013
3
3
  # See the included file COPYING for details.
4
+ require 'bundler/setup'
4
5
  require "rafblockparser.tab"
5
6
 
6
7
  module Raf
@@ -138,8 +138,8 @@ class Line
138
138
  end
139
139
 
140
140
 
141
- def initialize
142
- @inline_parser = InlineParser.new
141
+ def initialize(options = {})
142
+ @inline_parser = InlineParser.new(options)
143
143
  @metadata = {}
144
144
  @inline_index = @inline_parser.index
145
145
  @index = {}
@@ -150,7 +150,7 @@ attr_reader :metadata, :inline_index, :index
150
150
  def parse(src)
151
151
  @no = 0
152
152
  # srcをerbで処理
153
- src = ERB.new(src.join).result(binding).split("\n").map {|s| "#{s}\n"}
153
+ src = ERB.new(src.join,4).result(binding.taint).split("\n").map {|s| "#{s}\n"}
154
154
 
155
155
  @src = Array(src)
156
156
  @line = Line.new("")
@@ -37,8 +37,8 @@ class Line
37
37
  end
38
38
 
39
39
 
40
- def initialize
41
- @inline_parser = InlineParser.new
40
+ def initialize(options = {})
41
+ @inline_parser = InlineParser.new(options)
42
42
  @metadata = {}
43
43
  @inline_index = @inline_parser.index
44
44
  @index = {}
@@ -49,7 +49,7 @@ attr_reader :metadata, :inline_index, :index
49
49
  def parse(src)
50
50
  @no = 0
51
51
  # srcをerbで処理
52
- src = ERB.new(src.join).result(binding).split("\n").map {|s| "#{s}\n"}
52
+ src = ERB.new(src.join,4).result(binding.taint).split("\n").map {|s| "#{s}\n"}
53
53
 
54
54
  @src = Array(src)
55
55
  @line = Line.new("")
data/lib/rafelement.rb CHANGED
@@ -163,10 +163,17 @@ module Raf
163
163
  end
164
164
  end
165
165
 
166
+ class LabelLink < Element
167
+ # @contents = [title, uri]
168
+ def apply
169
+ "<LabelLink>Label:#{@contents[0]},Title:#{@contents[1]}</LabelLink>"
170
+ end
171
+ end
172
+
166
173
  class Reference < Element
167
174
  # @contents = [title, uri]
168
175
  def apply
169
- "#{@contents}"
176
+ "<Reference>Title:#{@contents[0]},Url:#{@contents[1]}</Reference>"
170
177
  end
171
178
  end
172
179
 
@@ -219,9 +226,10 @@ module Raf
219
226
  end
220
227
  end
221
228
 
222
- class Image < Element
229
+ class Media < Element
223
230
  def apply
224
- "<Image>#{@contents}</Image>"
231
+ # @contents = [Name, Mime::MediaType, Mime::SubType]
232
+ "<Media>Name:#{@contents[0]},Mime::MediaType:#{@contents[1]},Mime::SubType:#{@contents[2]}</Media>"
225
233
  end
226
234
  end
227
235
 
@@ -238,7 +246,6 @@ module Raf
238
246
  end
239
247
  end
240
248
 
241
-
242
249
  class String
243
250
  def to_code
244
251
  self.lines.to_a.pack('m').tr("012345679+/=\n", 'abcdefghiPSIQ').strip
@@ -1,7 +1,7 @@
1
1
  # Copyright (C) garin <garin54@gmail.com> 2011
2
2
  # See the included file COPYING for details.
3
3
  class InlineParser
4
- token EM_OPEN EM_CLOSE ITALIC_OPEN ITALIC_CLOSE STRIKE_OPEN STRIKE_CLOSE CODE_OPEN CODE_CLOSE KBD_OPEN KBD_CLOSE LABEL_OPEN LABEL_CLOSE REFERENCE_OPEN REFERENCE_CLOSE VERB_OPEN VERB_CLOSE FOOTNOTE_OPEN FOOTNOTE_CLOSE RUBY_OPEN RUBY_CLOSE VARIABLE_OPEN VARIABLE_CLOSE IMAGE_OPEN IMAGE_CLOSE MANUEDO_OPEN MANUEDO_CLOSE OTHER
4
+ token EM_OPEN EM_CLOSE ITALIC_OPEN ITALIC_CLOSE STRIKE_OPEN STRIKE_CLOSE CODE_OPEN CODE_CLOSE KBD_OPEN KBD_CLOSE LABEL_OPEN LABEL_CLOSE LABEL_LINK_OPEN LABEL_LINK_CLOSE REFERENCE_OPEN REFERENCE_CLOSE VERB_OPEN VERB_CLOSE FOOTNOTE_OPEN FOOTNOTE_CLOSE RUBY_OPEN RUBY_CLOSE VARIABLE_OPEN VARIABLE_CLOSE MEDIA_OPEN MEDIA_CLOSE MANUEDO_OPEN MANUEDO_CLOSE OTHER
5
5
  options no_result_var
6
6
  rule
7
7
  content :
@@ -16,11 +16,12 @@ class InlineParser
16
16
  | code
17
17
  | kbd
18
18
  | label
19
+ | label_link
19
20
  | reference
20
21
  | ruby
21
22
  | variable
22
23
  | footnote
23
- | image
24
+ | media
24
25
  | verb
25
26
  | manuedo
26
27
  | normal_strings
@@ -39,8 +40,8 @@ class InlineParser
39
40
 
40
41
  # --- inline end
41
42
 
42
- # --- image
43
- image_string : OTHER
43
+ # --- media
44
+ media_string : OTHER
44
45
  | EM_OPEN
45
46
  | EM_CLOSE
46
47
  | ITALIC_OPEN
@@ -61,17 +62,32 @@ class InlineParser
61
62
  | REFERENCE_CLOSE
62
63
  | LABEL_OPEN
63
64
  | LABEL_CLOSE
65
+ | LABEL_LINK_OPEN
66
+ | LABEL_LINK_CLOSE
64
67
  | FOOTNOTE_OPEN
65
68
  | FOOTNOTE_CLOSE
66
69
  | VERB_OPEN
67
70
  | VERB_CLOSE
68
- | IMAGE_OPEN
69
-
70
- image_strings : image_strings image_string { val.join }
71
- | image_string { val[0] }
72
- image : IMAGE_OPEN image_strings IMAGE_CLOSE { Image.new(val[1]) }
73
-
74
- # --- image end
71
+ | MEDIA_OPEN
72
+
73
+ media_strings : media_strings media_string { val.join }
74
+ | media_string {
75
+ unless @options[:media_directory].nil? || @options[:media_directory].empty?
76
+ val[0] = File.join(@options[:media_directory],val[0]) unless val[0] =~ /^.*:\/\/.*/
77
+ end
78
+ val[0]
79
+ }
80
+ media : MEDIA_OPEN media_strings MEDIA_CLOSE {
81
+ mime = MimeMagic.by_extension(val[1].split(".").last)
82
+ unless mime.nil?
83
+ mediatype, subtype = mime.mediatype, mime.subtype
84
+ else
85
+ mediatype, subtype = "",""
86
+ end
87
+ Media.new([val[1],mediatype,subtype])
88
+ }
89
+
90
+ # --- media end
75
91
  # --- ruby
76
92
  ruby_string : OTHER
77
93
  | EM_OPEN
@@ -84,14 +100,16 @@ class InlineParser
84
100
  | CODE_CLOSE
85
101
  | KBD_OPEN
86
102
  | KBD_CLOSE
87
- | IMAGE_OPEN
88
- | IMAGE_CLOSE
103
+ | MEDIA_OPEN
104
+ | MEDIA_CLOSE
89
105
  | MANUEDO_OPEN
90
106
  | MANUEDO_CLOSE
91
107
  | REFERENCE_OPEN
92
108
  | REFERENCE_CLOSE
93
109
  | LABEL_OPEN
94
110
  | LABEL_CLOSE
111
+ | LABEL_LINK_OPEN
112
+ | LABEL_LINK_CLOSE
95
113
  | RUBY_OPEN
96
114
  | FOOTNOTE_OPEN
97
115
  | FOOTNOTE_CLOSE
@@ -122,14 +140,16 @@ class InlineParser
122
140
  | CODE_CLOSE
123
141
  | KBD_OPEN
124
142
  | KBD_CLOSE
125
- | IMAGE_OPEN
126
- | IMAGE_CLOSE
143
+ | MEDIA_OPEN
144
+ | MEDIA_CLOSE
127
145
  | MANUEDO_OPEN
128
146
  | MANUEDO_CLOSE
129
147
  | REFERENCE_OPEN
130
148
  | REFERENCE_CLOSE
131
149
  | LABEL_OPEN
132
150
  | LABEL_CLOSE
151
+ | LABEL_LINK_OPEN
152
+ | LABEL_LINK_CLOSE
133
153
  | RUBY_OPEN
134
154
  | RUBY_CLOSE
135
155
  | VARIABLE_OPEN
@@ -143,20 +163,16 @@ class InlineParser
143
163
 
144
164
  variable : VARIABLE_OPEN variable_strings VARIABLE_CLOSE {
145
165
  base, text = val[1].split("=",2)
146
- unless text.nil?
147
- @variables ||= {}
148
- @variables[base] = text
149
- Empty.new("")
150
- else
151
- value = @variables[base]
152
- unless value.nil?
153
- parser = InlineParser.new
154
- value = parser.parse(value).map do |n| n.apply end
155
- else # 変数が未定義
156
- value = base
157
- end
158
- Variable.new(value)
166
+ @variables ||= {}
167
+ @variables[base] = text unless text.nil?
168
+ value = @variables[base]
169
+ unless value.nil?
170
+ parser = InlineParser.new
171
+ value = parser.parse(value).map do |n| n.apply end
172
+ else # 変数が未定義
173
+ value = base
159
174
  end
175
+ Variable.new(value)
160
176
  }
161
177
  # --- variable end
162
178
  # --- manuedo
@@ -180,6 +196,19 @@ class InlineParser
180
196
  }
181
197
 
182
198
  # --- labe end
199
+ # --- label link: start
200
+ label_link_string : OTHER { val[0] }
201
+
202
+ label_link_strings : label_link_strings label_link_string { val.join }
203
+ | label_link_string { val[0] }
204
+
205
+ label_link : LABEL_LINK_OPEN label_link_strings LABEL_LINK_CLOSE {
206
+ label, title = val[1].split("|",2)
207
+ title ||= label
208
+ LabelLink.new([label.to_code, title])
209
+ }
210
+ # --- label link: end
211
+
183
212
  # --- reference : start
184
213
  reference_string : OTHER { val[0] }
185
214
 
@@ -189,7 +218,10 @@ class InlineParser
189
218
  reference : REFERENCE_OPEN reference_strings REFERENCE_CLOSE {
190
219
  title, uri = val[1].split("|",2)
191
220
  uri ||= title
192
- uri = "#" + uri.to_code if uri.gsub(/^\s*https*:\/\//,"") == uri
221
+ if uri.strip[-2,2] == ".%" and ! @options[:extension].nil?
222
+ uri.slice!(-2,2)
223
+ uri = "#{uri}#{@options[:extension]}"
224
+ end
193
225
  Reference.new([title, uri])
194
226
  }
195
227
  # --- reference : end
@@ -205,14 +237,16 @@ class InlineParser
205
237
  | CODE_CLOSE
206
238
  | KBD_OPEN
207
239
  | KBD_CLOSE
208
- | IMAGE_OPEN
209
- | IMAGE_CLOSE
240
+ | MEDIA_OPEN
241
+ | MEDIA_CLOSE
210
242
  | MANUEDO_OPEN
211
243
  | MANUEDO_CLOSE
212
244
  | REFERENCE_OPEN
213
245
  | REFERENCE_CLOSE
214
246
  | LABEL_OPEN
215
247
  | LABEL_CLOSE
248
+ | LABEL_LINK_OPEN
249
+ | LABEL_LINK_CLOSE
216
250
  | RUBY_OPEN
217
251
  | RUBY_CLOSE
218
252
  | VARIABLE_OPEN
@@ -277,10 +311,10 @@ FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
277
311
  FOOTNOTE_CLOSE = ']))'
278
312
  FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
279
313
 
280
- IMAGE_OPEN = '(($'
281
- IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
282
- IMAGE_CLOSE = '$))'
283
- IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
314
+ MEDIA_OPEN = '(($'
315
+ MEDIA_OPEN_RE = /\A#{Regexp.quote(MEDIA_OPEN)}/
316
+ MEDIA_CLOSE = '$))'
317
+ MEDIA_CLOSE_RE = /\A#{Regexp.quote(MEDIA_CLOSE)}/
284
318
 
285
319
  LABEL_OPEN = '((>'
286
320
  LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
@@ -292,6 +326,11 @@ LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
292
326
  LABEL_HTML_CLOSE = '&lt;))'
293
327
  LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
294
328
 
329
+ LABEL_LINK_OPEN = '((='
330
+ LABEL_LINK_OPEN_RE = /\A#{Regexp.quote(LABEL_LINK_OPEN)}/
331
+ LABEL_LINK_CLOSE = '=))'
332
+ LABEL_LINK_CLOSE_RE = /\A#{Regexp.quote(LABEL_LINK_CLOSE)}/
333
+
295
334
  REFERENCE_OPEN = '((<'
296
335
  REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
297
336
  REFERENCE_CLOSE = '>))'
@@ -318,7 +357,7 @@ MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
318
357
  #other_re_mode = Regexp::EXTENDED
319
358
  other_re_mode = Regexp::MULTILINE
320
359
  OTHER_RE = Regexp.new(
321
- "\\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(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_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)})", other_re_mode)
360
+ "\\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(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_CLOSE)}|#{Regexp.quote(MEDIA_OPEN)}|#{Regexp.quote(MEDIA_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_LINK_OPEN)}|#{Regexp.quote(LABEL_LINK_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)})", other_re_mode)
322
361
 
323
362
  def parse(src)
324
363
  @src = StringScanner.new(Array(src).join)
@@ -327,7 +366,8 @@ def parse(src)
327
366
  @view_token_type = false
328
367
  do_parse
329
368
  end
330
- def initialize
369
+ def initialize(options = {})
370
+ @options = options
331
371
  @index = {}
332
372
  end
333
373
  attr_reader :index
@@ -382,6 +422,14 @@ def next_token
382
422
  puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
383
423
  @pre << ret
384
424
  [:LABEL_CLOSE, ret]
425
+ elsif ret = @src.scan(LABEL_LINK_OPEN_RE)
426
+ @pre << ret
427
+ puts "i: LABEL_LINK_OPEN: #{ret}" if @view_token_type
428
+ [:LABEL_LINK_OPEN, ret]
429
+ elsif ret = @src.scan(LABEL_LINK_CLOSE_RE)
430
+ puts "i: LABEL_LINK_CLOSE: #{ret}" if @view_token_type
431
+ @pre << ret
432
+ [:LABEL_LINK_CLOSE, ret]
385
433
  elsif ret = @src.scan(LABEL_HTML_OPEN_RE)
386
434
  @pre << ret
387
435
  puts "i: LABEL_OPEN: #{ret}" if @view_token_type
@@ -438,14 +486,14 @@ def next_token
438
486
  puts "i: FOOTNOTE_CLOSE: #{ret}" if @view_token_type
439
487
  @pre << ret
440
488
  [:FOOTNOTE_CLOSE, ret]
441
- elsif ret = @src.scan(IMAGE_OPEN_RE)
442
- puts "i: IMAGE_OPEN: #{ret}" if @view_token_type
489
+ elsif ret = @src.scan(MEDIA_OPEN_RE)
490
+ puts "i: MEDIA_OPEN: #{ret}" if @view_token_type
443
491
  @pre << ret
444
- [:IMAGE_OPEN, ret]
445
- elsif ret = @src.scan(IMAGE_CLOSE_RE)
446
- puts "i: IMAGE_CLOSE: #{ret}" if @view_token_type
492
+ [:MEDIA_OPEN, ret]
493
+ elsif ret = @src.scan(MEDIA_CLOSE_RE)
494
+ puts "i: MEDIA_CLOSE: #{ret}" if @view_token_type
447
495
  @pre << ret
448
- [:IMAGE_CLOSE, ret]
496
+ [:MEDIA_CLOSE, ret]
449
497
  elsif ret = @src.scan(MANUEDO_OPEN_RE)
450
498
  puts "i: MANUEDO_OPEN: #{ret}" if @view_token_type
451
499
  @pre << ret
@@ -470,6 +518,7 @@ end
470
518
  ---- header
471
519
  require "parserutility"
472
520
  require 'strscan'
521
+ require 'mimemagic'
473
522
  require 'erb'
474
523
  require 'rafelement'
475
524
 
@@ -8,13 +8,14 @@ require 'racc/parser.rb'
8
8
 
9
9
  require "parserutility"
10
10
  require 'strscan'
11
+ require 'mimemagic'
11
12
  require 'erb'
12
13
  require 'rafelement'
13
14
 
14
15
  module Raf
15
16
  class InlineParser < Racc::Parser
16
17
 
17
- module_eval(<<'...end rafinlineparser.ry/module_eval...', 'rafinlineparser.ry', 238)
18
+ module_eval(<<'...end rafinlineparser.ry/module_eval...', 'rafinlineparser.ry', 272)
18
19
  include ParserUtility
19
20
 
20
21
  EM_OPEN = '((*'
@@ -57,10 +58,10 @@ FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
57
58
  FOOTNOTE_CLOSE = ']))'
58
59
  FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
59
60
 
60
- IMAGE_OPEN = '(($'
61
- IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
62
- IMAGE_CLOSE = '$))'
63
- IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
61
+ MEDIA_OPEN = '(($'
62
+ MEDIA_OPEN_RE = /\A#{Regexp.quote(MEDIA_OPEN)}/
63
+ MEDIA_CLOSE = '$))'
64
+ MEDIA_CLOSE_RE = /\A#{Regexp.quote(MEDIA_CLOSE)}/
64
65
 
65
66
  LABEL_OPEN = '((>'
66
67
  LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
@@ -72,6 +73,11 @@ LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
72
73
  LABEL_HTML_CLOSE = '&lt;))'
73
74
  LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
74
75
 
76
+ LABEL_LINK_OPEN = '((='
77
+ LABEL_LINK_OPEN_RE = /\A#{Regexp.quote(LABEL_LINK_OPEN)}/
78
+ LABEL_LINK_CLOSE = '=))'
79
+ LABEL_LINK_CLOSE_RE = /\A#{Regexp.quote(LABEL_LINK_CLOSE)}/
80
+
75
81
  REFERENCE_OPEN = '((<'
76
82
  REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
77
83
  REFERENCE_CLOSE = '>))'
@@ -98,7 +104,7 @@ MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
98
104
  #other_re_mode = Regexp::EXTENDED
99
105
  other_re_mode = Regexp::MULTILINE
100
106
  OTHER_RE = Regexp.new(
101
- "\\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(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_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)})", other_re_mode)
107
+ "\\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(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_CLOSE)}|#{Regexp.quote(MEDIA_OPEN)}|#{Regexp.quote(MEDIA_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_LINK_OPEN)}|#{Regexp.quote(LABEL_LINK_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)})", other_re_mode)
102
108
 
103
109
  def parse(src)
104
110
  @src = StringScanner.new(Array(src).join)
@@ -107,7 +113,8 @@ def parse(src)
107
113
  @view_token_type = false
108
114
  do_parse
109
115
  end
110
- def initialize
116
+ def initialize(options = {})
117
+ @options = options
111
118
  @index = {}
112
119
  end
113
120
  attr_reader :index
@@ -162,6 +169,14 @@ def next_token
162
169
  puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
163
170
  @pre << ret
164
171
  [:LABEL_CLOSE, ret]
172
+ elsif ret = @src.scan(LABEL_LINK_OPEN_RE)
173
+ @pre << ret
174
+ puts "i: LABEL_LINK_OPEN: #{ret}" if @view_token_type
175
+ [:LABEL_LINK_OPEN, ret]
176
+ elsif ret = @src.scan(LABEL_LINK_CLOSE_RE)
177
+ puts "i: LABEL_LINK_CLOSE: #{ret}" if @view_token_type
178
+ @pre << ret
179
+ [:LABEL_LINK_CLOSE, ret]
165
180
  elsif ret = @src.scan(LABEL_HTML_OPEN_RE)
166
181
  @pre << ret
167
182
  puts "i: LABEL_OPEN: #{ret}" if @view_token_type
@@ -218,14 +233,14 @@ def next_token
218
233
  puts "i: FOOTNOTE_CLOSE: #{ret}" if @view_token_type
219
234
  @pre << ret
220
235
  [:FOOTNOTE_CLOSE, ret]
221
- elsif ret = @src.scan(IMAGE_OPEN_RE)
222
- puts "i: IMAGE_OPEN: #{ret}" if @view_token_type
236
+ elsif ret = @src.scan(MEDIA_OPEN_RE)
237
+ puts "i: MEDIA_OPEN: #{ret}" if @view_token_type
223
238
  @pre << ret
224
- [:IMAGE_OPEN, ret]
225
- elsif ret = @src.scan(IMAGE_CLOSE_RE)
226
- puts "i: IMAGE_CLOSE: #{ret}" if @view_token_type
239
+ [:MEDIA_OPEN, ret]
240
+ elsif ret = @src.scan(MEDIA_CLOSE_RE)
241
+ puts "i: MEDIA_CLOSE: #{ret}" if @view_token_type
227
242
  @pre << ret
228
- [:IMAGE_CLOSE, ret]
243
+ [:MEDIA_CLOSE, ret]
229
244
  elsif ret = @src.scan(MANUEDO_OPEN_RE)
230
245
  puts "i: MANUEDO_OPEN: #{ret}" if @view_token_type
231
246
  @pre << ret
@@ -251,327 +266,352 @@ end
251
266
  ##### State transition tables begin ###
252
267
 
253
268
  racc_action_table = [
254
- 18, 125, 19, 162, 20, 163, 21, 164, 22, 165,
255
- 28, 161, 29, 32, 30, 33, 23, 172, 25, 159,
256
- 26, 160, 24, 128, 27, nil, 32, 97, 98, 99,
257
- 100, 101, 102, 103, 104, 105, 106, 113, 114, 111,
258
- 112, 120, 121, 118, 119, 115, 116, 117, 171, 107,
259
- 108, 109, 110, 96, 18, nil, 19, nil, 20, nil,
260
- 21, nil, 22, nil, 28, nil, 29, nil, 30, nil,
261
- 23, nil, 25, nil, 26, nil, 24, nil, 27, nil,
262
- 32, 71, 72, 73, 74, 75, 76, 77, 78, 79,
263
- 80, 87, 88, 85, 86, 92, 93, 90, 91, 89,
264
- 169, nil, nil, 81, 82, 83, 84, 70, 18, 18,
265
- 19, 19, 20, 20, 21, 21, 22, 22, 28, 28,
266
- 29, 29, 30, 30, 23, 23, 25, 25, 26, 26,
267
- 24, 24, 27, 27, 32, 32, 18, 18, 19, 19,
268
- 20, 20, 21, 21, 22, 22, 28, 28, 29, 29,
269
- 30, 30, 23, 23, 25, 25, 26, 26, 24, 24,
270
- 27, 27, 32, 32, 18, 18, 19, 19, 20, 20,
271
- 21, 21, 22, 22, 28, 28, 29, 29, 30, 30,
272
- 23, 23, 25, 25, 26, 26, 24, 24, 27, 27,
273
- 32, 32, 43, 44, 45, 46, 47, 48, 49, 50,
274
- 51, 52, 61, 62, 59, 60, 65, 66, 63, 64,
275
- 53, 54, 55, 56, 67, nil, 57, 58, 42, 71,
276
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 87,
277
- 88, 85, 86, 92, 93, 90, 91, 89, nil, nil,
278
- nil, 81, 82, 83, 84, 70, 97, 98, 99, 100,
279
- 101, 102, 103, 104, 105, 106, 113, 114, 111, 112,
280
- 120, 121, 118, 119, 115, 116, 117, 174, 107, 108,
281
- 109, 110, 96, 18, nil, 19, nil, 20, nil, 21,
282
- nil, 22, 125, 28, nil, 29, nil, 30, nil, 23,
283
- nil, 25, nil, 26, nil, 24, nil, 27, nil, 32,
284
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
285
- 61, 62, 59, 60, 65, 66, 63, 64, 53, 54,
286
- 55, 56, 67, 167, 57, 58, 42, 132, 133, 134,
287
- 135, 136, 137, 138, 139, 140, 141, 148, 149, 146,
288
- 147, 156, nil, 154, 155, 150, 151, 152, 153, 142,
289
- 143, 144, 145, 131, 132, 133, 134, 135, 136, 137,
290
- 138, 139, 140, 141, 148, 149, 146, 147, 156, 178,
291
- 154, 155, 150, 151, 152, 153, 142, 143, 144, 145,
292
- 131, 176, nil, nil, nil, nil, nil, nil, nil, nil,
293
- nil, nil, nil, nil, 128 ]
269
+ 19, 133, 20, 175, 21, 176, 22, 177, 23, 178,
270
+ 29, 174, 30, 34, 31, 35, 32, 185, 24, 136,
271
+ 26, 173, 27, 172, 25, 139, 28, nil, 34, 103,
272
+ 104, 105, 106, 107, 108, 109, 110, 111, 112, 119,
273
+ 120, 121, 122, 117, 118, 128, 129, 126, 127, 123,
274
+ 124, 125, 184, 113, 114, 115, 116, 102, 19, nil,
275
+ 20, nil, 21, nil, 22, nil, 23, nil, 29, nil,
276
+ 30, nil, 31, nil, 32, nil, 24, nil, 26, nil,
277
+ 27, nil, 25, nil, 28, nil, 34, 75, 76, 77,
278
+ 78, 79, 80, 81, 82, 83, 84, 91, 92, 93,
279
+ 94, 89, 90, 98, 99, 96, 97, 95, 182, nil,
280
+ nil, 85, 86, 87, 88, 74, 19, 19, 20, 20,
281
+ 21, 21, 22, 22, 23, 23, 29, 29, 30, 30,
282
+ 31, 31, 32, 32, 24, 24, 26, 26, 27, 27,
283
+ 25, 25, 28, 28, 34, 34, 19, 19, 20, 20,
284
+ 21, 21, 22, 22, 23, 23, 29, 29, 30, 30,
285
+ 31, 31, 32, 32, 24, 24, 26, 26, 27, 27,
286
+ 25, 25, 28, 28, 34, 34, 19, 19, 20, 20,
287
+ 21, 21, 22, 22, 23, 23, 29, 29, 30, 30,
288
+ 31, 31, 32, 32, 24, 24, 26, 26, 27, 27,
289
+ 25, 25, 28, 28, 34, 34, 45, 46, 47, 48,
290
+ 49, 50, 51, 52, 53, 54, 63, 64, 65, 66,
291
+ 61, 62, 69, 70, 67, 68, 55, 56, 57, 58,
292
+ 71, nil, 59, 60, 44, 75, 76, 77, 78, 79,
293
+ 80, 81, 82, 83, 84, 91, 92, 93, 94, 89,
294
+ 90, 98, 99, 96, 97, 95, nil, nil, nil, 85,
295
+ 86, 87, 88, 74, 103, 104, 105, 106, 107, 108,
296
+ 109, 110, 111, 112, 119, 120, 121, 122, 117, 118,
297
+ 128, 129, 126, 127, 123, 124, 125, 187, 113, 114,
298
+ 115, 116, 102, 19, nil, 20, nil, 21, nil, 22,
299
+ nil, 23, nil, 29, 133, 30, nil, 31, nil, 32,
300
+ nil, 24, nil, 26, nil, 27, nil, 25, nil, 28,
301
+ nil, 34, 45, 46, 47, 48, 49, 50, 51, 52,
302
+ 53, 54, 63, 64, 65, 66, 61, 62, 69, 70,
303
+ 67, 68, 55, 56, 57, 58, 71, 180, 59, 60,
304
+ 44, 143, 144, 145, 146, 147, 148, 149, 150, 151,
305
+ 152, 159, 160, 161, 162, 157, 158, 169, nil, 167,
306
+ 168, 163, 164, 165, 166, 153, 154, 155, 156, 142,
307
+ 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
308
+ 159, 160, 161, 162, 157, 158, 169, 193, 167, 168,
309
+ 163, 164, 165, 166, 153, 154, 155, 156, 142, 189,
310
+ 191, nil, nil, nil, nil, nil, nil, nil, nil, nil,
311
+ nil, nil, nil, 139, 136 ]
294
312
 
295
313
  racc_action_check = [
296
- 0, 28, 0, 38, 0, 39, 0, 40, 0, 41,
297
- 0, 37, 0, 17, 0, 1, 0, 124, 0, 33,
298
- 0, 36, 0, 29, 0, nil, 0, 122, 122, 122,
299
- 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
300
- 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
301
- 122, 122, 122, 122, 2, nil, 2, nil, 2, nil,
314
+ 0, 29, 0, 40, 0, 41, 0, 42, 0, 43,
315
+ 0, 39, 0, 18, 0, 1, 0, 132, 0, 30,
316
+ 0, 38, 0, 35, 0, 31, 0, nil, 0, 130,
317
+ 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
318
+ 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
319
+ 130, 130, 130, 130, 130, 130, 130, 130, 2, nil,
302
320
  2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
303
321
  2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
304
- 2, 94, 94, 94, 94, 94, 94, 94, 94, 94,
305
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
306
- 94, nil, nil, 94, 94, 94, 94, 94, 18, 19,
307
- 18, 19, 18, 19, 18, 19, 18, 19, 18, 19,
308
- 18, 19, 18, 19, 18, 19, 18, 19, 18, 19,
309
- 18, 19, 18, 19, 18, 19, 20, 21, 20, 21,
310
- 20, 21, 20, 21, 20, 21, 20, 21, 20, 21,
311
- 20, 21, 20, 21, 20, 21, 20, 21, 20, 21,
312
- 20, 21, 20, 21, 22, 23, 22, 23, 22, 23,
313
- 22, 23, 22, 23, 22, 23, 22, 23, 22, 23,
314
- 22, 23, 22, 23, 22, 23, 22, 23, 22, 23,
315
- 22, 23, 24, 24, 24, 24, 24, 24, 24, 24,
316
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
317
- 24, 24, 24, 24, 24, nil, 24, 24, 24, 25,
322
+ 2, nil, 2, nil, 2, nil, 2, 100, 100, 100,
323
+ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
324
+ 100, 100, 100, 100, 100, 100, 100, 100, 100, nil,
325
+ nil, 100, 100, 100, 100, 100, 19, 20, 19, 20,
326
+ 19, 20, 19, 20, 19, 20, 19, 20, 19, 20,
327
+ 19, 20, 19, 20, 19, 20, 19, 20, 19, 20,
328
+ 19, 20, 19, 20, 19, 20, 21, 22, 21, 22,
329
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
330
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
331
+ 21, 22, 21, 22, 21, 22, 23, 24, 23, 24,
332
+ 23, 24, 23, 24, 23, 24, 23, 24, 23, 24,
333
+ 23, 24, 23, 24, 23, 24, 23, 24, 23, 24,
334
+ 23, 24, 23, 24, 23, 24, 25, 25, 25, 25,
335
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
318
336
  25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
319
- 25, 25, 25, 25, 25, 25, 25, 25, nil, nil,
320
- nil, 25, 25, 25, 25, 25, 26, 26, 26, 26,
337
+ 25, nil, 25, 25, 25, 26, 26, 26, 26, 26,
321
338
  26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
322
- 26, 26, 26, 26, 26, 26, 26, 126, 26, 26,
323
- 26, 26, 26, 27, nil, 27, nil, 27, nil, 27,
324
- nil, 27, 126, 27, nil, 27, nil, 27, nil, 27,
325
- nil, 27, nil, 27, nil, 27, nil, 27, nil, 27,
326
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
327
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
328
- 68, 68, 68, 68, 68, 68, 68, 30, 30, 30,
329
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
330
- 30, 30, nil, 30, 30, 30, 30, 30, 30, 30,
331
- 30, 30, 30, 30, 158, 158, 158, 158, 158, 158,
332
- 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
333
- 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
334
- 158, 129, nil, nil, nil, nil, nil, nil, nil, nil,
335
- nil, nil, nil, nil, 129 ]
339
+ 26, 26, 26, 26, 26, 26, nil, nil, nil, 26,
340
+ 26, 26, 26, 26, 27, 27, 27, 27, 27, 27,
341
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
342
+ 27, 27, 27, 27, 27, 27, 27, 134, 27, 27,
343
+ 27, 27, 27, 28, nil, 28, nil, 28, nil, 28,
344
+ nil, 28, nil, 28, 134, 28, nil, 28, nil, 28,
345
+ nil, 28, nil, 28, nil, 28, nil, 28, nil, 28,
346
+ nil, 28, 72, 72, 72, 72, 72, 72, 72, 72,
347
+ 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
348
+ 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
349
+ 72, 32, 32, 32, 32, 32, 32, 32, 32, 32,
350
+ 32, 32, 32, 32, 32, 32, 32, 32, nil, 32,
351
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
352
+ 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
353
+ 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
354
+ 171, 171, 171, 171, 171, 171, 171, 171, 171, 137,
355
+ 140, nil, nil, nil, nil, nil, nil, nil, nil, nil,
356
+ nil, nil, nil, 140, 137 ]
336
357
 
337
358
  racc_action_pointer = [
338
- -2, 15, 52, nil, nil, nil, nil, nil, nil, nil,
339
- nil, nil, nil, nil, nil, nil, nil, -15, 106, 107,
340
- 134, 135, 162, 163, 190, 217, 244, 271, -27, -5,
341
- 325, nil, nil, 19, nil, nil, 18, 6, -4, -4,
342
- -4, -10, nil, nil, nil, nil, nil, nil, nil, nil,
359
+ -2, 15, 56, nil, nil, nil, nil, nil, nil, nil,
360
+ nil, nil, nil, nil, nil, nil, nil, nil, -17, 114,
361
+ 115, 144, 145, 174, 175, 204, 233, 262, 291, -29,
362
+ -11, -5, 349, nil, nil, 23, nil, nil, 18, 6,
363
+ -4, -4, -4, -12, nil, nil, nil, nil, nil, nil,
343
364
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
344
- nil, nil, nil, nil, nil, nil, nil, nil, 298, nil,
345
365
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
366
+ nil, nil, 320, nil, nil, nil, nil, nil, nil, nil,
346
367
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
347
- nil, nil, nil, nil, 79, nil, nil, nil, nil, nil,
348
368
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
369
+ 85, nil, nil, nil, nil, nil, nil, nil, nil, nil,
349
370
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
350
- nil, nil, 25, nil, -10, nil, 254, nil, nil, 366,
351
371
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
372
+ 27, nil, -12, nil, 274, nil, nil, 394, nil, nil,
373
+ 393, nil, nil, nil, nil, nil, nil, nil, nil, nil,
352
374
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
353
- nil, nil, nil, nil, nil, nil, nil, nil, 352, nil,
354
375
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
355
- nil, nil, nil, nil, nil, nil, nil, nil, nil ]
376
+ nil, 378, nil, nil, nil, nil, nil, nil, nil, nil,
377
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
378
+ nil, nil, nil, nil ]
356
379
 
357
380
  racc_action_default = [
358
- -1, -151, -2, -4, -5, -6, -7, -8, -9, -10,
359
- -11, -12, -13, -14, -15, -16, -17, -18, -1, -1,
360
- -1, -1, -1, -1, -151, -151, -151, -1, -151, -151,
361
- -151, -148, -150, -151, -3, -149, -151, -151, -151, -151,
362
- -151, -151, -25, -26, -27, -28, -29, -30, -31, -32,
363
- -33, -34, -35, -36, -37, -38, -39, -40, -41, -42,
364
- -43, -44, -45, -46, -47, -48, -49, -50, -151, -52,
365
- -54, -55, -56, -57, -58, -59, -60, -61, -62, -63,
366
- -64, -65, -66, -67, -68, -69, -70, -71, -72, -73,
367
- -74, -75, -76, -77, -151, -79, -81, -82, -83, -84,
368
- -85, -86, -87, -88, -89, -90, -91, -92, -93, -94,
369
- -95, -96, -97, -98, -99, -100, -101, -102, -103, -104,
370
- -105, -106, -151, -108, -151, -111, -151, -113, -115, -151,
371
- -117, -119, -120, -121, -122, -123, -124, -125, -126, -127,
372
- -128, -129, -130, -131, -132, -133, -134, -135, -136, -137,
373
- -138, -139, -140, -141, -142, -143, -144, -145, -151, 179,
374
- -19, -20, -21, -22, -23, -24, -51, -53, -78, -80,
375
- -107, -109, -110, -112, -114, -116, -118, -146, -147 ]
381
+ -1, -164, -2, -4, -5, -6, -7, -8, -9, -10,
382
+ -11, -12, -13, -14, -15, -16, -17, -18, -19, -1,
383
+ -1, -1, -1, -1, -1, -164, -164, -164, -1, -164,
384
+ -164, -164, -164, -161, -163, -164, -3, -162, -164, -164,
385
+ -164, -164, -164, -164, -26, -27, -28, -29, -30, -31,
386
+ -32, -33, -34, -35, -36, -37, -38, -39, -40, -41,
387
+ -42, -43, -44, -45, -46, -47, -48, -49, -50, -51,
388
+ -52, -53, -164, -55, -57, -58, -59, -60, -61, -62,
389
+ -63, -64, -65, -66, -67, -68, -69, -70, -71, -72,
390
+ -73, -74, -75, -76, -77, -78, -79, -80, -81, -82,
391
+ -164, -84, -86, -87, -88, -89, -90, -91, -92, -93,
392
+ -94, -95, -96, -97, -98, -99, -100, -101, -102, -103,
393
+ -104, -105, -106, -107, -108, -109, -110, -111, -112, -113,
394
+ -164, -115, -164, -118, -164, -120, -122, -164, -124, -126,
395
+ -164, -128, -130, -131, -132, -133, -134, -135, -136, -137,
396
+ -138, -139, -140, -141, -142, -143, -144, -145, -146, -147,
397
+ -148, -149, -150, -151, -152, -153, -154, -155, -156, -157,
398
+ -158, -164, 194, -20, -21, -22, -23, -24, -25, -54,
399
+ -56, -83, -85, -114, -116, -117, -119, -121, -123, -125,
400
+ -127, -129, -159, -160 ]
376
401
 
377
402
  racc_goto_table = [
378
- 157, 130, 127, 123, 95, 69, 1, 122, 94, 126,
379
- 68, 129, 34, 158, 35, nil, nil, nil, nil, nil,
380
- nil, nil, nil, nil, 36, 37, 38, 39, 40, 41,
381
- nil, nil, nil, 124, nil, nil, nil, nil, nil, nil,
382
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 166,
403
+ 170, 141, 138, 135, 131, 101, 73, 1, 130, 134,
404
+ 100, 137, 72, 140, 36, 171, 37, nil, nil, nil,
405
+ nil, nil, nil, nil, nil, nil, 38, 39, 40, 41,
406
+ 42, 43, nil, nil, nil, 132, nil, nil, nil, nil,
407
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
408
+ nil, nil, nil, 179, nil, nil, nil, nil, nil, nil,
383
409
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
410
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 181,
384
411
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
385
- nil, nil, nil, 168, nil, nil, nil, nil, nil, nil,
386
412
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
387
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 170,
388
- 173, 175, nil, nil, nil, nil, nil, nil, nil, nil,
413
+ nil, nil, nil, nil, nil, nil, nil, 183, 186, 188,
414
+ 190, nil, nil, nil, nil, nil, nil, nil, nil, nil,
389
415
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
390
- nil, nil, nil, nil, nil, nil, nil, nil, 177 ]
416
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 192 ]
391
417
 
392
418
  racc_goto_check = [
393
- 28, 26, 24, 22, 20, 18, 1, 23, 21, 25,
394
- 19, 27, 3, 29, 30, nil, nil, nil, nil, nil,
395
- nil, nil, nil, nil, 1, 1, 1, 1, 1, 1,
396
- nil, nil, nil, 1, nil, nil, nil, nil, nil, nil,
397
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 18,
419
+ 31, 29, 27, 25, 23, 21, 19, 1, 24, 26,
420
+ 22, 28, 20, 30, 3, 32, 33, nil, nil, nil,
421
+ nil, nil, nil, nil, nil, nil, 1, 1, 1, 1,
422
+ 1, 1, nil, nil, nil, 1, nil, nil, nil, nil,
398
423
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
424
+ nil, nil, nil, 19, nil, nil, nil, nil, nil, nil,
399
425
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
400
- nil, nil, nil, 20, nil, nil, nil, nil, nil, nil,
426
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 21,
401
427
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
402
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 22,
403
- 24, 26, nil, nil, nil, nil, nil, nil, nil, nil,
404
428
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
405
- nil, nil, nil, nil, nil, nil, nil, nil, 28 ]
429
+ nil, nil, nil, nil, nil, nil, nil, 23, 25, 27,
430
+ 29, nil, nil, nil, nil, nil, nil, nil, nil, nil,
431
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
432
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 31 ]
406
433
 
407
434
  racc_goto_pointer = [
408
- nil, 6, nil, 10, nil, nil, nil, nil, nil, nil,
409
- nil, nil, nil, nil, nil, nil, nil, nil, -19, -14,
410
- -21, -17, -23, -19, -26, -19, -28, -18, -30, -17,
411
- -3 ]
435
+ nil, 7, nil, 12, nil, nil, nil, nil, nil, nil,
436
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, -19,
437
+ -13, -21, -16, -23, -19, -26, -20, -28, -19, -30,
438
+ -18, -32, -17, -2 ]
412
439
 
413
440
  racc_goto_default = [
414
441
  nil, nil, 2, 3, 4, 5, 6, 7, 8, 9,
415
- 10, 11, 12, 13, 14, 15, 16, 17, nil, nil,
442
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, nil,
416
443
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
417
- 31 ]
444
+ nil, nil, nil, 33 ]
418
445
 
419
446
  racc_reduce_table = [
420
447
  0, 0, :racc_error,
421
- 0, 30, :_reduce_none,
422
- 1, 30, :_reduce_none,
423
- 2, 31, :_reduce_3,
424
- 1, 31, :_reduce_4,
425
- 1, 32, :_reduce_none,
426
- 1, 32, :_reduce_none,
427
- 1, 32, :_reduce_none,
428
- 1, 32, :_reduce_none,
429
- 1, 32, :_reduce_none,
430
- 1, 32, :_reduce_none,
431
- 1, 32, :_reduce_none,
432
- 1, 32, :_reduce_none,
448
+ 0, 32, :_reduce_none,
433
449
  1, 32, :_reduce_none,
434
- 1, 32, :_reduce_none,
435
- 1, 32, :_reduce_none,
436
- 1, 32, :_reduce_none,
437
- 1, 32, :_reduce_none,
438
- 1, 32, :_reduce_none,
439
- 3, 33, :_reduce_19,
440
- 3, 34, :_reduce_20,
441
- 3, 35, :_reduce_21,
442
- 3, 36, :_reduce_22,
443
- 3, 37, :_reduce_23,
444
- 3, 42, :_reduce_24,
445
- 1, 47, :_reduce_none,
446
- 1, 47, :_reduce_none,
447
- 1, 47, :_reduce_none,
448
- 1, 47, :_reduce_none,
449
- 1, 47, :_reduce_none,
450
- 1, 47, :_reduce_none,
451
- 1, 47, :_reduce_none,
452
- 1, 47, :_reduce_none,
453
- 1, 47, :_reduce_none,
454
- 1, 47, :_reduce_none,
455
- 1, 47, :_reduce_none,
456
- 1, 47, :_reduce_none,
457
- 1, 47, :_reduce_none,
458
- 1, 47, :_reduce_none,
459
- 1, 47, :_reduce_none,
460
- 1, 47, :_reduce_none,
461
- 1, 47, :_reduce_none,
462
- 1, 47, :_reduce_none,
463
- 1, 47, :_reduce_none,
464
- 1, 47, :_reduce_none,
465
- 1, 47, :_reduce_none,
466
- 1, 47, :_reduce_none,
467
- 1, 47, :_reduce_none,
468
- 1, 47, :_reduce_none,
469
- 1, 47, :_reduce_none,
470
- 1, 47, :_reduce_none,
471
- 2, 48, :_reduce_51,
472
- 1, 48, :_reduce_52,
473
- 3, 43, :_reduce_53,
474
- 1, 49, :_reduce_none,
475
- 1, 49, :_reduce_none,
476
- 1, 49, :_reduce_none,
477
- 1, 49, :_reduce_none,
478
- 1, 49, :_reduce_none,
479
- 1, 49, :_reduce_none,
480
- 1, 49, :_reduce_none,
481
- 1, 49, :_reduce_none,
482
- 1, 49, :_reduce_none,
483
- 1, 49, :_reduce_none,
484
- 1, 49, :_reduce_none,
485
- 1, 49, :_reduce_none,
486
- 1, 49, :_reduce_none,
487
- 1, 49, :_reduce_none,
488
- 1, 49, :_reduce_none,
489
- 1, 49, :_reduce_none,
490
- 1, 49, :_reduce_none,
491
- 1, 49, :_reduce_none,
492
- 1, 49, :_reduce_none,
493
- 1, 49, :_reduce_none,
494
- 1, 49, :_reduce_none,
495
- 1, 49, :_reduce_none,
496
- 1, 49, :_reduce_none,
497
- 1, 49, :_reduce_none,
498
- 2, 50, :_reduce_78,
499
- 1, 50, :_reduce_79,
500
- 3, 40, :_reduce_80,
501
- 1, 51, :_reduce_none,
502
- 1, 51, :_reduce_none,
503
- 1, 51, :_reduce_none,
504
- 1, 51, :_reduce_none,
505
- 1, 51, :_reduce_none,
506
- 1, 51, :_reduce_none,
507
- 1, 51, :_reduce_none,
508
- 1, 51, :_reduce_none,
509
- 1, 51, :_reduce_none,
510
- 1, 51, :_reduce_none,
511
- 1, 51, :_reduce_none,
512
- 1, 51, :_reduce_none,
513
- 1, 51, :_reduce_none,
514
- 1, 51, :_reduce_none,
515
- 1, 51, :_reduce_none,
516
- 1, 51, :_reduce_none,
517
- 1, 51, :_reduce_none,
518
- 1, 51, :_reduce_none,
519
- 1, 51, :_reduce_none,
520
- 1, 51, :_reduce_none,
521
- 1, 51, :_reduce_none,
522
- 1, 51, :_reduce_none,
523
- 1, 51, :_reduce_none,
524
- 1, 51, :_reduce_none,
525
- 1, 51, :_reduce_none,
526
- 1, 51, :_reduce_none,
527
- 2, 52, :_reduce_107,
528
- 1, 52, :_reduce_108,
529
- 3, 41, :_reduce_109,
530
- 3, 45, :_reduce_110,
531
- 1, 53, :_reduce_111,
532
- 2, 54, :_reduce_112,
533
- 1, 54, :_reduce_113,
534
- 3, 38, :_reduce_114,
450
+ 2, 33, :_reduce_3,
451
+ 1, 33, :_reduce_4,
452
+ 1, 34, :_reduce_none,
453
+ 1, 34, :_reduce_none,
454
+ 1, 34, :_reduce_none,
455
+ 1, 34, :_reduce_none,
456
+ 1, 34, :_reduce_none,
457
+ 1, 34, :_reduce_none,
458
+ 1, 34, :_reduce_none,
459
+ 1, 34, :_reduce_none,
460
+ 1, 34, :_reduce_none,
461
+ 1, 34, :_reduce_none,
462
+ 1, 34, :_reduce_none,
463
+ 1, 34, :_reduce_none,
464
+ 1, 34, :_reduce_none,
465
+ 1, 34, :_reduce_none,
466
+ 1, 34, :_reduce_none,
467
+ 3, 35, :_reduce_20,
468
+ 3, 36, :_reduce_21,
469
+ 3, 37, :_reduce_22,
470
+ 3, 38, :_reduce_23,
471
+ 3, 39, :_reduce_24,
472
+ 3, 45, :_reduce_25,
473
+ 1, 50, :_reduce_none,
474
+ 1, 50, :_reduce_none,
475
+ 1, 50, :_reduce_none,
476
+ 1, 50, :_reduce_none,
477
+ 1, 50, :_reduce_none,
478
+ 1, 50, :_reduce_none,
479
+ 1, 50, :_reduce_none,
480
+ 1, 50, :_reduce_none,
481
+ 1, 50, :_reduce_none,
482
+ 1, 50, :_reduce_none,
483
+ 1, 50, :_reduce_none,
484
+ 1, 50, :_reduce_none,
485
+ 1, 50, :_reduce_none,
486
+ 1, 50, :_reduce_none,
487
+ 1, 50, :_reduce_none,
488
+ 1, 50, :_reduce_none,
489
+ 1, 50, :_reduce_none,
490
+ 1, 50, :_reduce_none,
491
+ 1, 50, :_reduce_none,
492
+ 1, 50, :_reduce_none,
493
+ 1, 50, :_reduce_none,
494
+ 1, 50, :_reduce_none,
495
+ 1, 50, :_reduce_none,
496
+ 1, 50, :_reduce_none,
497
+ 1, 50, :_reduce_none,
498
+ 1, 50, :_reduce_none,
499
+ 1, 50, :_reduce_none,
500
+ 1, 50, :_reduce_none,
501
+ 2, 51, :_reduce_54,
502
+ 1, 51, :_reduce_55,
503
+ 3, 46, :_reduce_56,
504
+ 1, 52, :_reduce_none,
505
+ 1, 52, :_reduce_none,
506
+ 1, 52, :_reduce_none,
507
+ 1, 52, :_reduce_none,
508
+ 1, 52, :_reduce_none,
509
+ 1, 52, :_reduce_none,
510
+ 1, 52, :_reduce_none,
511
+ 1, 52, :_reduce_none,
512
+ 1, 52, :_reduce_none,
513
+ 1, 52, :_reduce_none,
514
+ 1, 52, :_reduce_none,
515
+ 1, 52, :_reduce_none,
516
+ 1, 52, :_reduce_none,
517
+ 1, 52, :_reduce_none,
518
+ 1, 52, :_reduce_none,
519
+ 1, 52, :_reduce_none,
520
+ 1, 52, :_reduce_none,
521
+ 1, 52, :_reduce_none,
522
+ 1, 52, :_reduce_none,
523
+ 1, 52, :_reduce_none,
524
+ 1, 52, :_reduce_none,
525
+ 1, 52, :_reduce_none,
526
+ 1, 52, :_reduce_none,
527
+ 1, 52, :_reduce_none,
528
+ 1, 52, :_reduce_none,
529
+ 1, 52, :_reduce_none,
530
+ 2, 53, :_reduce_83,
531
+ 1, 53, :_reduce_84,
532
+ 3, 43, :_reduce_85,
533
+ 1, 54, :_reduce_none,
534
+ 1, 54, :_reduce_none,
535
+ 1, 54, :_reduce_none,
536
+ 1, 54, :_reduce_none,
537
+ 1, 54, :_reduce_none,
538
+ 1, 54, :_reduce_none,
539
+ 1, 54, :_reduce_none,
540
+ 1, 54, :_reduce_none,
541
+ 1, 54, :_reduce_none,
542
+ 1, 54, :_reduce_none,
543
+ 1, 54, :_reduce_none,
544
+ 1, 54, :_reduce_none,
545
+ 1, 54, :_reduce_none,
546
+ 1, 54, :_reduce_none,
547
+ 1, 54, :_reduce_none,
548
+ 1, 54, :_reduce_none,
549
+ 1, 54, :_reduce_none,
550
+ 1, 54, :_reduce_none,
551
+ 1, 54, :_reduce_none,
552
+ 1, 54, :_reduce_none,
553
+ 1, 54, :_reduce_none,
554
+ 1, 54, :_reduce_none,
555
+ 1, 54, :_reduce_none,
556
+ 1, 54, :_reduce_none,
557
+ 1, 54, :_reduce_none,
558
+ 1, 54, :_reduce_none,
559
+ 1, 54, :_reduce_none,
560
+ 1, 54, :_reduce_none,
561
+ 2, 55, :_reduce_114,
535
562
  1, 55, :_reduce_115,
536
- 2, 56, :_reduce_116,
537
- 1, 56, :_reduce_117,
538
- 3, 39, :_reduce_118,
539
- 1, 57, :_reduce_none,
540
- 1, 57, :_reduce_none,
541
- 1, 57, :_reduce_none,
542
- 1, 57, :_reduce_none,
543
- 1, 57, :_reduce_none,
544
- 1, 57, :_reduce_none,
545
- 1, 57, :_reduce_none,
546
- 1, 57, :_reduce_none,
547
- 1, 57, :_reduce_none,
548
- 1, 57, :_reduce_none,
549
- 1, 57, :_reduce_none,
550
- 1, 57, :_reduce_none,
551
- 1, 57, :_reduce_none,
552
- 1, 57, :_reduce_none,
553
- 1, 57, :_reduce_none,
554
- 1, 57, :_reduce_none,
555
- 1, 57, :_reduce_none,
556
- 1, 57, :_reduce_none,
557
- 1, 57, :_reduce_none,
558
- 1, 57, :_reduce_none,
559
- 1, 57, :_reduce_none,
560
- 1, 57, :_reduce_none,
561
- 1, 57, :_reduce_none,
562
- 1, 57, :_reduce_none,
563
- 1, 57, :_reduce_none,
564
- 1, 57, :_reduce_none,
565
- 1, 58, :_reduce_none,
566
- 2, 58, :_reduce_146,
567
- 3, 44, :_reduce_147,
568
- 1, 46, :_reduce_148,
569
- 2, 46, :_reduce_149,
570
- 1, 59, :_reduce_150 ]
571
-
572
- racc_reduce_n = 151
573
-
574
- racc_shift_n = 179
563
+ 3, 44, :_reduce_116,
564
+ 3, 48, :_reduce_117,
565
+ 1, 56, :_reduce_118,
566
+ 2, 57, :_reduce_119,
567
+ 1, 57, :_reduce_120,
568
+ 3, 40, :_reduce_121,
569
+ 1, 58, :_reduce_122,
570
+ 2, 59, :_reduce_123,
571
+ 1, 59, :_reduce_124,
572
+ 3, 41, :_reduce_125,
573
+ 1, 60, :_reduce_126,
574
+ 2, 61, :_reduce_127,
575
+ 1, 61, :_reduce_128,
576
+ 3, 42, :_reduce_129,
577
+ 1, 62, :_reduce_none,
578
+ 1, 62, :_reduce_none,
579
+ 1, 62, :_reduce_none,
580
+ 1, 62, :_reduce_none,
581
+ 1, 62, :_reduce_none,
582
+ 1, 62, :_reduce_none,
583
+ 1, 62, :_reduce_none,
584
+ 1, 62, :_reduce_none,
585
+ 1, 62, :_reduce_none,
586
+ 1, 62, :_reduce_none,
587
+ 1, 62, :_reduce_none,
588
+ 1, 62, :_reduce_none,
589
+ 1, 62, :_reduce_none,
590
+ 1, 62, :_reduce_none,
591
+ 1, 62, :_reduce_none,
592
+ 1, 62, :_reduce_none,
593
+ 1, 62, :_reduce_none,
594
+ 1, 62, :_reduce_none,
595
+ 1, 62, :_reduce_none,
596
+ 1, 62, :_reduce_none,
597
+ 1, 62, :_reduce_none,
598
+ 1, 62, :_reduce_none,
599
+ 1, 62, :_reduce_none,
600
+ 1, 62, :_reduce_none,
601
+ 1, 62, :_reduce_none,
602
+ 1, 62, :_reduce_none,
603
+ 1, 62, :_reduce_none,
604
+ 1, 62, :_reduce_none,
605
+ 1, 63, :_reduce_none,
606
+ 2, 63, :_reduce_159,
607
+ 3, 47, :_reduce_160,
608
+ 1, 49, :_reduce_161,
609
+ 2, 49, :_reduce_162,
610
+ 1, 64, :_reduce_163 ]
611
+
612
+ racc_reduce_n = 164
613
+
614
+ racc_shift_n = 194
575
615
 
576
616
  racc_token_table = {
577
617
  false => 0,
@@ -588,23 +628,25 @@ racc_token_table = {
588
628
  :KBD_CLOSE => 11,
589
629
  :LABEL_OPEN => 12,
590
630
  :LABEL_CLOSE => 13,
591
- :REFERENCE_OPEN => 14,
592
- :REFERENCE_CLOSE => 15,
593
- :VERB_OPEN => 16,
594
- :VERB_CLOSE => 17,
595
- :FOOTNOTE_OPEN => 18,
596
- :FOOTNOTE_CLOSE => 19,
597
- :RUBY_OPEN => 20,
598
- :RUBY_CLOSE => 21,
599
- :VARIABLE_OPEN => 22,
600
- :VARIABLE_CLOSE => 23,
601
- :IMAGE_OPEN => 24,
602
- :IMAGE_CLOSE => 25,
603
- :MANUEDO_OPEN => 26,
604
- :MANUEDO_CLOSE => 27,
605
- :OTHER => 28 }
606
-
607
- racc_nt_base = 29
631
+ :LABEL_LINK_OPEN => 14,
632
+ :LABEL_LINK_CLOSE => 15,
633
+ :REFERENCE_OPEN => 16,
634
+ :REFERENCE_CLOSE => 17,
635
+ :VERB_OPEN => 18,
636
+ :VERB_CLOSE => 19,
637
+ :FOOTNOTE_OPEN => 20,
638
+ :FOOTNOTE_CLOSE => 21,
639
+ :RUBY_OPEN => 22,
640
+ :RUBY_CLOSE => 23,
641
+ :VARIABLE_OPEN => 24,
642
+ :VARIABLE_CLOSE => 25,
643
+ :MEDIA_OPEN => 26,
644
+ :MEDIA_CLOSE => 27,
645
+ :MANUEDO_OPEN => 28,
646
+ :MANUEDO_CLOSE => 29,
647
+ :OTHER => 30 }
648
+
649
+ racc_nt_base = 31
608
650
 
609
651
  racc_use_result_var = false
610
652
 
@@ -639,6 +681,8 @@ Racc_token_to_s_table = [
639
681
  "KBD_CLOSE",
640
682
  "LABEL_OPEN",
641
683
  "LABEL_CLOSE",
684
+ "LABEL_LINK_OPEN",
685
+ "LABEL_LINK_CLOSE",
642
686
  "REFERENCE_OPEN",
643
687
  "REFERENCE_CLOSE",
644
688
  "VERB_OPEN",
@@ -649,8 +693,8 @@ Racc_token_to_s_table = [
649
693
  "RUBY_CLOSE",
650
694
  "VARIABLE_OPEN",
651
695
  "VARIABLE_CLOSE",
652
- "IMAGE_OPEN",
653
- "IMAGE_CLOSE",
696
+ "MEDIA_OPEN",
697
+ "MEDIA_CLOSE",
654
698
  "MANUEDO_OPEN",
655
699
  "MANUEDO_CLOSE",
656
700
  "OTHER",
@@ -664,22 +708,25 @@ Racc_token_to_s_table = [
664
708
  "code",
665
709
  "kbd",
666
710
  "label",
711
+ "label_link",
667
712
  "reference",
668
713
  "ruby",
669
714
  "variable",
670
715
  "footnote",
671
- "image",
716
+ "media",
672
717
  "verb",
673
718
  "manuedo",
674
719
  "normal_strings",
675
- "image_string",
676
- "image_strings",
720
+ "media_string",
721
+ "media_strings",
677
722
  "ruby_string",
678
723
  "ruby_strings",
679
724
  "variable_string",
680
725
  "variable_strings",
681
726
  "label_string",
682
727
  "label_strings",
728
+ "label_link_string",
729
+ "label_link_strings",
683
730
  "reference_string",
684
731
  "reference_strings",
685
732
  "verb_string",
@@ -736,38 +783,40 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 10)
736
783
 
737
784
  # reduce 18 omitted
738
785
 
739
- module_eval(<<'.,.,', 'rafinlineparser.ry', 28)
740
- def _reduce_19(val, _values)
741
- Emphasis.new(val[1])
742
- end
743
- .,.,
786
+ # reduce 19 omitted
744
787
 
745
788
  module_eval(<<'.,.,', 'rafinlineparser.ry', 29)
746
789
  def _reduce_20(val, _values)
747
- Italic.new(val[1])
790
+ Emphasis.new(val[1])
748
791
  end
749
792
  .,.,
750
793
 
751
794
  module_eval(<<'.,.,', 'rafinlineparser.ry', 30)
752
795
  def _reduce_21(val, _values)
753
- Strike.new(val[1])
796
+ Italic.new(val[1])
754
797
  end
755
798
  .,.,
756
799
 
757
800
  module_eval(<<'.,.,', 'rafinlineparser.ry', 31)
758
801
  def _reduce_22(val, _values)
759
- Code.new(val[1])
802
+ Strike.new(val[1])
760
803
  end
761
804
  .,.,
762
805
 
763
806
  module_eval(<<'.,.,', 'rafinlineparser.ry', 32)
764
807
  def _reduce_23(val, _values)
765
- Kbd.new(val[1])
808
+ Code.new(val[1])
766
809
  end
767
810
  .,.,
768
811
 
769
- module_eval(<<'.,.,', 'rafinlineparser.ry', 34)
812
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 33)
770
813
  def _reduce_24(val, _values)
814
+ Kbd.new(val[1])
815
+ end
816
+ .,.,
817
+
818
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 35)
819
+ def _reduce_25(val, _values)
771
820
  @index[:footnote] ||= []
772
821
  @index[:footnote] << {:content => val[1] }
773
822
  Footnote.new([val[1], @index[:footnote].size])
@@ -775,8 +824,6 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 34)
775
824
  end
776
825
  .,.,
777
826
 
778
- # reduce 25 omitted
779
-
780
827
  # reduce 26 omitted
781
828
 
782
829
  # reduce 27 omitted
@@ -827,30 +874,41 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 34)
827
874
 
828
875
  # reduce 50 omitted
829
876
 
830
- module_eval(<<'.,.,', 'rafinlineparser.ry', 69)
831
- def _reduce_51(val, _values)
877
+ # reduce 51 omitted
878
+
879
+ # reduce 52 omitted
880
+
881
+ # reduce 53 omitted
882
+
883
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 72)
884
+ def _reduce_54(val, _values)
832
885
  val.join
833
886
  end
834
887
  .,.,
835
888
 
836
- module_eval(<<'.,.,', 'rafinlineparser.ry', 70)
837
- def _reduce_52(val, _values)
838
- val[0]
889
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 74)
890
+ def _reduce_55(val, _values)
891
+ unless @options[:media_directory].nil? || @options[:media_directory].empty?
892
+ val[0] = File.join(@options[:media_directory],val[0]) unless val[0] =~ /^.*:\/\/.*/
893
+ end
894
+ val[0]
895
+
839
896
  end
840
897
  .,.,
841
898
 
842
- module_eval(<<'.,.,', 'rafinlineparser.ry', 71)
843
- def _reduce_53(val, _values)
844
- Image.new(val[1])
899
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 80)
900
+ def _reduce_56(val, _values)
901
+ mime = MimeMagic.by_extension(val[1].split(".").last)
902
+ unless mime.nil?
903
+ mediatype, subtype = mime.mediatype, mime.subtype
904
+ else
905
+ mediatype, subtype = "",""
906
+ end
907
+ Media.new([val[1],mediatype,subtype])
908
+
845
909
  end
846
910
  .,.,
847
911
 
848
- # reduce 54 omitted
849
-
850
- # reduce 55 omitted
851
-
852
- # reduce 56 omitted
853
-
854
912
  # reduce 57 omitted
855
913
 
856
914
  # reduce 58 omitted
@@ -893,20 +951,30 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 71)
893
951
 
894
952
  # reduce 77 omitted
895
953
 
896
- module_eval(<<'.,.,', 'rafinlineparser.ry', 100)
897
- def _reduce_78(val, _values)
954
+ # reduce 78 omitted
955
+
956
+ # reduce 79 omitted
957
+
958
+ # reduce 80 omitted
959
+
960
+ # reduce 81 omitted
961
+
962
+ # reduce 82 omitted
963
+
964
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 118)
965
+ def _reduce_83(val, _values)
898
966
  val.join
899
967
  end
900
968
  .,.,
901
969
 
902
- module_eval(<<'.,.,', 'rafinlineparser.ry', 101)
903
- def _reduce_79(val, _values)
970
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 119)
971
+ def _reduce_84(val, _values)
904
972
  val[0]
905
973
  end
906
974
  .,.,
907
975
 
908
- module_eval(<<'.,.,', 'rafinlineparser.ry', 104)
909
- def _reduce_80(val, _values)
976
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 122)
977
+ def _reduce_85(val, _values)
910
978
  base, text = val[1].split("|",2)
911
979
  text ||= base
912
980
  # parser = InlineParser.new
@@ -916,16 +984,6 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 104)
916
984
  end
917
985
  .,.,
918
986
 
919
- # reduce 81 omitted
920
-
921
- # reduce 82 omitted
922
-
923
- # reduce 83 omitted
924
-
925
- # reduce 84 omitted
926
-
927
- # reduce 85 omitted
928
-
929
987
  # reduce 86 omitted
930
988
 
931
989
  # reduce 87 omitted
@@ -968,65 +1026,75 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 104)
968
1026
 
969
1027
  # reduce 106 omitted
970
1028
 
971
- module_eval(<<'.,.,', 'rafinlineparser.ry', 140)
972
- def _reduce_107(val, _values)
1029
+ # reduce 107 omitted
1030
+
1031
+ # reduce 108 omitted
1032
+
1033
+ # reduce 109 omitted
1034
+
1035
+ # reduce 110 omitted
1036
+
1037
+ # reduce 111 omitted
1038
+
1039
+ # reduce 112 omitted
1040
+
1041
+ # reduce 113 omitted
1042
+
1043
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 160)
1044
+ def _reduce_114(val, _values)
973
1045
  val.join
974
1046
  end
975
1047
  .,.,
976
1048
 
977
- module_eval(<<'.,.,', 'rafinlineparser.ry', 141)
978
- def _reduce_108(val, _values)
1049
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 161)
1050
+ def _reduce_115(val, _values)
979
1051
  val[0]
980
1052
  end
981
1053
  .,.,
982
1054
 
983
- module_eval(<<'.,.,', 'rafinlineparser.ry', 144)
984
- def _reduce_109(val, _values)
1055
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 164)
1056
+ def _reduce_116(val, _values)
985
1057
  base, text = val[1].split("=",2)
986
- unless text.nil?
987
- @variables ||= {}
988
- @variables[base] = text
989
- Empty.new("")
990
- else
991
- value = @variables[base]
992
- unless value.nil?
993
- parser = InlineParser.new
994
- value = parser.parse(value).map do |n| n.apply end
995
- else # 変数が未定義
996
- value = base
997
- end
998
- Variable.new(value)
1058
+ @variables ||= {}
1059
+ @variables[base] = text unless text.nil?
1060
+ value = @variables[base]
1061
+ unless value.nil?
1062
+ parser = InlineParser.new
1063
+ value = parser.parse(value).map do |n| n.apply end
1064
+ else # 変数が未定義
1065
+ value = base
999
1066
  end
1067
+ Variable.new(value)
1000
1068
 
1001
1069
  end
1002
1070
  .,.,
1003
1071
 
1004
- module_eval(<<'.,.,', 'rafinlineparser.ry', 162)
1005
- def _reduce_110(val, _values)
1072
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 178)
1073
+ def _reduce_117(val, _values)
1006
1074
  Manuedo.new(val[1])
1007
1075
  end
1008
1076
  .,.,
1009
1077
 
1010
- module_eval(<<'.,.,', 'rafinlineparser.ry', 167)
1011
- def _reduce_111(val, _values)
1078
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 183)
1079
+ def _reduce_118(val, _values)
1012
1080
  val[0]
1013
1081
  end
1014
1082
  .,.,
1015
1083
 
1016
- module_eval(<<'.,.,', 'rafinlineparser.ry', 170)
1017
- def _reduce_112(val, _values)
1084
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 186)
1085
+ def _reduce_119(val, _values)
1018
1086
  val.join
1019
1087
  end
1020
1088
  .,.,
1021
1089
 
1022
- module_eval(<<'.,.,', 'rafinlineparser.ry', 171)
1023
- def _reduce_113(val, _values)
1090
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 187)
1091
+ def _reduce_120(val, _values)
1024
1092
  val[0]
1025
1093
  end
1026
1094
  .,.,
1027
1095
 
1028
- module_eval(<<'.,.,', 'rafinlineparser.ry', 174)
1029
- def _reduce_114(val, _values)
1096
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 190)
1097
+ def _reduce_121(val, _values)
1030
1098
  label, title = val[1].split("|",2)
1031
1099
  title ||= label
1032
1100
  @index[:label] ||= []
@@ -1036,55 +1104,63 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 174)
1036
1104
  end
1037
1105
  .,.,
1038
1106
 
1039
- module_eval(<<'.,.,', 'rafinlineparser.ry', 183)
1040
- def _reduce_115(val, _values)
1107
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 199)
1108
+ def _reduce_122(val, _values)
1041
1109
  val[0]
1042
1110
  end
1043
1111
  .,.,
1044
1112
 
1045
- module_eval(<<'.,.,', 'rafinlineparser.ry', 185)
1046
- def _reduce_116(val, _values)
1113
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 201)
1114
+ def _reduce_123(val, _values)
1047
1115
  val.join
1048
1116
  end
1049
1117
  .,.,
1050
1118
 
1051
- module_eval(<<'.,.,', 'rafinlineparser.ry', 186)
1052
- def _reduce_117(val, _values)
1119
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 202)
1120
+ def _reduce_124(val, _values)
1053
1121
  val[0]
1054
1122
  end
1055
1123
  .,.,
1056
1124
 
1057
- module_eval(<<'.,.,', 'rafinlineparser.ry', 189)
1058
- def _reduce_118(val, _values)
1059
- title, uri = val[1].split("|",2)
1060
- uri ||= title
1061
- uri = "#" + uri.to_code if uri.gsub(/^\s*https*:\/\//,"") == uri
1062
- Reference.new([title, uri])
1125
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 205)
1126
+ def _reduce_125(val, _values)
1127
+ label, title = val[1].split("|",2)
1128
+ title ||= label
1129
+ LabelLink.new([label.to_code, title])
1063
1130
 
1064
1131
  end
1065
1132
  .,.,
1066
1133
 
1067
- # reduce 119 omitted
1068
-
1069
- # reduce 120 omitted
1070
-
1071
- # reduce 121 omitted
1072
-
1073
- # reduce 122 omitted
1074
-
1075
- # reduce 123 omitted
1076
-
1077
- # reduce 124 omitted
1078
-
1079
- # reduce 125 omitted
1080
-
1081
- # reduce 126 omitted
1134
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 212)
1135
+ def _reduce_126(val, _values)
1136
+ val[0]
1137
+ end
1138
+ .,.,
1082
1139
 
1083
- # reduce 127 omitted
1140
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 214)
1141
+ def _reduce_127(val, _values)
1142
+ val.join
1143
+ end
1144
+ .,.,
1084
1145
 
1085
- # reduce 128 omitted
1146
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 215)
1147
+ def _reduce_128(val, _values)
1148
+ val[0]
1149
+ end
1150
+ .,.,
1086
1151
 
1087
- # reduce 129 omitted
1152
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 218)
1153
+ def _reduce_129(val, _values)
1154
+ title, uri = val[1].split("|",2)
1155
+ uri ||= title
1156
+ if uri.strip[-2,2] == ".%" and ! @options[:extension].nil?
1157
+ uri.slice!(-2,2)
1158
+ uri = "#{uri}#{@options[:extension]}"
1159
+ end
1160
+ Reference.new([title, uri])
1161
+
1162
+ end
1163
+ .,.,
1088
1164
 
1089
1165
  # reduce 130 omitted
1090
1166
 
@@ -1118,32 +1194,58 @@ module_eval(<<'.,.,', 'rafinlineparser.ry', 189)
1118
1194
 
1119
1195
  # reduce 145 omitted
1120
1196
 
1121
- module_eval(<<'.,.,', 'rafinlineparser.ry', 224)
1122
- def _reduce_146(val, _values)
1197
+ # reduce 146 omitted
1198
+
1199
+ # reduce 147 omitted
1200
+
1201
+ # reduce 148 omitted
1202
+
1203
+ # reduce 149 omitted
1204
+
1205
+ # reduce 150 omitted
1206
+
1207
+ # reduce 151 omitted
1208
+
1209
+ # reduce 152 omitted
1210
+
1211
+ # reduce 153 omitted
1212
+
1213
+ # reduce 154 omitted
1214
+
1215
+ # reduce 155 omitted
1216
+
1217
+ # reduce 156 omitted
1218
+
1219
+ # reduce 157 omitted
1220
+
1221
+ # reduce 158 omitted
1222
+
1223
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 258)
1224
+ def _reduce_159(val, _values)
1123
1225
  val
1124
1226
  end
1125
1227
  .,.,
1126
1228
 
1127
- module_eval(<<'.,.,', 'rafinlineparser.ry', 226)
1128
- def _reduce_147(val, _values)
1229
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 260)
1230
+ def _reduce_160(val, _values)
1129
1231
  Verb.new(val[1])
1130
1232
  end
1131
1233
  .,.,
1132
1234
 
1133
- module_eval(<<'.,.,', 'rafinlineparser.ry', 230)
1134
- def _reduce_148(val, _values)
1235
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 264)
1236
+ def _reduce_161(val, _values)
1135
1237
  Plain.new(val[0])
1136
1238
  end
1137
1239
  .,.,
1138
1240
 
1139
- module_eval(<<'.,.,', 'rafinlineparser.ry', 231)
1140
- def _reduce_149(val, _values)
1241
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 265)
1242
+ def _reduce_162(val, _values)
1141
1243
  Plain.new([val[0].contents, val[1]])
1142
1244
  end
1143
1245
  .,.,
1144
1246
 
1145
- module_eval(<<'.,.,', 'rafinlineparser.ry', 233)
1146
- def _reduce_150(val, _values)
1247
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 267)
1248
+ def _reduce_163(val, _values)
1147
1249
  val[0]
1148
1250
  end
1149
1251
  .,.,