rttool 1.0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +62 -0
- data/GPL +340 -0
- data/bin/rt/rdrt2 +2 -0
- data/bin/rt/rt2 +162 -0
- data/examples/easiest.html +19 -0
- data/examples/easiest.rt +3 -0
- data/examples/escape.html +17 -0
- data/examples/escape.rt +4 -0
- data/examples/rttest.html +40 -0
- data/examples/rttest.rd +20 -0
- data/examples/test1.html +23 -0
- data/examples/test1.rt +7 -0
- data/examples/test2.html +23 -0
- data/examples/test2.rt +7 -0
- data/lib/rd/rt-filter.rb +11 -0
- data/lib/rt/rt2html-lib.rb +91 -0
- data/lib/rt/rt2txt-lib.rb +15 -0
- data/lib/rt/rtparser.rb +226 -0
- data/lib/rt/rtvisitor.rb +68 -0
- data/lib/rt/w3m.rb +47 -0
- data/rttool.en.html +299 -0
- data/rttool.en.rd +265 -0
- data/rttool.ja.html +383 -0
- data/rttool.ja.rd +316 -0
- data/test/rttool-sub.rb +1023 -0
- data/test/test-rt2html-lib.rb +65 -0
- data/test/test-rtparser.rb +209 -0
- data/test/test.rb +88 -0
- metadata +75 -0
data/lib/rt/rtvisitor.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
=begin
|
3
|
+
rtvisitor.rb
|
4
|
+
$Id: rtvisitor.rb 597 2005-10-18 21:03:12Z rubikitch $
|
5
|
+
=end
|
6
|
+
require 'rt/rtparser'
|
7
|
+
|
8
|
+
module RT
|
9
|
+
class RTVisitor
|
10
|
+
def each_cell(ary)
|
11
|
+
ary.each do |x|
|
12
|
+
if x.class == RT::RTCell
|
13
|
+
yield x
|
14
|
+
else
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
private :each_cell
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
end
|
22
|
+
attr_reader :rt, :header, :body, :caption
|
23
|
+
attr_accessor :filename, :charcode
|
24
|
+
|
25
|
+
def self.visit(parsed)
|
26
|
+
self::new.visit(parsed)
|
27
|
+
end
|
28
|
+
|
29
|
+
def visit(parsed)
|
30
|
+
@filename = @charset = nil
|
31
|
+
@rt = parsed
|
32
|
+
@header = @rt.header
|
33
|
+
@body = @rt.body
|
34
|
+
@caption = @rt.config['caption']
|
35
|
+
|
36
|
+
setup +
|
37
|
+
visit_Caption +
|
38
|
+
visit_Header +
|
39
|
+
visit_Body +
|
40
|
+
teardown
|
41
|
+
end
|
42
|
+
|
43
|
+
def setup
|
44
|
+
""
|
45
|
+
end
|
46
|
+
|
47
|
+
def teardown
|
48
|
+
""
|
49
|
+
end
|
50
|
+
|
51
|
+
def visit_Caption
|
52
|
+
""
|
53
|
+
end
|
54
|
+
|
55
|
+
def visit_Header
|
56
|
+
""
|
57
|
+
end
|
58
|
+
|
59
|
+
def visit_Body
|
60
|
+
""
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
data/lib/rt/w3m.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
=begin
|
3
|
+
w3m.rb
|
4
|
+
$Id: w3m.rb 597 2005-10-18 21:03:12Z rubikitch $
|
5
|
+
|
6
|
+
--- W3M.w3m(url, options='-e')
|
7
|
+
invoke w3m.
|
8
|
+
--- W3M.html2txt(htmlstr, options='-e')
|
9
|
+
convert htmlstr to plain text.
|
10
|
+
--- W3M.source(url, options='-e')
|
11
|
+
get the source.
|
12
|
+
=end
|
13
|
+
|
14
|
+
module W3M
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
def external_filter (str, prog)
|
19
|
+
require 'open3'
|
20
|
+
|
21
|
+
pipe = Open3.popen3(prog)
|
22
|
+
pipe[0] .print str
|
23
|
+
pipe[0] .close
|
24
|
+
pipe[1] .read
|
25
|
+
end
|
26
|
+
private_class_method :external_filter
|
27
|
+
|
28
|
+
def w3m(url, option='-e')
|
29
|
+
open("| w3m -dump #{option} #{url}").readlines.join
|
30
|
+
end
|
31
|
+
|
32
|
+
def html2txt(htmlstr, option='-e')
|
33
|
+
external_filter(htmlstr, "w3m -dump -T text/html #{option}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def source(url, option='')
|
37
|
+
open("| w3m -dump_source #{option} #{url}").readlines.join
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if __FILE__ == $0
|
42
|
+
s = W3M::source('http://www.ruby-lang.org')
|
43
|
+
#print W3M::html2txt s
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
data/rttool.en.html
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-2022-jp" ?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
|
6
|
+
<head>
|
7
|
+
<title>RTtool</title>
|
8
|
+
<meta http-equiv="Content-type" content="text/html; charset=iso-2022-jp" />
|
9
|
+
<!-- head-element:nil -->
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h2>Index</h2>
|
13
|
+
|
14
|
+
<ul>
|
15
|
+
<li><p><a href="#label:1">What's new</a></p>
|
16
|
+
<ul>
|
17
|
+
<li><a href="#label:2">[2006/09/20] 1.0.2 released</a></li>
|
18
|
+
<li><a href="#label:3">[2005/10/28] 1.0.1 released</a></li>
|
19
|
+
<li><a href="#label:4">[2005/10/26] 1.0.0 released</a></li>
|
20
|
+
</ul></li>
|
21
|
+
<li><a href="#label:5">Abstract</a></li>
|
22
|
+
<li><a href="#label:6">Environment</a></li>
|
23
|
+
<li><a href="#label:7">Install</a></li>
|
24
|
+
<li><a href="#label:8">RT Syntax</a></li>
|
25
|
+
<li><a href="#label:12">Attributes</a></li>
|
26
|
+
<li><p><a href="#label:18">Examples</a></p>
|
27
|
+
<ul>
|
28
|
+
<li><a href="#label:19">The Easiest RT</a></li>
|
29
|
+
<li><a href="#label:20">Use the Escape Attribute</a></li>
|
30
|
+
<li><a href="#label:21">More Complex RT</a></li>
|
31
|
+
<li><a href="#label:22">RT Included by RD (RD/RT)</a></li>
|
32
|
+
</ul></li>
|
33
|
+
<li><a href="#label:23">License</a></li>
|
34
|
+
</ul>
|
35
|
+
<hr />
|
36
|
+
|
37
|
+
<h1><a name="Title:" href="#Title:">Title:</a> <a name="label:0">RTtool</a></h1><!-- RDLabel: "RTtool" -->
|
38
|
+
|
39
|
+
<h2><a name="1" href="#1">1</a> <a name="label:1">What's new</a></h2><!-- RDLabel: "What's new" -->
|
40
|
+
|
41
|
+
<h3><a name="1.1" href="#1.1">1.1</a> <a name="label:2">[2006/09/20] 1.0.2 released</a></h3><!-- RDLabel: "[2006/09/20] 1.0.2 released" -->
|
42
|
+
|
43
|
+
<ul>
|
44
|
+
<li>Bugfix about linefeed.</li>
|
45
|
+
</ul>
|
46
|
+
<h3><a name="1.2" href="#1.2">1.2</a> <a name="label:3">[2005/10/28] 1.0.1 released</a></h3><!-- RDLabel: "[2005/10/28] 1.0.1 released" -->
|
47
|
+
|
48
|
+
<ul>
|
49
|
+
<li>RTtool does not use .rd2rc anymore.</li>
|
50
|
+
</ul>
|
51
|
+
<h3><a name="1.3" href="#1.3">1.3</a> <a name="label:4">[2005/10/26] 1.0.0 released</a></h3><!-- RDLabel: "[2005/10/26] 1.0.0 released" -->
|
52
|
+
|
53
|
+
<ul>
|
54
|
+
<li>Escape.</li>
|
55
|
+
<li>English document.</li>
|
56
|
+
<li>Removed Ruby-1.8 warning.</li>
|
57
|
+
</ul>
|
58
|
+
<h2><a name="2" href="#2">2</a> <a name="label:5">Abstract</a></h2><!-- RDLabel: "Abstract" -->
|
59
|
+
|
60
|
+
<p>RT is a simple and human-readable table format.
|
61
|
+
RTtool is a converter from RT into various formats.
|
62
|
+
RT can be incorporated into RD.</p>
|
63
|
+
<p>At this time, RTtool can convert RT into HTML and plain text.
|
64
|
+
To convert into plain text, you need <a href="http://w3m.sourceforge.net/">w3m</a>.</p>
|
65
|
+
<h2><a name="3" href="#3">3</a> <a name="label:6">Environment</a></h2><!-- RDLabel: "Environment" -->
|
66
|
+
|
67
|
+
<h2><a name="4" href="#4">4</a> <a name="label:7">Install</a></h2><!-- RDLabel: "Install" -->
|
68
|
+
|
69
|
+
<p>Please execute the following commands.</p>
|
70
|
+
<pre>ruby -ropen-uri -e 'URI("http://www.rubyist.net/~rubikitch/archive/rttool-1.0.2.tar.gz").read.display' > rttool-1.0.2.tar.gz</pre>
|
71
|
+
<pre>tar xzvf rttool-1.0.2.tar.gz</pre>
|
72
|
+
<p>When you failed, please download it from the next link.</p>
|
73
|
+
<ul>
|
74
|
+
<li><a href="http://www.rubyist.net/~rubikitch/archive/rttool-1.0.2.tar.gz">rttool-1.0.2.tar.gz</a></li>
|
75
|
+
</ul>
|
76
|
+
<p>Then, install it.</p>
|
77
|
+
<pre>cd rttool-1.0.2
|
78
|
+
ruby setup.rb config
|
79
|
+
ruby setup.rb setup
|
80
|
+
ruby setup.rb install</pre>
|
81
|
+
<h2><a name="5" href="#5">5</a> <a name="label:8">RT Syntax</a></h2><!-- RDLabel: "RT Syntax" -->
|
82
|
+
|
83
|
+
<ul>
|
84
|
+
<li><p>RT consists of three Blocks.</p>
|
85
|
+
<dl>
|
86
|
+
<dt><a name="label:9" id="label:9"></a>ConfigBlock</dt><!-- RDLabel: "ConfigBlock" -->
|
87
|
+
<dd>
|
88
|
+
<p>ConfigBlock consist of groups of "attribute = value".
|
89
|
+
The following examples has <code>caption</code> attribute.
|
90
|
+
ConfigBlock can be omitted.</p>
|
91
|
+
</dd>
|
92
|
+
<dt><a name="label:10" id="label:10"></a>HeaderBlock</dt><!-- RDLabel: "HeaderBlock" -->
|
93
|
+
<dd>
|
94
|
+
<p>A part of THEAD by HTML.
|
95
|
+
HeaderBlock sets a header of the table.
|
96
|
+
A header is located at the center.
|
97
|
+
HeaderBlock can be omitted.</p>
|
98
|
+
</dd>
|
99
|
+
<dt><a name="label:11" id="label:11"></a>BodyBlock</dt><!-- RDLabel: "BodyBlock" -->
|
100
|
+
<dd>
|
101
|
+
<p>A part of TBODY by HTML.
|
102
|
+
BodyBlock sets data of the table.
|
103
|
+
A number is located at the right and others are located at left.</p>
|
104
|
+
</dd>
|
105
|
+
</dl></li>
|
106
|
+
<li><p>The default delimiter on HeaderBlock and BodyBlock is a comma or a Tab.</p>
|
107
|
+
<ul>
|
108
|
+
<li>It is not necessary to be always harmonious with an upper line.</li>
|
109
|
+
<li>Arbitrary character can be a delimiter by changing <code>delimiter</code> attribute.</li>
|
110
|
+
</ul></li>
|
111
|
+
<li><code>==</code> stretches the left column. (colspan)</li>
|
112
|
+
<li><code>||</code> stretches the upper row. (rowspan)</li>
|
113
|
+
</ul>
|
114
|
+
<h2><a name="6" href="#6">6</a> <a name="label:12">Attributes</a></h2><!-- RDLabel: "Attributes" -->
|
115
|
+
|
116
|
+
<p>In ConfigBlock, these attributes can be set.</p>
|
117
|
+
<dl>
|
118
|
+
<dt><a name="label:13" id="label:13"></a>caption</dt><!-- RDLabel: "caption" -->
|
119
|
+
<dd>
|
120
|
+
<p>The caption of the table.</p>
|
121
|
+
</dd>
|
122
|
+
<dt><a name="label:14" id="label:14"></a>delimiter</dt><!-- RDLabel: "delimiter" -->
|
123
|
+
<dd>
|
124
|
+
<p>The delimiter of the table.</p>
|
125
|
+
</dd>
|
126
|
+
<dt><a name="label:15" id="label:15"></a>rowspan</dt><!-- RDLabel: "rowspan" -->
|
127
|
+
<dd>
|
128
|
+
<p>A string which stretches the left column. (defalut: <code>==</code>)</p>
|
129
|
+
</dd>
|
130
|
+
<dt><a name="label:16" id="label:16"></a>colspan</dt><!-- RDLabel: "colspan" -->
|
131
|
+
<dd>
|
132
|
+
<p>A string which stretches the upper row. (default: <code>||</code>)</p>
|
133
|
+
</dd>
|
134
|
+
<dt><a name="label:17" id="label:17"></a>escape</dt><!-- RDLabel: "escape" -->
|
135
|
+
<dd>
|
136
|
+
<p>An escape character.
|
137
|
+
This attribute is disabled by default.</p>
|
138
|
+
</dd>
|
139
|
+
</dl>
|
140
|
+
<h2><a name="7" href="#7">7</a> <a name="label:18">Examples</a></h2><!-- RDLabel: "Examples" -->
|
141
|
+
|
142
|
+
<h3><a name="7.1" href="#7.1">7.1</a> <a name="label:19">The Easiest RT</a></h3><!-- RDLabel: "The Easiest RT" -->
|
143
|
+
|
144
|
+
<pre>$ cat examples/easiest.rt
|
145
|
+
1, 2, 3
|
146
|
+
4, 5, 6
|
147
|
+
7, 8, 9
|
148
|
+
|
149
|
+
$ rt2 examples/easiest.rt
|
150
|
+
$B(#(!(((!(((!($(B
|
151
|
+
$B("(B 1$B("(B 2$B("(B 3$B("(B
|
152
|
+
$B('(!(+(!(+(!()(B
|
153
|
+
$B("(B 4$B("(B 5$B("(B 6$B("(B
|
154
|
+
$B('(!(+(!(+(!()(B
|
155
|
+
$B("(B 7$B("(B 8$B("(B 9$B("(B
|
156
|
+
$B(&(!(*(!(*(!(%(B
|
157
|
+
|
158
|
+
$ rt2 -r rt/rt2html-lib examples/easiest.rt
|
159
|
+
<!-- setup -->
|
160
|
+
<table border="1">
|
161
|
+
<!-- setup end -->
|
162
|
+
|
163
|
+
<!-- Header -->
|
164
|
+
<!-- Header end -->
|
165
|
+
|
166
|
+
<!-- Body -->
|
167
|
+
<tbody>
|
168
|
+
<tr><td align="right">1</td><td align="right">2</td><td align="right">3</td></tr>
|
169
|
+
<tr><td align="right">4</td><td align="right">5</td><td align="right">6</td></tr>
|
170
|
+
<tr><td align="right">7</td><td align="right">8</td><td align="right">9</td></tr>
|
171
|
+
</tbody>
|
172
|
+
<!-- Body end -->
|
173
|
+
|
174
|
+
<!-- teardown -->
|
175
|
+
</table>
|
176
|
+
<!-- teardown end --></pre>
|
177
|
+
<h3><a name="7.2" href="#7.2">7.2</a> <a name="label:20">Use the Escape Attribute</a></h3><!-- RDLabel: "Use the Escape Attribute" -->
|
178
|
+
|
179
|
+
<pre>$ cat examples/escape.rt
|
180
|
+
delimiter = ;
|
181
|
+
escape = \
|
182
|
+
|
183
|
+
\z ; \;1 ; 2
|
184
|
+
|
185
|
+
$ rt2 examples/escape.rt
|
186
|
+
$B(#(!(((!(((!($(B
|
187
|
+
$B("(B\z$B("(B;1$B("(B 2$B("(B
|
188
|
+
$B(&(!(*(!(*(!(%(B
|
189
|
+
|
190
|
+
$ rt2 -r rt/rt2html-lib examples/escape.rt
|
191
|
+
<!-- setup -->
|
192
|
+
<table border="1">
|
193
|
+
<!-- setup end -->
|
194
|
+
|
195
|
+
<!-- Header -->
|
196
|
+
<!-- Header end -->
|
197
|
+
|
198
|
+
<!-- Body -->
|
199
|
+
<tbody>
|
200
|
+
<tr><td align="left">\z</td><td align="left">;1</td><td align="right">2</td></tr>
|
201
|
+
</tbody>
|
202
|
+
<!-- Body end -->
|
203
|
+
|
204
|
+
<!-- teardown -->
|
205
|
+
</table>
|
206
|
+
<!-- teardown end --></pre>
|
207
|
+
<h3><a name="7.3" href="#7.3">7.3</a> <a name="label:21">More Complex RT</a></h3><!-- RDLabel: "More Complex RT" -->
|
208
|
+
|
209
|
+
<pre>$ cat examples/test1.rt
|
210
|
+
caption = Test Table
|
211
|
+
|
212
|
+
, Human, == , Dog , ==
|
213
|
+
|| , M , F ,M,F
|
214
|
+
|
215
|
+
x , 1.0 , 2.0, 1.1, 1.2
|
216
|
+
y , 0.4 , 0.5, 0.3, 0.1
|
217
|
+
|
218
|
+
$ rt2 examples/test1.rt
|
219
|
+
Test Table
|
220
|
+
$B(#(!(((!(!(!(!(!(((!(!(!(!(!($(B
|
221
|
+
$B("(B $B("(B Human $B("(B Dog $B("(B
|
222
|
+
$B("(B $B('(!(!(((!(!(+(!(!(((!(!()(B
|
223
|
+
$B("(B $B("(B M $B("(B F $B("(B M $B("(B F $B("(B
|
224
|
+
$B('(!(+(!(!(+(!(!(+(!(!(+(!(!()(B
|
225
|
+
$B("(Bx $B("(B 1.0$B("(B 2.0$B("(B 1.1$B("(B 1.2$B("(B
|
226
|
+
$B('(!(+(!(!(+(!(!(+(!(!(+(!(!()(B
|
227
|
+
$B("(By $B("(B 0.4$B("(B 0.5$B("(B 0.3$B("(B 0.1$B("(B
|
228
|
+
$B(&(!(*(!(!(*(!(!(*(!(!(*(!(!(%(B
|
229
|
+
|
230
|
+
$ rt2 -r rt/rt2html-lib examples/test1.rt
|
231
|
+
<!-- setup -->
|
232
|
+
<table border="1">
|
233
|
+
<caption>Test Table</caption>
|
234
|
+
<!-- setup end -->
|
235
|
+
|
236
|
+
<!-- Header -->
|
237
|
+
<thead>
|
238
|
+
<tr><th rowspan="2"></th><th colspan="2">Human</th><th colspan="2">Dog</th></tr>
|
239
|
+
<tr><th>M</th><th>F</th><th>M</th><th>F</th></tr>
|
240
|
+
</thead>
|
241
|
+
<!-- Header end -->
|
242
|
+
|
243
|
+
<!-- Body -->
|
244
|
+
<tbody>
|
245
|
+
<tr><td align="left">x</td><td align="right">1.0</td><td align="right">2.0</td><td align="right">1.1</td><td align="right">1.2</td></tr>
|
246
|
+
<tr><td align="left">y</td><td align="right">0.4</td><td align="right">0.5</td><td align="right">0.3</td><td align="right">0.1</td></tr>
|
247
|
+
</tbody>
|
248
|
+
<!-- Body end -->
|
249
|
+
|
250
|
+
<!-- teardown -->
|
251
|
+
</table>
|
252
|
+
<!-- teardown end --></pre>
|
253
|
+
<h3><a name="7.4" href="#7.4">7.4</a> <a name="label:22">RT Included by RD (RD/RT)</a></h3><!-- RDLabel: "RT Included by RD (RD/RT)" -->
|
254
|
+
|
255
|
+
<pre>$ cat examples/rttest.rd
|
256
|
+
=begin
|
257
|
+
= Sample RD/RT
|
258
|
+
|
259
|
+
This RD contains a table.
|
260
|
+
It is so-called RD/RT.
|
261
|
+
|
262
|
+
=end
|
263
|
+
=begin RT
|
264
|
+
caption = Test Table
|
265
|
+
|
266
|
+
, Human, == , Dog , ==
|
267
|
+
|| , M , F ,M,F
|
268
|
+
|
269
|
+
x , 1.0 , 2.0, 1.1, 1.2
|
270
|
+
y , 0.4 , 0.5, 0.3, 0.1
|
271
|
+
|
272
|
+
=end
|
273
|
+
=begin
|
274
|
+
It is simple.
|
275
|
+
=end
|
276
|
+
|
277
|
+
$ rdrt2 examples/rttest.rd | w3m -dump -T text/html
|
278
|
+
= Sample RD/RT
|
279
|
+
|
280
|
+
This RD contains a table. It is so-called RD/RT.
|
281
|
+
|
282
|
+
Test Table
|
283
|
+
$B(#(!(((!(!(!(!(!(((!(!(!(!(!($(B
|
284
|
+
$B("(B $B("(B Human $B("(B Dog $B("(B
|
285
|
+
$B("(B $B('(!(!(((!(!(+(!(!(((!(!()(B
|
286
|
+
$B("(B $B("(B M $B("(B F $B("(B M $B("(B F $B("(B
|
287
|
+
$B('(!(+(!(!(+(!(!(+(!(!(+(!(!()(B
|
288
|
+
$B("(Bx $B("(B 1.0$B("(B 2.0$B("(B 1.1$B("(B 1.2$B("(B
|
289
|
+
$B('(!(+(!(!(+(!(!(+(!(!(+(!(!()(B
|
290
|
+
$B("(By $B("(B 0.4$B("(B 0.5$B("(B 0.3$B("(B 0.1$B("(B
|
291
|
+
$B(&(!(*(!(!(*(!(!(*(!(!(*(!(!(%(B
|
292
|
+
|
293
|
+
It is simple.</pre>
|
294
|
+
<h2><a name="8" href="#8">8</a> <a name="label:23">License</a></h2><!-- RDLabel: "License" -->
|
295
|
+
|
296
|
+
<p>Ruby's</p>
|
297
|
+
|
298
|
+
</body>
|
299
|
+
</html>
|
data/rttool.en.rd
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
|
4
|
+
= RTtool
|
5
|
+
|
6
|
+
##### [whats new]
|
7
|
+
== What's new
|
8
|
+
|
9
|
+
=== [2006/09/20] 1.0.2 released
|
10
|
+
* Bugfix about linefeed.
|
11
|
+
|
12
|
+
=== [2005/10/28] 1.0.1 released
|
13
|
+
* RTtool does not use .rd2rc anymore.
|
14
|
+
=== [2005/10/26] 1.0.0 released
|
15
|
+
|
16
|
+
* Escape.
|
17
|
+
* English document.
|
18
|
+
* Removed Ruby-1.8 warning.
|
19
|
+
|
20
|
+
##### [/whats new]
|
21
|
+
|
22
|
+
##### [abstract]
|
23
|
+
== Abstract
|
24
|
+
|
25
|
+
RT is a simple and human-readable table format.
|
26
|
+
RTtool is a converter from RT into various formats.
|
27
|
+
RT can be incorporated into RD.
|
28
|
+
|
29
|
+
At this time, RTtool can convert RT into HTML and plain text.
|
30
|
+
To convert into plain text, you need ((<w3m|URL:http://w3m.sourceforge.net/>)).
|
31
|
+
|
32
|
+
##### [/abstract]
|
33
|
+
== Environment
|
34
|
+
|
35
|
+
##### [install]
|
36
|
+
== Install
|
37
|
+
Please execute the following commands.
|
38
|
+
|
39
|
+
ruby -ropen-uri -e 'URI("http://www.rubyist.net/~rubikitch/archive/rttool-1.0.2.tar.gz").read.display' > rttool-1.0.2.tar.gz
|
40
|
+
tar xzvf rttool-1.0.2.tar.gz
|
41
|
+
|
42
|
+
|
43
|
+
When you failed, please download it from the next link.
|
44
|
+
|
45
|
+
* ((<rttool-1.0.2.tar.gz|URL:http://www.rubyist.net/~rubikitch/archive/rttool-1.0.2.tar.gz>))
|
46
|
+
|
47
|
+
Then, install it.
|
48
|
+
|
49
|
+
cd rttool-1.0.2
|
50
|
+
ruby setup.rb config
|
51
|
+
ruby setup.rb setup
|
52
|
+
ruby setup.rb install
|
53
|
+
|
54
|
+
|
55
|
+
##### [/install]
|
56
|
+
|
57
|
+
== RT Syntax
|
58
|
+
* RT consists of three Blocks.
|
59
|
+
:ConfigBlock
|
60
|
+
ConfigBlock consist of groups of "attribute = value".
|
61
|
+
The following examples has (({caption})) attribute.
|
62
|
+
ConfigBlock can be omitted.
|
63
|
+
:HeaderBlock
|
64
|
+
A part of THEAD by HTML.
|
65
|
+
HeaderBlock sets a header of the table.
|
66
|
+
A header is located at the center.
|
67
|
+
HeaderBlock can be omitted.
|
68
|
+
:BodyBlock
|
69
|
+
A part of TBODY by HTML.
|
70
|
+
BodyBlock sets data of the table.
|
71
|
+
A number is located at the right and others are located at left.
|
72
|
+
* The default delimiter on HeaderBlock and BodyBlock is a comma or a Tab.
|
73
|
+
* It is not necessary to be always harmonious with an upper line.
|
74
|
+
* Arbitrary character can be a delimiter by changing (({delimiter})) attribute.
|
75
|
+
* (({==})) stretches the left column. (colspan)
|
76
|
+
* (({||})) stretches the upper row. (rowspan)
|
77
|
+
|
78
|
+
== Attributes
|
79
|
+
In ConfigBlock, these attributes can be set.
|
80
|
+
|
81
|
+
:caption
|
82
|
+
The caption of the table.
|
83
|
+
|
84
|
+
:delimiter
|
85
|
+
The delimiter of the table.
|
86
|
+
|
87
|
+
:rowspan
|
88
|
+
A string which stretches the left column. (defalut: (({==})))
|
89
|
+
|
90
|
+
:colspan
|
91
|
+
A string which stretches the upper row. (default: (({||})))
|
92
|
+
|
93
|
+
:escape
|
94
|
+
An escape character.
|
95
|
+
This attribute is disabled by default.
|
96
|
+
|
97
|
+
== Examples
|
98
|
+
|
99
|
+
=== The Easiest RT
|
100
|
+
$ cat examples/easiest.rt
|
101
|
+
1, 2, 3
|
102
|
+
4, 5, 6
|
103
|
+
7, 8, 9
|
104
|
+
|
105
|
+
$ rt2 examples/easiest.rt
|
106
|
+
��������������
|
107
|
+
�� 1�� 2�� 3��
|
108
|
+
��������������
|
109
|
+
�� 4�� 5�� 6��
|
110
|
+
��������������
|
111
|
+
�� 7�� 8�� 9��
|
112
|
+
��������������
|
113
|
+
|
114
|
+
$ rt2 -r rt/rt2html-lib examples/easiest.rt
|
115
|
+
<!-- setup -->
|
116
|
+
<table border="1">
|
117
|
+
<!-- setup end -->
|
118
|
+
|
119
|
+
<!-- Header -->
|
120
|
+
<!-- Header end -->
|
121
|
+
|
122
|
+
<!-- Body -->
|
123
|
+
<tbody>
|
124
|
+
<tr><td align="right">1</td><td align="right">2</td><td align="right">3</td></tr>
|
125
|
+
<tr><td align="right">4</td><td align="right">5</td><td align="right">6</td></tr>
|
126
|
+
<tr><td align="right">7</td><td align="right">8</td><td align="right">9</td></tr>
|
127
|
+
</tbody>
|
128
|
+
<!-- Body end -->
|
129
|
+
|
130
|
+
<!-- teardown -->
|
131
|
+
</table>
|
132
|
+
<!-- teardown end -->
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
=== Use the Escape Attribute
|
138
|
+
$ cat examples/escape.rt
|
139
|
+
delimiter = ;
|
140
|
+
escape = \
|
141
|
+
|
142
|
+
\z ; \;1 ; 2
|
143
|
+
|
144
|
+
$ rt2 examples/escape.rt
|
145
|
+
��������������
|
146
|
+
��\z��;1�� 2��
|
147
|
+
��������������
|
148
|
+
|
149
|
+
$ rt2 -r rt/rt2html-lib examples/escape.rt
|
150
|
+
<!-- setup -->
|
151
|
+
<table border="1">
|
152
|
+
<!-- setup end -->
|
153
|
+
|
154
|
+
<!-- Header -->
|
155
|
+
<!-- Header end -->
|
156
|
+
|
157
|
+
<!-- Body -->
|
158
|
+
<tbody>
|
159
|
+
<tr><td align="left">\z</td><td align="left">;1</td><td align="right">2</td></tr>
|
160
|
+
</tbody>
|
161
|
+
<!-- Body end -->
|
162
|
+
|
163
|
+
<!-- teardown -->
|
164
|
+
</table>
|
165
|
+
<!-- teardown end -->
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
=== More Complex RT
|
171
|
+
$ cat examples/test1.rt
|
172
|
+
caption = Test Table
|
173
|
+
|
174
|
+
, Human, == , Dog , ==
|
175
|
+
|| , M , F ,M,F
|
176
|
+
|
177
|
+
x , 1.0 , 2.0, 1.1, 1.2
|
178
|
+
y , 0.4 , 0.5, 0.3, 0.1
|
179
|
+
|
180
|
+
$ rt2 examples/test1.rt
|
181
|
+
Test Table
|
182
|
+
������������������������������
|
183
|
+
�� �� Human �� Dog ��
|
184
|
+
�� ��������������������������
|
185
|
+
�� �� M �� F �� M �� F ��
|
186
|
+
������������������������������
|
187
|
+
��x �� 1.0�� 2.0�� 1.1�� 1.2��
|
188
|
+
������������������������������
|
189
|
+
��y �� 0.4�� 0.5�� 0.3�� 0.1��
|
190
|
+
������������������������������
|
191
|
+
|
192
|
+
$ rt2 -r rt/rt2html-lib examples/test1.rt
|
193
|
+
<!-- setup -->
|
194
|
+
<table border="1">
|
195
|
+
<caption>Test Table</caption>
|
196
|
+
<!-- setup end -->
|
197
|
+
|
198
|
+
<!-- Header -->
|
199
|
+
<thead>
|
200
|
+
<tr><th rowspan="2"></th><th colspan="2">Human</th><th colspan="2">Dog</th></tr>
|
201
|
+
<tr><th>M</th><th>F</th><th>M</th><th>F</th></tr>
|
202
|
+
</thead>
|
203
|
+
<!-- Header end -->
|
204
|
+
|
205
|
+
<!-- Body -->
|
206
|
+
<tbody>
|
207
|
+
<tr><td align="left">x</td><td align="right">1.0</td><td align="right">2.0</td><td align="right">1.1</td><td align="right">1.2</td></tr>
|
208
|
+
<tr><td align="left">y</td><td align="right">0.4</td><td align="right">0.5</td><td align="right">0.3</td><td align="right">0.1</td></tr>
|
209
|
+
</tbody>
|
210
|
+
<!-- Body end -->
|
211
|
+
|
212
|
+
<!-- teardown -->
|
213
|
+
</table>
|
214
|
+
<!-- teardown end -->
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
=== RT Included by RD (RD/RT)
|
220
|
+
$ cat examples/rttest.rd
|
221
|
+
=begin
|
222
|
+
= Sample RD/RT
|
223
|
+
|
224
|
+
This RD contains a table.
|
225
|
+
It is so-called RD/RT.
|
226
|
+
|
227
|
+
=end
|
228
|
+
=begin RT
|
229
|
+
caption = Test Table
|
230
|
+
|
231
|
+
, Human, == , Dog , ==
|
232
|
+
|| , M , F ,M,F
|
233
|
+
|
234
|
+
x , 1.0 , 2.0, 1.1, 1.2
|
235
|
+
y , 0.4 , 0.5, 0.3, 0.1
|
236
|
+
|
237
|
+
=end
|
238
|
+
=begin
|
239
|
+
It is simple.
|
240
|
+
=end
|
241
|
+
|
242
|
+
$ rdrt2 examples/rttest.rd | w3m -dump -T text/html
|
243
|
+
= Sample RD/RT
|
244
|
+
|
245
|
+
This RD contains a table. It is so-called RD/RT.
|
246
|
+
|
247
|
+
Test Table
|
248
|
+
������������������������������
|
249
|
+
�� �� Human �� Dog ��
|
250
|
+
�� ��������������������������
|
251
|
+
�� �� M �� F �� M �� F ��
|
252
|
+
������������������������������
|
253
|
+
��x �� 1.0�� 2.0�� 1.1�� 1.2��
|
254
|
+
������������������������������
|
255
|
+
��y �� 0.4�� 0.5�� 0.3�� 0.1��
|
256
|
+
������������������������������
|
257
|
+
|
258
|
+
It is simple.
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
== License
|
264
|
+
Ruby's
|
265
|
+
=end
|