CSV to HTML translation: Difference between revisions

Content added Content deleted
Line 1,627: Line 1,627:


=={{header|Mathematica}}==
=={{header|Mathematica}}==
<lang Mathematica>a = "Character,Speech
<lang Mathematica>a="Character,Speech
The multitude,The messiah! Show us the messiah!
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>
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?
The multitude,Who are you?
Brians mother,I'm his mother;that's who!
Brians mother,I'm his mother;that's who!
The multitude,Behold his mother! Behold his mother!";
The multitude,Behold his mother! Behold his mother!";
(*Naive*)
(*Naive*)
StringJoin["<table>\n",
StringJoin["<table>\n",Map[StringJoin["<tr><td>",#,"</td></tr>\n"]&,
Map[StringJoin["<tr><td>", #, "</td></tr>\n"] &, StringSplit[StringReplace[a, "," -> "</td><td>"], "\n"]],
StringSplit[StringReplace[a,{","->"</td><td>","<"->"&lt;",">"->"&gt;"}],"\n"]]
"</table>"]
,"</table>"]
(*Extra*)
(*Extra*)
StringJoin["<table>\n",
StringJoin["<table>\n",StringJoin["<tr><th>",#,"</th></tr>\n"]&[
StringJoin["<tr><th>", #, "</th></tr>\n"]&[ StringSplit[ StringReplace[a, "," -> "</th><th>"], "\n"] //First],
StringSplit[StringReplace[a,{","->"</td><td>","<"->"&lt;",">"->"&gt;"}],"\n"]//First]
Map[StringJoin["<tr><td>",#,"</td></tr>\n"]&,StringSplit[StringReplace[a, "," -> "</td><td>"], "\n"] //Rest],
,Map[StringJoin["<tr><td>",#,"</td></tr>\n"]&,
StringSplit[StringReplace[a,{","->"</td><td>","<"->"&lt;",">"->"&gt;"}],"\n"]//Rest]
"</table>"]
</lang>
,"</table>"]

Output:
Output:

<pre><table>
<table>
<tr><td>Character</td><td>Speech</td></tr>
<tr><td>Character</td><td>Speech</td></tr>
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</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>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>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>Brians mother</td><td>I'm his mother;that's who!</td></tr>
Line 1,654: Line 1,656:


<table>
<table>
<tr><th>Character</th><th>Speech</th></tr>
<tr><th>Character</td><td>Speech</th></tr>
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</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>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>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>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>
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</table>
</table></lang>
</pre>


=={{header|ML/I}}==
=={{header|ML/I}}==