June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,31 @@
|
|||
USING: combinators csv io kernel sequences strings ;
|
||||
IN: rosetta-code.csv-to-html
|
||||
|
||||
CONSTANT: input
|
||||
|
||||
"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!"
|
||||
|
||||
: escape-chars ( seq -- seq' )
|
||||
[
|
||||
{
|
||||
{ CHAR: & [ "&" ] }
|
||||
{ CHAR: ' [ "'" ] }
|
||||
{ CHAR: < [ "<" ] }
|
||||
{ CHAR: > [ ">" ] }
|
||||
[ 1string ]
|
||||
} case
|
||||
] { } map-as concat ;
|
||||
|
||||
: tag ( str tag -- <tag>str</tag> )
|
||||
[ "<" ">" surround ] [ "</" ">" surround ] bi surround ;
|
||||
|
||||
: csv>table ( seq -- str )
|
||||
[ [ "td" tag ] map concat "tr" tag " " prepend ] map
|
||||
{ "<table>" } prepend { "</table>" } append "\n" join ;
|
||||
|
||||
input escape-chars string>csv csv>table print
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<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><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue