[Japanese] [English]


Index


Title: RTtool

1 What's new

1.1 [2009/01/25] 1.0.3 released

1.2 [2006/09/20] 1.0.2 released

1.3 [2005/10/28] 1.0.1 released

1.4 [2005/10/26] 1.0.0 released

2 Abstract

RT is a simple and human-readable table format. RTtool is a converter from RT into various formats. RT can be incorporated into RD.

At this time, RTtool can convert RT into HTML and plain text. To convert into plain text, you need w3m.

3 Environment

4 Install

Please execute the following commands.

ruby -ropen-uri -e 'URI("http://www.rubyist.net/~rubikitch/archive/rttool-1.0.3.tar.gz").read.display' > rttool-1.0.3.tar.gz
tar xzvf rttool-1.0.3.tar.gz

When you failed, please download it from the next link.

Then, install it.

cd rttool-1.0.3
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

5 RT Syntax

6 Attributes

In ConfigBlock, these attributes can be set.

caption

The caption of the table.

delimiter

The delimiter of the table.

rowspan

A string which stretches the left column. (defalut: ==)

colspan

A string which stretches the upper row. (default: ||)

escape

An escape character. This attribute is disabled by default.

7 Examples

7.1 The Easiest RT

$ cat examples/easiest.rt
1, 2, 3
4, 5, 6
7, 8, 9

$ rt2 examples/easiest.rt
┌─┬─┬─┐
│ 1│ 2│ 3│
├─┼─┼─┤
│ 4│ 5│ 6│
├─┼─┼─┤
│ 7│ 8│ 9│
└─┴─┴─┘

$ rt2 -r rt/rt2html-lib examples/easiest.rt
<!-- setup -->
<table border="1">
<!-- setup end -->

<!-- Header -->
<!-- Header end -->

<!-- Body -->
<tbody>
<tr><td align="right">1</td><td align="right">2</td><td align="right">3</td></tr>
<tr><td align="right">4</td><td align="right">5</td><td align="right">6</td></tr>
<tr><td align="right">7</td><td align="right">8</td><td align="right">9</td></tr>
</tbody>
<!-- Body end -->

<!-- teardown -->
</table>
<!-- teardown end -->

7.2 Use the Escape Attribute

$ cat examples/escape.rt
delimiter = ;
escape = \

\z   ; \;1 ; 2

$ rt2 examples/escape.rt
┌─┬─┬─┐
│\z│;1│ 2│
└─┴─┴─┘

$ rt2 -r rt/rt2html-lib examples/escape.rt
<!-- setup -->
<table border="1">
<!-- setup end -->

<!-- Header -->
<!-- Header end -->

<!-- Body -->
<tbody>
<tr><td align="left">\z</td><td align="left">;1</td><td align="right">2</td></tr>
</tbody>
<!-- Body end -->

<!-- teardown -->
</table>
<!-- teardown end -->

7.3 More Complex RT

$ cat examples/test1.rt
caption = Test Table

     , Human, == , Dog , ==
||  , M  , F ,M,F

  x  , 1.0 , 2.0, 1.1, 1.2
  y  , 0.4 , 0.5, 0.3, 0.1

$ rt2 examples/test1.rt
          Test Table
┌─┬─────┬─────┐
│  │  Human   │   Dog    │
│  ├──┬──┼──┬──┤
│  │ M  │ F  │ M  │ F  │
├─┼──┼──┼──┼──┤
│x │ 1.0│ 2.0│ 1.1│ 1.2│
├─┼──┼──┼──┼──┤
│y │ 0.4│ 0.5│ 0.3│ 0.1│
└─┴──┴──┴──┴──┘

$ rt2 -r rt/rt2html-lib examples/test1.rt
<!-- setup -->
<table border="1">
<caption>Test Table</caption>
<!-- setup end -->

<!-- Header -->
<thead>
<tr><th rowspan="2"></th><th colspan="2">Human</th><th colspan="2">Dog</th></tr>
<tr><th>M</th><th>F</th><th>M</th><th>F</th></tr>
</thead>
<!-- Header end -->

<!-- Body -->
<tbody>
<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>
<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>
</tbody>
<!-- Body end -->

<!-- teardown -->
</table>
<!-- teardown end -->

7.4 RT Included by RD (RD/RT)

$ cat examples/rttest.rd
=begin
= Sample RD/RT

This RD contains a table.
It is so-called RD/RT.

=end
=begin RT
caption = Test Table

     , Human, == , Dog , ==
||  , M  , F ,M,F

  x  , 1.0 , 2.0, 1.1, 1.2
  y  , 0.4 , 0.5, 0.3, 0.1

=end
=begin
It is simple.
=end

$ rdrt2 examples/rttest.rd | w3m -dump -T text/html
= Sample RD/RT

This RD contains a table. It is so-called RD/RT.

          Test Table
┌─┬─────┬─────┐
│  │  Human   │   Dog    │
│  ├──┬──┼──┬──┤
│  │ M  │ F  │ M  │ F  │
├─┼──┼──┼──┼──┤
│x │ 1.0│ 2.0│ 1.1│ 1.2│
├─┼──┼──┼──┼──┤
│y │ 0.4│ 0.5│ 0.3│ 0.1│
└─┴──┴──┴──┴──┘

It is simple.

8 License

Ruby's


Back to Top

Valid XHTML 1.0!
rubikitch(rubikitch __nos_pam__ At __nos_pam__ ruby-lang DoT org)

Mail Form
Name Mail
URL