CSV to HTML translation: Difference between revisions
→{{header|J}}: tidy up
m (→{{header|J}}: display output using lang html) |
(→{{header|J}}: tidy up) |
||
Line 118:
<lang j>require 'strings tables/csv'
encodeHTML=: ('&';'&';'<';'<';'>';'>')&stringreplace
cell=: ('<td>' , ,&'</td>')&.>
row=: <@('<tr>' , ,&('</tr>',LF))@;"1
table=: (('<table>',LF) , ,&('</table>'))@;"1
makeHTMLtablefromCSV=
'''Example'''
<lang j> csvstrng=: noun define
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!
)
HTML output:
▲<lang html> makeHTMLtablefromCSV csvstrng
<lang html><table>
<tr><td>
<tr><td>
<tr><td>
<tr><td>
<tr><td>
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</table></lang>
|