Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/CSV-to-HTML-translation/Nim/csv-to-html-translation.nim
Normal file
23
Task/CSV-to-HTML-translation/Nim/csv-to-html-translation.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import cgi, strutils
|
||||
|
||||
const csvtext = """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!"""
|
||||
|
||||
proc row2tr(row): string =
|
||||
result = "<tr>"
|
||||
let cols = xmlEncode(row).split(",")
|
||||
for col in cols:
|
||||
result.add "<td>"&col&"</td>"
|
||||
result.add "</tr>"
|
||||
|
||||
proc csv2html(txt): string =
|
||||
result = "<table summary=\"csv2html program output\">\n"
|
||||
for row in txt.splitLines():
|
||||
result.add " <tbody>"&row2tr(row)&"</tbody>\n"
|
||||
result.add "</table>"
|
||||
|
||||
echo csv2html(csvtext)
|
||||
Loading…
Add table
Add a link
Reference in a new issue