web commit by JoshTriplett: Formatting, typos, and wording.
[ikiwiki.git] / doc / plugins / contrib / table.mdwn
1 [[meta title="table (third-party plugin)"]]
2
3 This plugin supplies a `table` [[PreprocessorDirective]] to build html tables from data in CSV (comma-separated values) or DSV (delimiter-separated values) format.
4
5 It needs the perl module [[cpan Text::CSV]] for the CSV data.
6
7 ## Usage
8
9 In any source page include the following:
10
11     The next table shows the results:
12
13     \[[table class="myclass" format=dsv data="""
14     Custom|Amount|
15     Fulanito|134,34|
16     Menganito|234,56|
17     """]]
18
19     This is my last acquisition:
20
21     [[table class="book_record" format=csv file="data/books/record1"]]
22
23     And the record1 page should be similar to:
24
25     "Title","Perl Best Practices"
26     "Author","Damian Conway"
27     "Publisher","O’Reilly"
28
29 The parameters are:
30
31 - _data_: Values for the table
32 - _file_: Wiki page containing the data.
33 - _format_ (optional): format name of the data. By default is `auto` and the options are `csv` or `dsv`.
34 - _delimiter_ (optional): The character used to separate fields. By default, DSV format uses a pipe (`|`), and CSV uses a comma (`,`).
35 - _class_ (optional): CSS class for the table html element
36 - _caption_ (optional): Text string for the table caption.
37 - _no\_header_: This switch disables the generation of table header (`<th>`) elements. By default, the `table` directive uses the first data line as column headers.
38
39 The _data_ and _file_ parameters are mutually exclusive.
40
41 Note: the automatic format detection mechanism is still very rudimentary.
42
43 ## Changelog
44
45 ### version 0.5
46
47 * Remove a call to an inexistent [[cpan Text::CSV]] method.
48 * Added the sep_char parameter.
49 * Parse CSV data in binary mode.
50 * Added a format detection mechanism.
51 * Default format now is 'auto'.
52
53 ## Links
54
55 - Information about the formats in Wikipedia:
56     - [[wikipedia CSV]]
57     - [[wikipedia DSV]]
58
59 - Download the tar file from <http://taquiones.net/files/misc/>
60 - Debian package in <http://taquiones.net/files/debian/>