import cgi, strutils
const csvtext = """Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!"""
proc row2tr(row): string =
result = "
"
let cols = xmlEncode(row).split(",")
for col in cols:
result.add "| "&col&" | "
result.add "
"
proc csv2html(txt): string =
result = "\n"
for row in txt.splitLines():
result.add " "&row2tr(row)&"\n"
result.add "
"
echo csv2html(csvtext)