How to modify this script?
yacinechaouche at yahoo.com
Wed Jan 9 19:25:45 CET 2013
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) :
return "<tr\>%s</tr\>\n" % line
if nb_columns != 3:
return "<td colspan='%s'\>%s</td\>" % (3 - nb_columns + 1, item)
return "<td\>%s</td\>" % item
output = "<table\>\n"
selected_text = $GEDIT_SELECTED_TEXT
for line in selected_text.split("\n"):
items = line.strip().split("\t")
columns = ""
for item in items :
columns += addcolumn(item,len(items))
output += addline(columns)
output += "</table\>"
From: Kurt Hansen <kurt at ugyldig.invalid>
To: python-list at python.org
Sent: Wednesday, January 9, 2013 12:04 PM
Subject: Re: How to modify this script?
Den 09/01/13 11.23, chaouche yacine skrev:
> I figrued it out. Copy/paste exactly these lines in the snippets tool.
> You can bind it to a key as you may know, I bound it to Ctrl-E. So paste
> it in a new snippet (keep the original in a safe place), bind to a key,
> select the text you want to html-tableize and hit the key binding. In my
> case it worked.
> def addline(line):
Spooky behavior. Yes, the green-apple-example also works for me with your new script, BUT ...!
Try to copy the table content on this page:
which is a realistic scenario. That's whar I am doing these days.
Pasting it into Gedit and running the snippet blanks the edit area (on MY Mac at least).
And yes: I have pasted your code excatly and I've double-checked for linewraps. Everything is okay.
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 ... ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list