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

29 lines
858 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
#A translation of the C code posted
html_table := proc(str)
2026-02-01 16:33:20 -08:00
local char;
2023-07-01 11:58:00 -04:00
printf("<table>\n<tr><td>");
for char in str do
if char = "\n" then
2026-02-01 16:33:20 -08:00
printf("</td></tr>\n<tr><td>")
2023-07-01 11:58:00 -04:00
elif char = "," then
printf("</td><td>")
elif char = "<" then
printf("&lt;")
elif char = ">" then
printf("&gt;")
elif char = "&" then
2026-02-01 16:33:20 -08:00
printf("&amp;")
2023-07-01 11:58:00 -04:00
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!");