Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package require Tcl 8.5
package require csv
package require html
package require struct::queue
set csvData "Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!"
struct::queue rows
foreach line [split $csvData "\n"] {
csv::split2queue rows $line
}
html::init
puts [subst {
[html::openTag table {summary="csv2html program output"}]
[html::while {[rows size]} {
[html::row {*}[html::quoteFormValue [rows get]]]
}]
[html::closeTag]
}]

View file

@ -0,0 +1,45 @@
package require Tcl 8.5
package require csv
package require html
package require struct::queue
set csvData "Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!"
html::init {
table.border 1
table.summary "csv2html program output"
tr.bgcolor orange
}
# Helpers; the html package is a little primitive otherwise
proc table {contents {opts ""}} {
set out [html::openTag table $opts]
append out [uplevel 1 [list subst $contents]]
append out [html::closeTag]
}
proc tr {list {ropt ""}} {
set out [html::openTag tr $ropt]
foreach x $list {append out [html::cell "" $x td]}
append out [html::closeTag]
}
# Parse the CSV data
struct::queue rows
foreach line [split $csvData "\n"] {
csv::split2queue rows $line
}
# Generate the output
puts [subst {
[table {
[tr [html::quoteFormValue [rows get]] {bgcolor="yellow"}]
[html::while {[rows size]} {
[tr [html::quoteFormValue [rows get]]]
}]
}]
}]

View file

@ -0,0 +1,8 @@
<table border="1" summary="csv2html program output">
<tr bgcolor="yellow"><td>Character</td><td>Speech</td></tr>
<tr bgcolor="orange"><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr>
<tr bgcolor="orange"><td>Brians mother</td><td>&lt;angry&gt;Now you listen here! He&#39;s not the messiah; he&#39;s a very naughty boy! Now go away! &lt;/angry&gt;</td></tr>
<tr bgcolor="orange"><td>The multitude</td><td>Who are you?</td></tr>
<tr bgcolor="orange"><td>Brians mother</td><td>I&#39;m his mother; that&#39;s who!</td></tr>
<tr bgcolor="orange"><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</table>