CSV to HTML translation: Difference between revisions

m
→‎{{header|Perl 6}}: output added (and added newlines for nicer output)
m (→‎{{header|Perl 6}}: output added (and added newlines for nicer output))
Line 1,923:
 
=={{header|Perl 6}}==
{{output?|Perl 6}}
 
A very lispy solution:
<lang Perl 6>
my $str = Q¦Character,Speech
Line 1,953:
# that / at the end is just an unspace, you can omit it, but then you have to delete
# all whitespace and comments between split(…) and .map
.map({tag 'td', $^cell})) });\ # map those cells as td
.join("\n"); # append a newline for nicer output;
</lang>
Output:
<lang html>
<!DOCTYPE html>
<html>
<head><title>Some Text</title></head>
<body><table>
<tr><td>Character</td><td>Speech</td></tr>
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr>
<tr><td>Brians mother</td><td>&lt;angry&gt;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!&lt;/angry&gt;</td></tr>
<tr><td>The multitude</td><td>Who are you?</td></tr>
<tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr>
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</table></body></html>
 
</lang>
 
38

edits