<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Indeed, the console shows a traceback where data is misinterpreted, maybe due to my triple protective quotes around $GEDIT_SELECTED_TEXT. Try without them, like so (it worked for me) : <br><br>$<<br>def addline(line):<br> return "<tr\>%s</tr\>\n" % line<br><br>def addcolumn(item,nb_columns):<br> if nb_columns != 3:<br> return "<td colspan='%s'\>%s</td\>" % (3 - nb_columns + 1, item)<br> return "<td\>%s</td\>" % item<br><br>output = "<table\>\n"<br>selected_text = $GEDIT_SELECTED_TEXT<br>for line in selected_text.split("\n"):<br> items = line.strip().split("\t")<br> columns = ""<br> for item in items
:<br> columns += addcolumn(item,len(items))<br> output += addline(columns)<br><br>output += "</table\>"<br>return output><br><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Kurt Hansen <kurt@ugyldig.invalid><br> <b><span style="font-weight: bold;">To:</span></b> python-list@python.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, January 9, 2013 12:04 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: How to modify this script?<br> </font> </div> <br>
Den 09/01/13 11.23, chaouche yacine skrev:<br>> I figrued it out. Copy/paste exactly these lines in the snippets tool.<br>> You can bind it to a key as you may know, I bound it to Ctrl-E. So paste<br>> it in a new snippet (keep the original in a safe place), bind to a key,<br>> select the text you want to html-tableize and hit the key binding. In my<br>> case it worked.<br>> <br>> $<<br>[cut]<br>> def addline(line):<br><br>Spooky behavior. Yes, the green-apple-example also works for me with your new script, BUT ...!<br><br>Try to copy the table content on this page:<br>http://www.danacord.dk/frmsets/records/732-r.html<br>which is a realistic scenario. That's whar I am doing these days.<br><br>Pasting it into Gedit and running the snippet blanks the edit area (on MY Mac at least).<br><br>And yes: I have pasted your code excatly and I've double-checked for linewraps. Everything is okay.<br><br>For your cenvenience I have put
borders on the table online (see link above). You may ommit the rows after track 14. Not that it makes any differerence, but that block is surposed to be formatted differerent. I do that manually afterwards ... if not ... ;-)<br>-- Regards<br>Kurt Hansen<br>-- http://mail.python.org/mailman/listinfo/python-list<br><br><br> </div> </div> </div></body></html>