Extension:SimpleTable
![]() | This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
![]() | This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
![]() | Warning: The code or configuration described here poses a major security risk. Site administrators: You are advised against using it until this security issue is resolved. Problem: Vulnerable to Cross-site scripting attacks, because it passes user input directly to the browser. This may lead to user accounts being hijacked, among other things. Solution: strictly validate user input and/or apply escaping to all characters that have a special meaning in HTML |
SimpleTable Release status: unmaintained |
|
---|---|
![]() |
|
Implementation | Tag |
Description | Converts tab- (or comma-) separated data into a Wiki table. |
Author(s) | JohanTheGhost |
Latest version | 1.2a |
MediaWiki | 1.6/1.9 |
License | No license specified |
Download | Version 1.2a |
- Note: this extension was called "TabbedData", but this was felt to be misleading (see the talk page), so it has been renamed, as of version 1.2.
This very simple extension allows tabular data to be easily cut-and-pasted into a Wiki; for example, this allows a CSV export from Excel to be pasted in without having to manually edit it into Wiki table syntax. It's really crude, and doesn't allow any kind of clever formatting; for example, there is no way to set row and cell parameters, including row and cell spanning. On the other hand, it's really simple, and it would be pretty easy to expand the parser (the convertTable() function) to handle more complex input.
Suggestions for enhancements are welcome (on the talk page). However, please bear in mind that if we do anything fancy in the markup, it will end up being not much less complex than the Wiki table markup; the whole concept of this extension is to give the user something which is absolutely minimal, and requires no markup learning. If the user has to learn any markup at all, they may as well learn the real MW table markup.
There are now two versions available; a non-class-based version for PHP 4, and an enhanced, class-based version that works with PHP 5 and on MediaWiki 1.9.3. Both versions include Smcnaught's improvement to allow Wiki text within the table — thanks, Smcnaught! — JohanTheGhost 15:25, 12 April 2007 (UTC)
Update: the PHP 5 version now includes a new "sep" option, "bar", and the "head" parameter (see below). JohanTheGhost 17:18, 19 April 2007 (UTC)
Usage[edit]
All you need to do is prepare your data in rows, with fields separated by tab characters. (Excel's "Save as" → "Text (Tab delimited)"
function saves data in this format.) Place the data inside <tab>...</tab>
tags, and set any table parameters inside the opening <tab>
tag:
<tab border=1> Field 1→Field 2→Field 3 Field 4→Field 5→Field 6 Field 7→Field 8→Field 9 </tab>
(where →
represents a tab character) produces the corresponding table. Most table parameters should work; for example, if your wiki has the wikitable
CSS class defined, then this markup should work:
<tab class=wikitable> . . .
Parameter: sep
[edit]
You can use a different separator, using the sep
parameter.
Values[edit]
sep
can be one of:
- tab
- a tab
- space
- a space
- spaces
- one or more spaces and/or tabs
- comma
- a comma
- bar
- a vertical bar (|)
- semicolon
- a semicolon
Parameter: head
[edit]
You can also specify that either the top row or the left column should be formatted as a heading, using the head
parameter.
Values[edit]
head
can be one of:
- top
- make the top row a heading
- left
- make the left column a heading
- topleft
- do both
Oddly Top headings are done by default if head is omitted, use 'head=' to remove them
Example[edit]
<tab class=wikitable sep=comma head=top> Head 1,Head 2,Head 3 Field 4,Field 5,Field 6 Field 7,Field 8,Field 9 </tab>
produces a table with a heading row and two data rows, all having three columns.
Installation[edit]
- Download the extension code:
- Version 1.0 (named "TabbedData"): known to work with PHP 4 and MW 1.6. Usage is the same as above, except that the
sep
andhead
parameters are not supported. - Version 1.1 (named "TabbedData"): known to work with PHP 5 and MW 1.9; will not work on PHP 4 / MW 1.6.
- Version 1.2: added "head=topleft" and "sep=semicolon" and renamed to SimpleTable. Known to work with PHP 5 and MW 1.9; will not work on PHP 4 / MW 1.6.
- Version 1.2a: added "applycssborderstyle=true" which adds css style attributes to the table and cells to show a 1px black border around all cells.
- Version 1.0 (named "TabbedData"): known to work with PHP 4 and MW 1.6. Usage is the same as above, except that the
- Save the code in your wiki's
extensions
directory asextensions/SimpleTable.php
.
Changes to LocalSettings.php[edit]
require_once("$IP/extensions/SimpleTable.php");