Revision history for PLG-Csv
Additions:
// by ThePLG, Mar 2020, license GPL http://wikkawiki.org/PLG-Csv
$style["th"][""]= "background-color:#ccc; ";
$style["tr"]["even"]= "background-color:#ffe; ";
$style["tr"]["odd"]= "background-color:#eee; ";
$style["td"]["error"]= "background-color:#d30; ";
if ( preg_match('/^#!\s*(t[hrd])\s*{/', $csv_line, $a_t) )
if ( preg_match_all('/background-color-?([\w]*)\s*:\s*(#[0-9a-fA-F]{3,6})\s*;/', $csv_line, $a_bkcolors) )
foreach ($a_bkcolors[0] as $n => $bkcolors)
{
$style[ $a_t[1] ][ $a_bkcolors[1][$n] ]= "background-color:". $a_bkcolors[2][$n] ."; ";
// print "style[". $a_t[1] ."][". $a_bkcolors[1][$n] ."]=". $style[ $a_t[1] ][ $a_bkcolors[1][$n] ] ."<br/>";
print (($csv_n+$comments)%2) ? "<tr style=\"". $style["tr"]["even"] ."\">" : "<tr style=\"". $style["tr"]["odd"] ."\">";
// asserts what precedes the ; is not a backslash \\\\, doesn't account for \\; (escaped backslash semicolon)
print "<th style=\"". $style["th"][""] . $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($title[$csv_nn]) ."</th>";
if (preg_match("/^\s*$/",$csv_cell))
print "<td style=\"". $style["td"]["error"] . $style[$csv_nn] ."\">ERROR!</td>"; // $this->htmlspecialchars_ent($csv_cell)
$style["th"][""]= "background-color:#ccc; ";
$style["tr"]["even"]= "background-color:#ffe; ";
$style["tr"]["odd"]= "background-color:#eee; ";
$style["td"]["error"]= "background-color:#d30; ";
if ( preg_match('/^#!\s*(t[hrd])\s*{/', $csv_line, $a_t) )
if ( preg_match_all('/background-color-?([\w]*)\s*:\s*(#[0-9a-fA-F]{3,6})\s*;/', $csv_line, $a_bkcolors) )
foreach ($a_bkcolors[0] as $n => $bkcolors)
{
$style[ $a_t[1] ][ $a_bkcolors[1][$n] ]= "background-color:". $a_bkcolors[2][$n] ."; ";
// print "style[". $a_t[1] ."][". $a_bkcolors[1][$n] ."]=". $style[ $a_t[1] ][ $a_bkcolors[1][$n] ] ."<br/>";
print (($csv_n+$comments)%2) ? "<tr style=\"". $style["tr"]["even"] ."\">" : "<tr style=\"". $style["tr"]["odd"] ."\">";
// asserts what precedes the ; is not a backslash \\\\, doesn't account for \\; (escaped backslash semicolon)
print "<th style=\"". $style["th"][""] . $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($title[$csv_nn]) ."</th>";
if (preg_match("/^\s*$/",$csv_cell))
print "<td style=\"". $style["td"]["error"] . $style[$csv_nn] ."\">ERROR!</td>"; // $this->htmlspecialchars_ent($csv_cell)
Deletions:
$style_header="background-color:#ccc; ";
$style_even="background-color:#ffe; ";
$style_odd="background-color:#eee; ";
$style_error="background-color:#d30; ";
if (preg_match("/^#!\s*th\s*{\s*background-color:\s*([^\s;]*)\s*;\s*}$/", $csv_line, $color)) {
$style_header= "background-color:". $color[1] ."; ";
else
if (preg_match("/^#!\s*td\s*{.*background-color-even\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_even= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-odd\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_odd= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-error\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_error= "background-color:". $color[1] ."; ";
print (($csv_n+$comments)%2) ? "<tr style=\"". $style_even ."\">" : "<tr style=\"". $style_odd ."\">";
// asserts what precedes the ; is not a backslash \\\\, doesn't accoutn for \\; (escaped backslash semicolon)
print "<th style=\"". $style_header . $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($title[$csv_nn]) ."</th>";
if (preg_match("/^\s*$/",$csv_cell)) {
else
print "<td style=\"". $style_error . $style[$csv_nn] ."\">ERROR!</td>"; // $this->htmlspecialchars_ent($csv_cell)
Additions:
~- Sept-2019 Code clean-up, remove deprecated code, more features, fix bugs - ThePLG
~- Mar-2020 Upgrade code for PHP7, add some CSS formatting options.
~- Mar-2020 Upgrade code for PHP7, add some CSS formatting options.
Deletions:
~- 2020-02-29 Upgrade code for PHP7, add some CSS formatting options.
Additions:
~- 2020-02-29 Upgrade code for PHP7, add some CSS formatting options.
Deletions:
Additions:
~- 2020-03-02 Upgrade code for PHP7, add some CSS formatting options.
Additions:
~- Text in quotes is preserved e.g., whitespace, no splitting on semi-colons
<?php
// convert inline csv data into a table.
// by OnegWR, May 2005, license GPL http://wikkawiki.org/OnegWRCsv
// by ThePLG, Feb 2020, license GPL http://wikkawiki.org/PLG-Csv
// Copy the code below into a file named formatters/csv.php
// And give it the same file permissions as the other files in that directory.
$comments= 0;
$style_header="background-color:#ccc; ";
$style_even="background-color:#ffe; ";
$style_odd="background-color:#eee; ";
$style_error="background-color:#d30; ";
print "<table><tbody>\n";
foreach ($array_csv_lines= preg_split("/[\n]/", $text) as $csv_n => $csv_line)
{
if (preg_match("/^#|^\s*$/",$csv_line))
{
if (preg_match("/^#!\s*th\s*{\s*background-color:\s*([^\s;]*)\s*;\s*}$/", $csv_line, $color)) {
$style_header= "background-color:". $color[1] ."; ";
}
else
{
if (preg_match("/^#!\s*td\s*{.*background-color-even\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_even= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-odd\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_odd= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-error\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_error= "background-color:". $color[1] ."; ";
}
$comments++;
continue;
}
print (($csv_n+$comments)%2) ? "<tr style=\"". $style_even ."\">" : "<tr style=\"". $style_odd ."\">";
// https://www.rexegg.com/regex-lookarounds.html
// asserts what precedes the ; is not a backslash \\\\, doesn't accoutn for \\; (escaped backslash semicolon)
// OMFG! https://stackoverflow.com/questions/40479546/how-to-split-on-white-spaces-not-between-quotes
//
foreach (preg_split("/(?<!\\\\);(?=(?:[^\"]*([\"])[^\"]*\\1)*[^\"]*$)/", $csv_line) as $csv_nn => $csv_cell)
{
// https://www.phpliveregex.com
// https://www.regular-expressions.info/quickstart.html
if ($csv_n == $comments) {
$style[$csv_nn]= "padding: 1px 10px 1px 10px; ";
}
if (preg_match("/^\"?\s*==(.*)==\s*\"?$/", $csv_cell, $header))
{
$title[$csv_nn]= $header[1];
if (preg_match("/([\/\\\\|])([^\/\\\\|]*)\\1$/", $title[$csv_nn], $align))
{
switch ($align[1]) {
case "/" : $style[$csv_nn].= "text-align:right; "; break;
case "\\" : $style[$csv_nn].= "text-align:left; "; break;
case "|" : $style[$csv_nn].= "text-align:center; "; break;
}
$title[$csv_nn]= $align[2];
}
print "<th style=\"". $style_header . $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($title[$csv_nn]) ."</th>";
continue;
}
// if a cell is blank, print
//
if (preg_match("/^\s*$/",$csv_cell)) {
print "<td style=\"". $style[$csv_nn] ."\"> </td>";
}
// extract the cell out of it's quotes
//
elseif (preg_match("/^\s*(\"?)(.*)\\1\s*$/", $csv_cell, $matches))
{
if ($matches[1] == "\"")
{
$style[$csv_nn]= "white-space:pre; ". $style[$csv_nn];
$cell= $matches[2];
}
else
$cell= preg_replace('/\\\\;/', ';', $matches[2]);
// test for CamelLink
//
if (preg_match_all("/\[\[([[:alnum:]-]+)\]\]/", $cell, $all_links))
{
$linked= $cell;
foreach ($all_links[1] as $n => $camel_link)
$linked = preg_replace("/\[\[". $camel_link ."\]\]/", $this->Link($camel_link), $linked);
print "<td style=\"". $style[$csv_nn] ."\">". $linked ."</td>"; // no htmlspecialchars_ent()
}
else
print "<td style=\"". $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($cell) ."</td>";
}
else
print "<td style=\"". $style_error . $style[$csv_nn] ."\">ERROR!</td>"; // $this->htmlspecialchars_ent($csv_cell)
}
print "</tr>\n";
}
print "</tbody></table>\n";
?>
<?php
// convert inline csv data into a table.
// by OnegWR, May 2005, license GPL http://wikkawiki.org/OnegWRCsv
// by ThePLG, Feb 2020, license GPL http://wikkawiki.org/PLG-Csv
// Copy the code below into a file named formatters/csv.php
// And give it the same file permissions as the other files in that directory.
$comments= 0;
$style_header="background-color:#ccc; ";
$style_even="background-color:#ffe; ";
$style_odd="background-color:#eee; ";
$style_error="background-color:#d30; ";
print "<table><tbody>\n";
foreach ($array_csv_lines= preg_split("/[\n]/", $text) as $csv_n => $csv_line)
{
if (preg_match("/^#|^\s*$/",$csv_line))
{
if (preg_match("/^#!\s*th\s*{\s*background-color:\s*([^\s;]*)\s*;\s*}$/", $csv_line, $color)) {
$style_header= "background-color:". $color[1] ."; ";
}
else
{
if (preg_match("/^#!\s*td\s*{.*background-color-even\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_even= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-odd\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_odd= "background-color:". $color[1] ."; ";
if (preg_match("/^#!\s*td\s*{.*background-color-error\s*:\s*([^\s;]*)\s*;.*}$/", $csv_line, $color))
$style_error= "background-color:". $color[1] ."; ";
}
$comments++;
continue;
}
print (($csv_n+$comments)%2) ? "<tr style=\"". $style_even ."\">" : "<tr style=\"". $style_odd ."\">";
// https://www.rexegg.com/regex-lookarounds.html
// asserts what precedes the ; is not a backslash \\\\, doesn't accoutn for \\; (escaped backslash semicolon)
// OMFG! https://stackoverflow.com/questions/40479546/how-to-split-on-white-spaces-not-between-quotes
//
foreach (preg_split("/(?<!\\\\);(?=(?:[^\"]*([\"])[^\"]*\\1)*[^\"]*$)/", $csv_line) as $csv_nn => $csv_cell)
{
// https://www.phpliveregex.com
// https://www.regular-expressions.info/quickstart.html
if ($csv_n == $comments) {
$style[$csv_nn]= "padding: 1px 10px 1px 10px; ";
}
if (preg_match("/^\"?\s*==(.*)==\s*\"?$/", $csv_cell, $header))
{
$title[$csv_nn]= $header[1];
if (preg_match("/([\/\\\\|])([^\/\\\\|]*)\\1$/", $title[$csv_nn], $align))
{
switch ($align[1]) {
case "/" : $style[$csv_nn].= "text-align:right; "; break;
case "\\" : $style[$csv_nn].= "text-align:left; "; break;
case "|" : $style[$csv_nn].= "text-align:center; "; break;
}
$title[$csv_nn]= $align[2];
}
print "<th style=\"". $style_header . $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($title[$csv_nn]) ."</th>";
continue;
}
// if a cell is blank, print
//
if (preg_match("/^\s*$/",$csv_cell)) {
print "<td style=\"". $style[$csv_nn] ."\"> </td>";
}
// extract the cell out of it's quotes
//
elseif (preg_match("/^\s*(\"?)(.*)\\1\s*$/", $csv_cell, $matches))
{
if ($matches[1] == "\"")
{
$style[$csv_nn]= "white-space:pre; ". $style[$csv_nn];
$cell= $matches[2];
}
else
$cell= preg_replace('/\\\\;/', ';', $matches[2]);
// test for CamelLink
//
if (preg_match_all("/\[\[([[:alnum:]-]+)\]\]/", $cell, $all_links))
{
$linked= $cell;
foreach ($all_links[1] as $n => $camel_link)
$linked = preg_replace("/\[\[". $camel_link ."\]\]/", $this->Link($camel_link), $linked);
print "<td style=\"". $style[$csv_nn] ."\">". $linked ."</td>"; // no htmlspecialchars_ent()
}
else
print "<td style=\"". $style[$csv_nn] ."\">". $this->htmlspecialchars_ent($cell) ."</td>";
}
else
print "<td style=\"". $style_error . $style[$csv_nn] ."\">ERROR!</td>"; // $this->htmlspecialchars_ent($csv_cell)
}
print "</tr>\n";
}
print "</tbody></table>\n";
?>
Deletions:
Additions:
~- Add more cell formatting options: text/background color, alignment, bold, italic, ...
Deletions:
Additions:
||{border: 0px solid white;}##""==Swede==;""##||{border: 0px solid white;}##"" Chanelle;""##||{border: 0px solid white;}##"" Blomqvist;""##||{border: 0px solid white;}##"" Överhogdal 95\; 282 02 HÖRJA;""##||{border: 0px solid white;}##"" 61""##||
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
Deletions:
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
Additions:
%%
Deletions:
~~""<div><table cellpadding="5" cellspacing="1"><tbody>
<tr bgcolor="#eeeeee"><td> </td><td bgcolor="#cccccc">a</td><td bgcolor="#cccccc">b</td><td bgcolor="#cccccc">c</td></tr>
<tr bgcolor="#ffffee"><td bgcolor="#cccccc">1</td><td>d</td><td>e</td><td>f</td></tr>
<tr bgcolor="#eeeeee"><td bgcolor="#cccccc">2</td><td>g</td><td> </td><td>h</td></tr>
<tr bgcolor="#ffffee"><td bgcolor="#cccccc">3</td><td>I</td><td>J</td><td>K</td></tr>
</tbody></table>
</div>""
<?php
// convert inline csv data into a table.
// by OnegWR, may 2005, license GPL
$csv_printheader=0;
foreach(split("\n", $text) as $csv_n => $csv_line){
if(preg_match("/^#|^\s*$/",$csv_line)) continue;
if( $csv_printheader == 0){ print "<table cellpadding=\"5\" cellspacing=\"1\"><tbody>\n"; $csv_printheader=1; }
print ($csv_n%2) ? "<tr bgcolor=\"#ffffee\">" : "<tr bgcolor=\"#eeeeee\">";
foreach(split(";", $csv_line) as $csv_nn => $csv_cell){
if(preg_match("/^\s*$/",$csv_cell)){
print "<td> </td>";
}elseif(preg_match("/^(\"?)\*\*\*(.*?)\*\*\*(\"?)$/",$csv_cell,$matches)){
print "<td bgcolor=\"#cccccc\">".
$this->htmlspecialchars_ent($matches[2])."</td>";
}elseif(preg_match("/^(\"?)(.*?)(\"?)$/",$csv_cell,$matches)){
print "<td>".$this->htmlspecialchars_ent($matches[2])."</td>";
}else{
print "<td>".$this->htmlspecialchars_ent($csv_cell)."</td>";
}
}
print "</tr>\n";
}
if( $csv_printheader == 1) print "</tbody></table>\n";
?>%%
Additions:
<tr bgcolor="#ffffee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Norwegian</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Sigurd</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Nordmo</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> Viggo Hansteens allé 119; 1524 MOSS</td><td style="padding: 1px 10px 1px 10px; "> 38</td></tr>
Deletions:
Additions:
||{border: 0px solid white;}##""==Swede==;""##||{border: 0px solid white;}##"" Chanelle;""##||{border: 0px solid white;}##"" Blomqvist;""##||{border: 0px solid white;}##"" Överhogdal 95; 282 02 HÖRJA;""##||{border: 0px solid white;}##"" 61""##||
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
""<table><tbody>
<tr bgcolor="#eeeeee"><td> </td><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:right; ">First Name</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:left; ">Last Name</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:center; ">Address</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; "> Age </th></tr>
<tr bgcolor="#ffffee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Norwegian</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Sigurd</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Nordmo</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> [[Viggo]] Hansteens allé 119; 1524 MOSS</td><td style="padding: 1px 10px 1px 10px; "> 38</td></tr>
<tr bgcolor="#eeeeee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Swede</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Chanelle</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Blomqvist</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> Överhogdal 95; 282 02 HÖRJA</td><td style="padding: 1px 10px 1px 10px; "> 61</td></tr>
<tr bgcolor="#ffffee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">German</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Leah</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Ackermann</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> "Landhausstraße 73; 15702 Königs Wusterhausen"</td><td style="padding: 1px 10px 1px 10px; "> 25</td></tr>
<tr bgcolor="#eeeeee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Hobbit</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Celendine</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> "Gam gee"</td><td> </td><td style="padding: 1px 10px 1px 10px; "> 216</td></tr>
</tbody></table>""
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
""<table><tbody>
<tr bgcolor="#eeeeee"><td> </td><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:right; ">First Name</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:left; ">Last Name</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; text-align:center; ">Address</th><th style="background-color:#ccc;padding: 1px 10px 1px 10px; "> Age </th></tr>
<tr bgcolor="#ffffee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Norwegian</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Sigurd</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Nordmo</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> [[Viggo]] Hansteens allé 119; 1524 MOSS</td><td style="padding: 1px 10px 1px 10px; "> 38</td></tr>
<tr bgcolor="#eeeeee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Swede</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Chanelle</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Blomqvist</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> Överhogdal 95; 282 02 HÖRJA</td><td style="padding: 1px 10px 1px 10px; "> 61</td></tr>
<tr bgcolor="#ffffee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">German</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Leah</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> Ackermann</td><td style="padding: 1px 10px 1px 10px; text-align:center; "> "Landhausstraße 73; 15702 Königs Wusterhausen"</td><td style="padding: 1px 10px 1px 10px; "> 25</td></tr>
<tr bgcolor="#eeeeee"><th style="background-color:#ccc;padding: 1px 10px 1px 10px; ">Hobbit</th><td style="padding: 1px 10px 1px 10px; text-align:right; "> Celendine</td><td style="padding: 1px 10px 1px 10px; text-align:left; "> "Gam gee"</td><td> </td><td style="padding: 1px 10px 1px 10px; "> 216</td></tr>
</tbody></table>""
Deletions:
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
Additions:
||{border: 0px solid white;}##""==German==;""##||{border: 0px solid white;}##"" Leah;""##||{border: 0px solid white;}##"" Ackermann;""##||{border: 0px solid white;}##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||{border: 0px solid white;}##"" 25""##||
||(x:5){border: 0px solid white;}##""# Comments are possible. Yes, the following person is a Hobbit!""##||
||{border: 0px solid white;}##""==Hobbit==;""##||{border: 0px solid white;}##""Celendine;""##||{border: 0px solid white;}##"" "Gam gee";""##||{border: 0px solid white;}##"" ;""##||{border: 0px solid white;}##"" 216""##||
||{border: 0px solid white;}##""%%""##||
||(x:5){border: 0px solid white;}##""# Comments are possible. Yes, the following person is a Hobbit!""##||
||{border: 0px solid white;}##""==Hobbit==;""##||{border: 0px solid white;}##""Celendine;""##||{border: 0px solid white;}##"" "Gam gee";""##||{border: 0px solid white;}##"" ;""##||{border: 0px solid white;}##"" 216""##||
||{border: 0px solid white;}##""%%""##||
Deletions:
||(x:5)##""# Comments are possible. Yes, the following person is a Hobbit!""##||
||##""==Hobbit==;""##||##""Celendine;""##||##"" "Gam gee";""##||##"" ;""##||##"" 216""##||
||##""%%""##||
Additions:
|!|{border: 0px solid white;}||
||{border: 0px solid white;}##""%%(csv)""##||
||{border: 0px solid white;}##"";""##||{border: 0px solid white;}##""==/First Name/==;""##||{border: 0px solid white;}##""==\Last Name\==;""##||{border: 0px solid white;}##""==|Address|==;""##||{border: 0px solid white;}##""== Age ==""##||
||{border: 0px solid white;}##""==Norwegian==;""##||{border: 0px solid white;}##""Sigurd;""##||{border: 0px solid white;}##""Nordmo;""##||{border: 0px solid white;}##""[[Viggo]] Hansteens allé 119\; 1524 MOSS;""##||{border: 0px solid white;}##"" 38""##||
||{border: 0px solid white;}##""==Swede==;""##||{border: 0px solid white;}##"" Chanelle;""##||{border: 0px solid white;}##"" Blomqvist;""##||{border: 0px solid white;}##"" Överhogdal 95\; 282 02 HÖRJA;""##||{border: 0px solid white;}##"" 61""##||
||{border: 0px solid white;}##""%%(csv)""##||
||{border: 0px solid white;}##"";""##||{border: 0px solid white;}##""==/First Name/==;""##||{border: 0px solid white;}##""==\Last Name\==;""##||{border: 0px solid white;}##""==|Address|==;""##||{border: 0px solid white;}##""== Age ==""##||
||{border: 0px solid white;}##""==Norwegian==;""##||{border: 0px solid white;}##""Sigurd;""##||{border: 0px solid white;}##""Nordmo;""##||{border: 0px solid white;}##""[[Viggo]] Hansteens allé 119\; 1524 MOSS;""##||{border: 0px solid white;}##"" 38""##||
||{border: 0px solid white;}##""==Swede==;""##||{border: 0px solid white;}##"" Chanelle;""##||{border: 0px solid white;}##"" Blomqvist;""##||{border: 0px solid white;}##"" Överhogdal 95\; 282 02 HÖRJA;""##||{border: 0px solid white;}##"" 61""##||
Deletions:
||##""%%(csv)""##||
||##"";""##||##""==/First Name/==;""##||##""==\Last Name\==;""##||##""==|Address|==;""##||##""== Age ==""##||
||##""==Norwegian==;""##||##""Sigurd;""##||##""Nordmo;""##||##""[[Viggo]] Hansteens allé 119\; 1524 MOSS;""##||##"" 38""##||
||##""==Swede==;""##||##"" Chanelle;""##||##"" Blomqvist;""##||##"" Överhogdal 95\; 282 02 HÖRJA;""##||##"" 61""##||
Additions:
|!|{border: 1px solid white; color: black;}||
Deletions:
Additions:
|!|{border: 0px solid white; color: black;}||
||##""%%(csv)""##||
||##"";""##||##""==/First Name/==;""##||##""==\Last Name\==;""##||##""==|Address|==;""##||##""== Age ==""##||
||##""==Norwegian==;""##||##""Sigurd;""##||##""Nordmo;""##||##""[[Viggo]] Hansteens allé 119\; 1524 MOSS;""##||##"" 38""##||
||##""==Swede==;""##||##"" Chanelle;""##||##"" Blomqvist;""##||##"" Överhogdal 95\; 282 02 HÖRJA;""##||##"" 61""##||
||##""==German==;""##||##"" Leah;""##||##"" Ackermann;""##||##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||##"" 25""##||
||(x:5)##""# Comments are possible. Yes, the following person is a Hobbit!""##||
||##""==Hobbit==;""##||##""Celendine;""##||##"" "Gam gee";""##||##"" ;""##||##"" 216""##||
||##""%%""##||
||##""%%(csv)""##||
||##"";""##||##""==/First Name/==;""##||##""==\Last Name\==;""##||##""==|Address|==;""##||##""== Age ==""##||
||##""==Norwegian==;""##||##""Sigurd;""##||##""Nordmo;""##||##""[[Viggo]] Hansteens allé 119\; 1524 MOSS;""##||##"" 38""##||
||##""==Swede==;""##||##"" Chanelle;""##||##"" Blomqvist;""##||##"" Överhogdal 95\; 282 02 HÖRJA;""##||##"" 61""##||
||##""==German==;""##||##"" Leah;""##||##"" Ackermann;""##||##"" Landhausstraße 73\; 15702 Königs Wusterhausen;""##||##"" 25""##||
||(x:5)##""# Comments are possible. Yes, the following person is a Hobbit!""##||
||##""==Hobbit==;""##||##""Celendine;""##||##"" "Gam gee";""##||##"" ;""##||##"" 216""##||
||##""%%""##||
Deletions:
||""%%(csv)""||
||"";""||##""==/First Name/==;""##||##""==\Last Name\==;""##||""==|Address|==;""||""== Age ==""||
""==Norwegian==; Sigurd; Nordmo; [[Viggo]] Hansteens allé 119\; 1524 MOSS; 38""
""==Swede==; Chanelle; Blomqvist; Överhogdal 95\; 282 02 HÖRJA; 61""
""==German==; Leah; Ackermann; Landhausstraße 73\; 15702 Königs Wusterhausen; 25""
""# Comments are possible. Yes, the following person is a Hobbit!""
""==Hobbit==; Celendine; "Gam gee"; ; 216""
""%%""
~%%(csv)
~;***a***;"***b***";***c***
~***1***;d;"e";f
~#test
~
~***2***;g;;h
~***3***;I;J;"K"
~%%
Additions:
|!|{border: 0px solid white;}||
||""%%(csv)""||
||"";""||##""==/First Name/==;""##||##""==\Last Name\==;""##||""==|Address|==;""||""== Age ==""||
""==Norwegian==; Sigurd; Nordmo; [[Viggo]] Hansteens allé 119\; 1524 MOSS; 38""
""==Swede==; Chanelle; Blomqvist; Överhogdal 95\; 282 02 HÖRJA; 61""
""==German==; Leah; Ackermann; Landhausstraße 73\; 15702 Königs Wusterhausen; 25""
""# Comments are possible. Yes, the following person is a Hobbit!""
""==Hobbit==; Celendine; "Gam gee"; ; 216""
""%%""
~%%(csv)
~;***a***;"***b***";***c***
~***1***;d;"e";f
~#test
~
~***2***;g;;h
~***3***;I;J;"K"
~%%
||""%%(csv)""||
||"";""||##""==/First Name/==;""##||##""==\Last Name\==;""##||""==|Address|==;""||""== Age ==""||
""==Norwegian==; Sigurd; Nordmo; [[Viggo]] Hansteens allé 119\; 1524 MOSS; 38""
""==Swede==; Chanelle; Blomqvist; Överhogdal 95\; 282 02 HÖRJA; 61""
""==German==; Leah; Ackermann; Landhausstraße 73\; 15702 Königs Wusterhausen; 25""
""# Comments are possible. Yes, the following person is a Hobbit!""
""==Hobbit==; Celendine; "Gam gee"; ; 216""
""%%""
~%%(csv)
~;***a***;"***b***";***c***
~***1***;d;"e";f
~#test
~
~***2***;g;;h
~***3***;I;J;"K"
~%%
Deletions:
~- The code:
~~%%(csv)
~~;***a***;"***b***";***c***
~~***1***;d;"e";f
~~#test
~~
~~***2***;g;;h
~~***3***;I;J;"K"
~~%%
Additions:
~- 2005-05-09 Published on main site - OnegWR
~- 2019-09-03 Code clean-up, remove deprecated code, more features, fix bugs - ThePLG
~- 2019-09-03 Code clean-up, remove deprecated code, more features, fix bugs - ThePLG
Deletions:
Additions:
==TODO==
~- text in quotes needs to be preserved e.g., whitespace, no splitting on semi-colons
~- camel links are really hard to see
~- Add more cell formatting options: alignment, bold, italic, ...
~- text in quotes needs to be preserved e.g., whitespace, no splitting on semi-colons
~- camel links are really hard to see
~- Add more cell formatting options: alignment, bold, italic, ...
Deletions:
~- Add more cell options: alignment, bold, Italic, ...
~- Fix the ';' in a cell ("">"",...)
==Bugs==
~- Remove the the default yellow background via the [[OnegWRNoDefaultCodeClass | NoDefaultCodeClass]] workaround.
~- If there is an ';' within a cell, this script will make 2 cell from it.
Additions:
~- Rows of the table alternate background color
~- Column alignment: left, right, center or default
~- Table headers/footers using wiki style heading markers
~- Add comments in between data by starting a line with (#); blank lines are ignored
~- Cells can be surrounded in double quotes (")
~- It is possible to escape semi-colons with a backslash (\), that should appear in text
~- Camel links in cell text are linked to their wiki internal pages
Deletions:
~- Ignores empty lines or lines starting with an '#' (comments).
~~To not disturb the alternated layout: add 2 (comment)lines...
~- The " before and after a cell is auto-removed.
~- You can make the background darker by wrapping the cell in "***"-tags.
Additions:
This formatter converts inline csv data into a table.
Deletions:
Deletions:
Deletions:
Additions:
test
if(preg_match("/^#|^\s*$/",$csv_line)) continue;
if( $csv_printheader == 0){ print "<table cellpadding=\"5\" cellspacing=\"1\"><tbody>\n"; $csv_printheader=1; }
print ($csv_n%2) ? "<tr bgcolor=\"#ffffee\">" : "<tr bgcolor=\"#eeeeee\">";
foreach(split(";", $csv_line) as $csv_nn => $csv_cell){
if(preg_match("/^\s*$/",$csv_cell)){
print "<td> </td>";
}elseif(preg_match("/^(\"?)\*\*\*(.*?)\*\*\*(\"?)$/",$csv_cell,$matches)){
print "<td bgcolor=\"#cccccc\">".
$this->htmlspecialchars_ent($matches[2])."</td>";
}elseif(preg_match("/^(\"?)(.*?)(\"?)$/",$csv_cell,$matches)){
print "<td>".$this->htmlspecialchars_ent($matches[2])."</td>";
}else{
print "<td>".$this->htmlspecialchars_ent($csv_cell)."</td>";
}
}
print "</tr>\n";
if(preg_match("/^#|^\s*$/",$csv_line)) continue;
if( $csv_printheader == 0){ print "<table cellpadding=\"5\" cellspacing=\"1\"><tbody>\n"; $csv_printheader=1; }
print ($csv_n%2) ? "<tr bgcolor=\"#ffffee\">" : "<tr bgcolor=\"#eeeeee\">";
foreach(split(";", $csv_line) as $csv_nn => $csv_cell){
if(preg_match("/^\s*$/",$csv_cell)){
print "<td> </td>";
}elseif(preg_match("/^(\"?)\*\*\*(.*?)\*\*\*(\"?)$/",$csv_cell,$matches)){
print "<td bgcolor=\"#cccccc\">".
$this->htmlspecialchars_ent($matches[2])."</td>";
}elseif(preg_match("/^(\"?)(.*?)(\"?)$/",$csv_cell,$matches)){
print "<td>".$this->htmlspecialchars_ent($matches[2])."</td>";
}else{
print "<td>".$this->htmlspecialchars_ent($csv_cell)."</td>";
}
}
print "</tr>\n";
Deletions:
if( $csv_printheader == 0){ print "<table cellpadding=\"5\" cellspacing=\"1\"><tbody>\n"; $csv_printheader=1; }
print ($csv_n%2) ? "<tr bgcolor=\"#ffffee\">" : "<tr bgcolor=\"#eeeeee\">";
foreach(split(";", $csv_line) as $csv_nn => $csv_cell){
if(preg_match("/^\s*$/",$csv_cell)){
print "<td> </td>";
}elseif(preg_match("/^(\"?)\*\*\*(.*?)\*\*\*(\"?)$/",$csv_cell,$matches)){
print "<td bgcolor=\"#cccccc\">".
$this->htmlspecialchars_ent($matches[2])."</td>";
}elseif(preg_match("/^(\"?)(.*?)(\"?)$/",$csv_cell,$matches)){
print "<td>".$this->htmlspecialchars_ent($matches[2])."</td>";
}else{
print "<td>".$this->htmlspecialchars_ent($csv_cell)."</td>";
}
}
print "</tr>\n";