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) :
$<
def addline(line):
return "<tr\>%s</tr\>\n" % line
def addcolumn(item,nb_columns):
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\>"
return output>
________________________________
From: Kurt Hansen <kurt@ugyldig.invalid>
To: python-list@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.
>
> $<
[cut]
> 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:
http://www.danacord.dk/frmsets/records/732-r.html
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 ... ;-)
-- Regards
Kurt Hansen
-- http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list