CSV to HTML translation: Difference between revisions
Content deleted Content added
Restore MATLAB example, deleted by Bbsingapore. |
→{{header|TXR}}: Bonus points version. |
||
Line 2,821:
=={{header|TXR}}==
====Simple====
<lang txr>@(collect)
Line 2,835 ⟶ 2,837:
</table>
@(end)</lang>
Output:
Line 2,869 ⟶ 2,868:
</tr>
</table></lang>
====With Styling====
<lang txr>@(collect)
@char,@speech
@(end)
@(output :filter :to_html)
<style type="text/css">
tr.odd td {
background-color: #CC9999; color: black;
}
tr.even td {
background-color: #9999CC; color: black;
}
th {
background-color: #99CC99; color: black;
}
</style>
<table>
@ (repeat :counter row)
<tr class="@(if (evenp row) "even" "odd")">
<td>@char</td>
<td>@speech</td>
</tr>
@ (first)
<tr>
<th>@char</th>
<th>@speech</th>
</tr>
@ (end)
</table>
@(end)</lang>
Output:
<pre>$ txr csv2.txr csv.txt</pre>
<lang html5><style type="text/css">
tr.odd td {
background-color: #CC9999; color: black;
}
tr.even td {
background-color: #9999CC; color: black;
}
th {
background-color: #99CC99; color: black;
}
</style>
<table>
<tr>
<th>Character</th>
<th>Speech</th>
</tr>
<tr class="odd">
<td>The multitude</td>
<td>The messiah! Show us the messiah!</td>
</tr>
<tr class="even">
<td>Brians mother</td>
<td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td>
</tr>
<tr class="odd">
<td>The multitude</td>
<td>Who are you?</td>
</tr>
<tr class="even">
<td>Brians mother</td>
<td>I'm his mother; that's who!</td>
</tr>
<tr class="odd">
<td>The multitude</td>
<td>Behold his mother! Behold his mother!</td>
</tr>
</table></lang>
Rendered:
[[File:txr-csv.jpg]]
=={{header|Vedit macro language}}==
|