CSV to HTML translation: Difference between revisions

Content deleted Content added
Sonia (talk | contribs)
→‎{{header|Go}}: update for new template library (old one deprecated)
→‎{{header|AutoHotkey}}: AutoHotkey example added
Line 193:
</BODY>
</HTML></lang>
 
=={{header|AutoHotkey}}==
Very basic implementation
<lang AutoHotkey>CSVData =
(
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!
)
TableData := "<table>"
Loop Parse, CSVData,`n
{
TableData .= "`n <tr>"
Loop Parse, A_LoopField, CSV
TableData .= "<td>" HTMLEncode(A_LoopField) "</td>"
TableData .= "</tr>"
}
TableData .= "`n</table>"
HTMLEncode(str){
static rep := "&amp;<lt;>gt;""quot"
Loop Parse, rep,;
StringReplace, str, str, % SubStr(A_LoopField, 1, 1), % "&" . SubStr(A_LoopField, 2) . ";", All
return str
}
MsgBox % clipboard := TableData</lang>
Output:
<pre><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>&amp;lt;angry&amp;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>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></pre>(note the output has been modified slightly since this webpage is html.)
 
=={{header|C}}==