RosettaCodeData/Task/CSV-to-HTML-translation/Maple/csv-to-html-translation.maple

29 lines
852 B
Plaintext

#A translation of the C code posted
html_table := proc(str)
local char;
printf("<table>\n<tr><td>");
for char in str do
if char = "\n" then
printf("</td></tr>\n<tr><td>")
elif char = "," then
printf("</td><td>")
elif char = "<" then
printf("&lt;")
elif char = ">" then
printf("&gt;")
elif char = "&" then
printf("&amp;")
else
printf(char)
end if;
end do;
printf("</td></tr>\n</table>");
end proc;
html_table("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!");