CSV to HTML translation: Difference between revisions

m
→‎{{header|Perl 6}}: delete spurious newlines, unfool the highlighter
(thead vs CSS (thanks User:Patrick))
m (→‎{{header|Perl 6}}: delete spurious newlines, unfool the highlighter)
Line 1,925:
 
A very lispy solution:
<lang perl6>my $str = "Character,Speech
<lang Perl 6>
my $str = Q¦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!¦";
 
# comment the next line out, if you want to read from standard input instead of the hard-coded $str above
Line 1,938 ⟶ 1,937:
my &escape = *.trans([ <& < \>>] => [<&amp; &lt; &gt;> ]); # a function with one argument that escapes the entities
my &tag = {"<$^tag>"~$^what~"</$^tag>"};
 
 
printf
Line 1,954 ⟶ 1,952:
# 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>
 
</lang>
Output:
<lang html><!DOCTYPE html>
<!DOCTYPE html>
<html>
<head><title>Some Text</title></head>
Line 1,969 ⟶ 1,965:
<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>
 
</lang>
 
=={{header|PicoLisp}}==
Anonymous user