raf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.rdoc +21 -2
- data/RELEASE +1 -0
- data/VERSION +1 -1
- data/bin/raf +19 -0
- data/bin/raf2html +11 -4
- data/lib/raf.rb +7 -0
- data/lib/raf2html.rb +4 -1
- data/lib/raf2html_element.rb +1 -1
- data/lib/rafinlineparser.ry +20 -58
- data/lib/rafinlineparser.tab.rb +285 -432
- metadata +7 -3
- /data/{test.raf → sample.raf} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c185ed73d5d2fe3fed31aa048c256b458cdef61d
|
4
|
+
data.tar.gz: 0f728c67524f41bd3fa44adbd571b95444a24552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c264951405f105cf060dd463c45ef91a3cd2901fbae978ee1e913a1cb2b3d496d6d969b7008673ffcc052480b35f4c50734b1a8c7309eded18097b391fede3f
|
7
|
+
data.tar.gz: f588eecc9d45853a027822ca9034091f0965cf11419a40ff188fad8c2a32b5e925730169f2b5f2519aa6ad51901e390d7559586b0386d074ff525298bf9be62a
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -2,14 +2,33 @@
|
|
2
2
|
"raf" is simple document format.
|
3
3
|
refer to : http://garin.jp/doc/raf/raf (this page is japanese)
|
4
4
|
|
5
|
-
==
|
5
|
+
== INSTALLATION
|
6
6
|
// check ruby version
|
7
7
|
$ ruby -v
|
8
8
|
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
|
9
9
|
|
10
|
-
// raf gem package install
|
10
|
+
// raf gem package install
|
11
11
|
$ gem install raf
|
12
12
|
|
13
|
+
== UTILITIES
|
14
|
+
=== raf
|
15
|
+
print raf format version.
|
16
|
+
|
17
|
+
=== raf2html
|
18
|
+
Raf format to HTML format conveter.
|
19
|
+
|
20
|
+
+ Usage
|
21
|
+
// edit
|
22
|
+
$ vi mydoc.raf
|
23
|
+
= This is My document
|
24
|
+
raf is simple document format.
|
25
|
+
|
26
|
+
// to html
|
27
|
+
$ raf2html mydoc.raf > mydoc.html
|
28
|
+
|
29
|
+
== Read more
|
30
|
+
Official Web Site : http://garin.jp/doc/raf/raf (this page is japanese)
|
31
|
+
|
13
32
|
== Copyright
|
14
33
|
Copyright (c) 2011-2013 garin. See LICENSE.txt for
|
15
34
|
further details.
|
data/RELEASE
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2013-11-26
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/raf
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (C) garin <garin54@gmail.com> 2011-2013
|
4
|
+
# See the included file COPYING for details.
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
6
|
+
require "raf"
|
7
|
+
require "optparse"
|
8
|
+
|
9
|
+
opt = OptionParser.new do |opt|
|
10
|
+
opt.version = Raf::VERSION
|
11
|
+
opt.release = Raf::RELEASE
|
12
|
+
opt.banner = <<EOL
|
13
|
+
"raf" is simple document format.
|
14
|
+
Read more: https://github.com/garin/raf
|
15
|
+
EOL
|
16
|
+
end
|
17
|
+
|
18
|
+
opt.parse!(ARGV)
|
19
|
+
puts opt.help
|
data/bin/raf2html
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*-
|
3
|
-
# Copyright (C) garin <garin54@gmail.com> 2011
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (C) garin <garin54@gmail.com> 2011-2013
|
4
4
|
# See the included file COPYING for details.
|
5
5
|
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
6
6
|
require "optparse"
|
7
7
|
require "raf2html"
|
8
8
|
|
9
|
+
def usage(opt)
|
10
|
+
puts opt.help
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
9
14
|
options = {:css => nil, :language => 'ja', :index => true, :quiet => false}
|
10
15
|
opt = OptionParser.new do |opt|
|
11
|
-
opt.
|
12
|
-
opt.version =
|
16
|
+
opt.banner = "Usage: raf2html [options] file"
|
17
|
+
opt.version = Raf::Raf2Html::VERSION
|
18
|
+
opt.release = Raf::Raf2Html::RELEASE
|
13
19
|
opt.on("--css file", "スタイルシートのファイルを指定") {|f| options[:css] = f}
|
14
20
|
opt.on("-L", "--language LANG", "言語(デフォルトは #{options[:language]} 。ドキュメント側で指定されていればそちらを優先)"){|l| options[:language] = l}
|
15
21
|
opt.on("--[no-]index", "目次を生成する(デフォルトは生成する)"){|v| options[:index] = v }
|
@@ -17,6 +23,7 @@ opt = OptionParser.new do |opt|
|
|
17
23
|
opt.on("-q","--quiet", "本文だけを出力する(ヘッダやフッタは出力しない)"){ options[:quiet] = true }
|
18
24
|
end
|
19
25
|
opt.parse!(ARGV)
|
26
|
+
usage(opt) unless ARGV[0]
|
20
27
|
src = File.open(ARGV[0],"r").readlines
|
21
28
|
raf = Raf::Raf2Html.new(src, options)
|
22
29
|
puts raf.to_html
|
data/lib/raf.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) garin <garin54@gmail.com> 2011-2013
|
3
|
+
# See the included file COPYING for details.
|
4
|
+
module Raf
|
5
|
+
VERSION = File.readlines(File.join(File.dirname(__FILE__),"../VERSION"))[0].strip
|
6
|
+
RELEASE = File.readlines(File.join(File.dirname(__FILE__),"../RELEASE"))[0].strip
|
7
|
+
end
|
data/lib/raf2html.rb
CHANGED
@@ -6,6 +6,9 @@ require "cgi"
|
|
6
6
|
|
7
7
|
module Raf
|
8
8
|
class Raf2Html
|
9
|
+
VERSION="0.0.2"
|
10
|
+
RELEASE="2011-04-07"
|
11
|
+
|
9
12
|
def initialize(src, options = {})
|
10
13
|
@debug = true
|
11
14
|
|
@@ -18,7 +21,7 @@ module Raf
|
|
18
21
|
|
19
22
|
@raf = BlockParser.new
|
20
23
|
@metadata = setup_metadata
|
21
|
-
@nodes = @raf.parse src
|
24
|
+
@nodes = @raf.parse src
|
22
25
|
end
|
23
26
|
|
24
27
|
def setup_metadata
|
data/lib/raf2html_element.rb
CHANGED
data/lib/rafinlineparser.ry
CHANGED
@@ -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 LABEL_OPEN LABEL_CLOSE REFERENCE_OPEN REFERENCE_CLOSE VERB_OPEN VERB_CLOSE ERB_OPEN ERB_CLOSE FOOTNOTE_OPEN FOOTNOTE_CLOSE RUBY_OPEN RUBY_CLOSE IMAGE_OPEN IMAGE_CLOSE MANUEDO_OPEN MANUEDO_CLOSE
|
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
5
|
options no_result_var
|
6
6
|
rule
|
7
7
|
content :
|
@@ -10,7 +10,6 @@ class InlineParser
|
|
10
10
|
elements : elements element { val[0].push(val[1]) }
|
11
11
|
| element { val }
|
12
12
|
|
13
|
-
|
14
13
|
element : emphasis
|
15
14
|
| italic
|
16
15
|
| strike
|
@@ -21,6 +20,7 @@ class InlineParser
|
|
21
20
|
| image
|
22
21
|
| verb
|
23
22
|
| erb
|
23
|
+
| herb
|
24
24
|
| manuedo
|
25
25
|
| normal_strings
|
26
26
|
|
@@ -34,15 +34,10 @@ class InlineParser
|
|
34
34
|
Footnote.new([val[1], @index[:footnote].size])
|
35
35
|
}
|
36
36
|
|
37
|
-
|
38
37
|
# --- inline end
|
39
38
|
|
40
39
|
# --- image
|
41
40
|
image_string : OTHER
|
42
|
-
| QUOTE
|
43
|
-
| BAR
|
44
|
-
| SLASH
|
45
|
-
| BACK_SLASH
|
46
41
|
| EM_OPEN
|
47
42
|
| EM_CLOSE
|
48
43
|
| ITALIC_OPEN
|
@@ -55,6 +50,7 @@ class InlineParser
|
|
55
50
|
| MANUEDO_CLOSE
|
56
51
|
| ERB_OPEN
|
57
52
|
| ERB_CLOSE
|
53
|
+
| HERB_OPEN
|
58
54
|
| REFERENCE_OPEN
|
59
55
|
| REFERENCE_CLOSE
|
60
56
|
| LABEL_OPEN
|
@@ -72,10 +68,6 @@ class InlineParser
|
|
72
68
|
# --- image end
|
73
69
|
# --- ruby
|
74
70
|
ruby_string : OTHER
|
75
|
-
| QUOTE
|
76
|
-
| BAR
|
77
|
-
| SLASH
|
78
|
-
| BACK_SLASH
|
79
71
|
| EM_OPEN
|
80
72
|
| EM_CLOSE
|
81
73
|
| ITALIC_OPEN
|
@@ -88,6 +80,7 @@ class InlineParser
|
|
88
80
|
| MANUEDO_CLOSE
|
89
81
|
| ERB_OPEN
|
90
82
|
| ERB_CLOSE
|
83
|
+
| HERB_OPEN
|
91
84
|
| REFERENCE_OPEN
|
92
85
|
| REFERENCE_CLOSE
|
93
86
|
| LABEL_OPEN
|
@@ -112,6 +105,9 @@ class InlineParser
|
|
112
105
|
erb : ERB_OPEN verb_string ERB_CLOSE {
|
113
106
|
e = ERB.new("<%= #{val[1]} %>")
|
114
107
|
Plain.new(e.result) }
|
108
|
+
herb : HERB_OPEN verb_string ERB_CLOSE {
|
109
|
+
e = ERB.new("<% #{val[1]} %>")
|
110
|
+
Plain.new(e.result) }
|
115
111
|
# --- erb end
|
116
112
|
# --- manuedo
|
117
113
|
manuedo : MANUEDO_OPEN content MANUEDO_CLOSE { Manuedo.new(val[1]) }
|
@@ -120,10 +116,7 @@ class InlineParser
|
|
120
116
|
|
121
117
|
# --- label
|
122
118
|
label_string : OTHER { val[0] }
|
123
|
-
|
124
|
-
| BAR { val[0] }
|
125
|
-
| SLASH { val[0] }
|
126
|
-
| BACK_SLASH { val[0] }
|
119
|
+
|
127
120
|
|
128
121
|
label_strings : label_strings label_string { val.join }
|
129
122
|
| label_string { val[0] }
|
@@ -139,10 +132,6 @@ class InlineParser
|
|
139
132
|
# --- labe end
|
140
133
|
# --- reference : start
|
141
134
|
reference_string : OTHER { val[0] }
|
142
|
-
| QUOTE { val[0] }
|
143
|
-
| BAR { val[0] }
|
144
|
-
| SLASH { val[0] }
|
145
|
-
| BACK_SLASH { val[0] }
|
146
135
|
|
147
136
|
reference_strings : reference_strings reference_string { val.join }
|
148
137
|
| reference_string { val[0] }
|
@@ -156,10 +145,6 @@ class InlineParser
|
|
156
145
|
# --- reference : end
|
157
146
|
# --- verb
|
158
147
|
verb_string : OTHER
|
159
|
-
| QUOTE
|
160
|
-
| BAR
|
161
|
-
| SLASH
|
162
|
-
| BACK_SLASH
|
163
148
|
| EM_OPEN
|
164
149
|
| EM_CLOSE
|
165
150
|
| ITALIC_OPEN
|
@@ -172,6 +157,7 @@ class InlineParser
|
|
172
157
|
| MANUEDO_CLOSE
|
173
158
|
| ERB_OPEN
|
174
159
|
| ERB_CLOSE
|
160
|
+
| HERB_OPEN
|
175
161
|
| REFERENCE_OPEN
|
176
162
|
| REFERENCE_CLOSE
|
177
163
|
| LABEL_OPEN
|
@@ -193,10 +179,6 @@ class InlineParser
|
|
193
179
|
| normal_strings normal_string { Plain.new([val[0].contents, val[1]]) }
|
194
180
|
|
195
181
|
normal_string : OTHER { val[0] }
|
196
|
-
| QUOTE { val[0] }
|
197
|
-
| BAR { val[0] }
|
198
|
-
| SLASH { val[0] }
|
199
|
-
| BACK_SLASH { val[0] }
|
200
182
|
# --- normal end
|
201
183
|
|
202
184
|
---- inner
|
@@ -232,7 +214,6 @@ IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
|
|
232
214
|
IMAGE_CLOSE = '$))'
|
233
215
|
IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
|
234
216
|
|
235
|
-
|
236
217
|
LABEL_OPEN = '((>'
|
237
218
|
LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
|
238
219
|
LABEL_CLOSE = '<))'
|
@@ -243,15 +224,14 @@ LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
|
|
243
224
|
LABEL_HTML_CLOSE = '<))'
|
244
225
|
LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
|
245
226
|
|
246
|
-
|
247
227
|
REFERENCE_OPEN = '((<'
|
248
228
|
REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
|
249
229
|
REFERENCE_CLOSE = '>))'
|
250
230
|
REFERENCE_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_CLOSE)}/
|
251
231
|
|
252
|
-
REFERENCE_HTML_OPEN = '((
|
232
|
+
REFERENCE_HTML_OPEN = '((<'
|
253
233
|
REFERENCE_HTML_OPEN_RE = /\A#{Regexp.quote(REFERENCE_HTML_OPEN)}/
|
254
|
-
REFERENCE_HTML_CLOSE = '
|
234
|
+
REFERENCE_HTML_CLOSE = '>))'
|
255
235
|
REFERENCE_HTML_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_HTML_CLOSE)}/
|
256
236
|
|
257
237
|
VERB_OPEN = "(('"
|
@@ -264,27 +244,21 @@ MANUEDO_OPEN_RE = /\A#{Regexp.quote(MANUEDO_OPEN)}/
|
|
264
244
|
MANUEDO_CLOSE = "/))"
|
265
245
|
MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
|
266
246
|
|
267
|
-
ERB_OPEN = "
|
247
|
+
ERB_OPEN = "<%="
|
268
248
|
ERB_OPEN_RE = /\A#{Regexp.quote(ERB_OPEN)}/
|
269
|
-
ERB_CLOSE = "
|
249
|
+
ERB_CLOSE = "%>"
|
270
250
|
ERB_CLOSE_RE = /\A#{Regexp.quote(ERB_CLOSE)}/
|
271
251
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
QUOTE_RE = /\A#{Regexp.quote(QUOTE)}/
|
276
|
-
SLASH = "/"
|
277
|
-
SLASH_RE = /\A#{Regexp.quote(SLASH)}/
|
278
|
-
BACK_SLASH = "\\"
|
279
|
-
BACK_SLASH_RE = /\A#{Regexp.quote(BACK_SLASH)}/
|
252
|
+
HERB_OPEN = "<%"
|
253
|
+
HERB_OPEN_RE = /\A#{Regexp.quote(HERB_OPEN)}/
|
254
|
+
|
280
255
|
# URL = "URL:"
|
281
256
|
# URL_RE = /\A#{Regexp.quote(URL)}/
|
282
257
|
|
283
258
|
#other_re_mode = Regexp::EXTENDED
|
284
259
|
other_re_mode = Regexp::MULTILINE
|
285
260
|
OTHER_RE = Regexp.new(
|
286
|
-
"\\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(
|
287
|
-
|
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)
|
288
262
|
|
289
263
|
def parse(src)
|
290
264
|
@src = StringScanner.new(Array(src).join)
|
@@ -404,22 +378,10 @@ def next_token
|
|
404
378
|
puts "i: ERB_CLOSE: #{ret}" if @view_token_type
|
405
379
|
@pre << ret
|
406
380
|
[:ERB_CLOSE, ret]
|
407
|
-
elsif ret = @src.scan(
|
408
|
-
puts "i:
|
409
|
-
@pre << ret
|
410
|
-
[:BAR, ret]
|
411
|
-
elsif ret = @src.scan(QUOTE_RE)
|
412
|
-
puts "i: QUOTE: #{ret}" if @view_token_type
|
413
|
-
@pre << ret
|
414
|
-
[:QUOTE, ret]
|
415
|
-
elsif ret = @src.scan(SLASH_RE)
|
416
|
-
puts "i: SLASH: #{ret}" if @view_token_type
|
417
|
-
@pre << ret
|
418
|
-
[:SLASH, ret]
|
419
|
-
elsif ret = @src.scan(BACK_SLASH_RE)
|
420
|
-
puts "i: BACK_SLASH: #{ret}" if @view_token_type
|
381
|
+
elsif ret = @src.scan(HERB_OPEN_RE)
|
382
|
+
puts "i: HERB_OPEN: #{ret}" if @view_token_type
|
421
383
|
@pre << ret
|
422
|
-
[:
|
384
|
+
[:HERB_OPEN, ret]
|
423
385
|
elsif ret = @src.scan(OTHER_RE)
|
424
386
|
puts "i: OTHER_RE: #{ret}" if @view_token_type
|
425
387
|
@pre << ret
|