javascript - Turn several strings of structured text into HTML table -
for example have following text no tags @ within html page: color: red shape: square side: 1mm as rows needed, 3 quite enough question. 1 be. in rows i'll have the beginning of text string , colon+space (: ) , the end of text string . how should turn the beginning of text string <tr><td> , colon+space :</td><td> , the end of text string </td></tr> ? thanks @andrew willems (the script) , @phil (further suggestions) , running. the original text here has unnecessary lines before , after text demonstrate need dealing with, , ability deal with, lines. var opening = '<table id="newborn_table"><tbody>'; var closing = '</tbody></table>'; var origtext = document.queryselector('#source').innertext; var lines = origtext.split('\n').filter(function(line) { return (line !== ""); }); var rowstext = ''; lines.foreach(function(line) { ...