Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
item_01 item_02 item_03 item_11 item_12 item_13 item_21 item_22 item_23
hit a key combo, and get:
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
I guess my biggest problem is to figure out how to get it to work with any number of row and column...
Any help much appreciated... Thanks!
On Mar 9, 2007, at 7:17 PM, Yann B wrote:
Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
item_01 item_02 item_03 item_11 item_12 item_13 item_21 item_22 item_23
hit a key combo, and get:
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
I guess my biggest problem is to figure out how to get it to work with any number of row and column...
Any help much appreciated... Thanks!
I would write a command for that. The LaTeX bundle for instance already has one. You might be able to modify it to work with HTML output instead.
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On Mar 9, 2007, at 6:17 PM, Yann B wrote:
Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
Might be easier to learn the (simple) markdown table syntax, write the table in Markdown and then select "Convert Selection to HTML" from the Markdown bundle.
Gerd
Yann B asked:
Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
item_01 item_02 item_03 item_11 item_12 item_13 item_21 item_22 item_23
hit a key combo, and get:
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
OK, I'm feeling sufficiently perverse to write it as a one-long-liner in perl (it's a *Saturday*...). Not elegant, to be sure, but it works OK and might give the "perl as unmaintainable line noise" folk a warm fuzzy feeling.
Cheers, Paul =======================================================================
Make a new command: input as "selected text", output as "replace selected text". The command should be:
#!/usr/bin/perl print "<table>\n\t<tr><td>",join("</td></tr>\n\t<tr><td>",map {chomp;join("</td><td>",(split(/\t/,$_)))} <>),"</td></tr>\n</table>\n";
Hi,
if you want to use a snippet for inserting cell by cell by pressing TAB you can try the attached tmCommand.
The command asks you about dimension of your table. Syntax is '4' for 4x4 or '3 5' for 3x5 or try '4 10 1' (1 := other style).
Best,
Hans
On 10.03.2007, at 07:06, Paul McCann wrote:
Yann B asked:
Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
item_01 item_02 item_03 item_11 item_12 item_13 item_21 item_22 item_23
hit a key combo, and get:
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
OK, I'm feeling sufficiently perverse to write it as a one-long- liner in perl (it's a *Saturday*...). Not elegant, to be sure, but it works OK and might give the "perl as unmaintainable line noise" folk a warm fuzzy feeling.
Cheers, Paul ====================================================================== =
Make a new command: input as "selected text", output as "replace selected text". The command should be:
#!/usr/bin/perl print "<table>\n\t<tr><td>",join("</td></tr>\n\t<tr><td>",map {chomp;join("</td><td>",(split(/\t/,$_)))} <>),"</td></tr>\n</table> \n";
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Hi again,
Please excuse my old eyes: I got excited by all the symmetry I thought I saw in the table, and missed the fact that the first row is special. So one-liner becomes two-liner... ah well... To get the following table output
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
use the previous prescription, but with the command:
#!/usr/bin/perl chomp($first=<>);print "<table>\n\t<tr><th>",join("</th><th>",(split(/ \t/,$first))),"</th></tr>\n\t<tr><td>"; print join("</td></tr>\n\t<tr><td>",map {chomp;join("</td><td>",(split (/\t/,$_)))} <>),"</td></tr>\n</table>\n";
Cheers, Paul