CSV to HTML translation: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: added some comments |
|||
Line 1,923:
=={{header|Perl 6}}==
I'm not sure why this looks so messy, tried my best with comments, but this very funtional approach seems very unreadable.
<lang Perl 6>
Line 1,930 ⟶ 1,933:
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!¦;
my &escape = *.trans([ <& < \>>] => [<& < >> ]); # a function with one argument that escapes the entities
my &tag = {"<$^t>"~$^s~"</$^t>"}; #
printf #printf statement
'<!DOCTYPE html>
<html>
<head><title>Some Text</title></head>
<body><table>
%s
</table></body></html>
', [~] escape($str).split(/\n/).map(-> $l { # concatenation reduction, escape the string, then split it at \n, then anonymous function
state $first //= 0; # state variable for considering if it is the first line (no ff implemented, yet)
#tag
tag(([~] $l.split(/','/).map({tag($^a, $first++ ?? 'td' !!'th' )})),'tr')});
</lang>
=={{header|PicoLisp}}==
|