How to modify this script?

G

Gertjan Klein

Thomas said:
Am 07.01.2013 18:56 schrieb Gertjan Klein:


Do "insert as quotation" (in German Thunderbird: "Als Zitat einfügen"),
or Strg-Shift-O. Then it gets inserted with a ">" before and in blue.

Just remove the > and the space after it; the "non-breaking property" is
kept.

Ah, I didn't think of that, thanks. Laborious but manageable. But:

Both your examples are wrapped, in the same way. (I checked the message
source, it's not some setting on my end.) It appears that, although
Thunderbirds editor remembers the "don't wrap" setting, wrapping still
occurs before sending. (The wrapping-before-sending code uses a slightly
different algorithm than the editor too, so messages often look
different after sending. Thunderbirds editor is really bad.)

A last attempt: two (equal) quotes, the second one with the leading "> "
removed:
output += ('<td colspan=%s\>' % max_columns) + line + '</td\></tr\>\n'

output += ('<td colspan=%s\>' % max_columns) + line +
'</td\></tr\>\n'

I'm curious how this will come out.

Regards,
Gertjan.
 
K

Kurt Hansen

Den 08/01/13 16.31, chaouche yacine skrev:
Well tell me how do you use this script in gedit, are you using it as a
plugin ?

"Snippets" is a plugin, yes. It's included in the .app for Mac (v.
2.30.2), but not activated af default.

Open "Tools" in the menu line and click "Manage snippets...". Here you
can organize, add and edit snippets of texts. The feature olså has the
ability to work with Python code inside the snippet content.

I am re-building a 15 years old homepage. The HTML code is handmade over
the years and very varying, buggy etc., så I would like to renew the
HTML for the table structure in an easy way.

Example: On this page: http://www.danacord.dk/frmsets/records/732-r.html
I mark the content of the CD, copy it to the clipboard and paste it into
the editing area in Gedit. cmd-a marks it all again and then I "run" the
snippet upon the text, either using my self-defined hotkey or by pushing
ctrl+space and select my snippet from a list.

The copied text is inserted as clean text without any HTML. The
Python-snippet we are discussing recognizes tabs to separate the columns
and adds the apprpriate HTML-code to it.
 
K

Kurt Hansen

Am 06.01.2013 15:30 schrieb Kurt Hansen:

That would be simple:

Replace

output += '<td colspan="' + str(4-len(columns)) + '"\>' + item +
'</td\> '

with

if len(columns) >= 3:
output += '<td\>'
else:
output += '<td colspan="' + str(4-len(columns)) + '"\>'
output += item + '</td\> '

(untested as well; keep the indentation in mind!)

Thanks, Thomas, but ...

The script stops right bofore
= 3:
output += '<td\>'

This, and the rest of the script code is put out as the result, not my test.
 
K

Kurt Hansen

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 ... ;-)
 
K

Kurt Hansen

Kurt said:
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.

Chaouche replied:
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) :

Yes!!! :)

Of course it would be nice if the script could be developed to take into
account some of the antics I have made in my tables over the years, but
with this script the basic codes of rows and columns is formatted
properly; refinements of some collapsed fields with with line breaks
a.o. is up to me now ;-).

Thanks to you and others who have participated in this thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top