Re: How to modify this script?

2013-01-10 Thread Kurt Hansen
Kurt wrote: 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

Re: How to modify this script?

2013-01-09 Thread 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

Re: How to modify this script?

2013-01-09 Thread Kurt Hansen
Den 06/01/13 15.20, Chris Angelico wrote: That version should work. Am 06.01.2013 15:30 schrieb Kurt Hansen: It certainly does. I'll keep it and use it until at better solution is found. On 08/01/13 15.18, Thomas Rachel wrote: That would be simple: Replace output += 'td colspan=' +

Re: How to modify this script?

2013-01-09 Thread chaouche yacine
what was wrong in the snippet. If this doesn't work for you, please let me know. From: Kurt Hansen kurt@ugyldig.invalid To: python-list@python.org Sent: Wednesday, January 9, 2013 10:07 AM Subject: Re: How to modify this script? Den 08/01/13 16.31, chaouche

Re: How to modify this script?

2013-01-09 Thread 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

Re: How to modify this script?

2013-01-09 Thread chaouche yacine
(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

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
Am 06.01.2013 15:30 schrieb Kurt Hansen: Den 06/01/13 15.20, Chris Angelico wrote: On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen kurt@ugyldig.invalid wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the marked, tab-separated text in the

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
Am 07.01.2013 18:56 schrieb Gertjan Klein: (Watch out for line wraps! I don't know how to stop Thunderbird from inserting them.) 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

Re: How to modify this script?

2013-01-08 Thread chaouche yacine
Sent: Monday, January 7, 2013 5:42 PM Subject: Re: How to modify this script? Den 06/01/13 16.12, chaouche yacine skrev: I'm not confident this would run on gedit. It works on a python interpreter if you have a file named data.txt in the same directory containing your sample data. It surely

Re: How to modify this script?

2013-01-08 Thread Gertjan Klein
Thomas Rachel wrote: Am 07.01.2013 18:56 schrieb Gertjan Klein: (Watch out for line wraps! I don't know how to stop Thunderbird from inserting them.) 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

Re: How to modify this script?

2013-01-07 Thread Kurt Hansen
. *From:* Kurt Hansen kurt@ugyldig.invalid *To:* python-list@python.org *Sent:* Sunday, January 6, 2013 3:21 PM *Subject:* Re: How to modify this script? Den 06/01/13 15.01, chaouche yacine wrote: Well, I'm not answering your question since I am rewriting

Re: How to modify this script?

2013-01-07 Thread Gertjan Klein
Kurt Hansen wrote: To convert tab-separated text lines into a HTML-table: As you apparently didn't receive answers that worked for you I tried to get what you want to work and test it in Gedit. Here's the result: $ lines = $GEDIT_SELECTED_TEXT.split(\n); output = 'table\\n'; max_columns =

Re: How to modify this script?

2013-01-06 Thread Chris Angelico
On Sun, Jan 6, 2013 at 11:42 PM, Kurt Hansen kurt@ugyldig.invalid wrote: Since there's only one field in the first line, I want this output: trtd colspan=3Price table/td/tr - insted of trtdPrice table/td/tr How to? Thank you i advance. It's actually quite simple, as long as you don't

Re: How to modify this script?

2013-01-06 Thread chaouche yacine
if len(columns) != 3:    colspan = 3 - len(columns) + 1    output += 'td colspan=%s' % (colspan) + item + '/td ' I did not test. Use with caution. From: Kurt Hansen kurt@ugyldig.invalid To: python-list@python.org Sent: Sunday, January 6, 2013 1:42 PM

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 13.52, Chris Angelico skrev: On Sun, Jan 6, 2013 at 11:42 PM, Kurt Hansen kurt@ugyldig.invalid wrote: Since there's only one field in the first line, I want this output: trtd colspan=3Price table/td/tr - insted of trtdPrice table/td/tr How to? Thank you i advance. It's

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 13.58, chaouche yacine skrev: if len(columns) != 3: colspan = 3 - len(columns) + 1 output += 'td colspan=%s' % (colspan) + item + '/td ' I did not test. Use with caution. I've tried to put it in several different places in the script, but with no luck; remember that I'm

Re: How to modify this script?

2013-01-06 Thread Chris Angelico
On Mon, Jan 7, 2013 at 12:34 AM, Kurt Hansen kurt@ugyldig.invalid wrote: innermost? I have replaced this with yours, but all the marked text are deleted: Here's the full code, with my change: $ lines = $GEDIT_SELECTED_TEXT.split(\n); output = 'table\\n'; for line in lines: output +=

Re: How to modify this script?

2013-01-06 Thread chaouche yacine
Green apple /tdtd $1/td/tr trtd5 /tdtd Green apples /tdtd $4/td/tr trtd10 /tdtd Green apples /tdtd $7/td/tr /table From: Kurt Hansen kurt@ugyldig.invalid To: python-list@python.org Sent: Sunday, January 6, 2013 2:38 PM Subject: Re: How to modify this script

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 14.44, Chris Angelico wrote: On Mon, Jan 7, 2013 at 12:34 AM, Kurt Hansen kurt@ugyldig.invalid wrote: innermost? I have replaced this with yours, but all the marked text are deleted: Here's the full code, with my change: $ lines = $GEDIT_SELECTED_TEXT.split(\n); output =

Re: How to modify this script?

2013-01-06 Thread Chris Angelico
On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen kurt@ugyldig.invalid wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the marked, tab-separated text in the editor. Ah, whoops. That would be because I had a bug in the code (that's why I

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 15.01, chaouche yacine wrote: Well, I'm not answering your question since I am rewriting the script, because I prefer it this way :) def addline(line): return tr%s/tr\n % line [cut] I surpose I shall put your code between $ and ? printed table trtd colspan='3'Price

Re: How to modify this script?

2013-01-06 Thread Subimal Deb
Kurt, Try this: $ lines = $GEDIT_SELECTED_TEXT.split(\n); output = 'table\\n'; for line in lines: output += 'tr\'; columns = line.split(\t); if len(columns)==1: output += 'tr\td colspan=3\', line, '/td\/tr\' else: for item

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 15.20, Chris Angelico wrote: On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen kurt@ugyldig.invalid wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the marked, tab-separated text in the editor. Ah, whoops. That would be

Re: How to modify this script?

2013-01-06 Thread Chris Angelico
On Mon, Jan 7, 2013 at 1:30 AM, Kurt Hansen kurt@ugyldig.invalid wrote: Den 06/01/13 15.20, Chris Angelico wrote: On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen kurt@ugyldig.invalid wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 15.22, Subimal Deb wrote: Kurt, Try this: [cut] I've tested it on my original example: Price table 1 Green apple $1 5 Green apples$4 10 Green apples$7 With all four lines selected it makes an error. With only three (without the first line) it works

Re: How to modify this script?

2013-01-06 Thread Chris Angelico
On Mon, Jan 7, 2013 at 1:40 AM, Kurt Hansen kurt@ugyldig.invalid wrote: failed: cannot concatenate 'str' and 'tuple' objects The problem is this line: output += 'trtd colspan=3', line, '/td/tr' Change it to: output += 'trtd colspan=3' + line + '/td/tr' ChrisA --

Re: How to modify this script?

2013-01-06 Thread Kurt Hansen
Den 06/01/13 15.52, Chris Angelico skrev: On Mon, Jan 7, 2013 at 1:40 AM, Kurt Hansen kurt@ugyldig.invalid wrote: failed: cannot concatenate 'str' and 'tuple' objects The problem is this line: output += 'trtd colspan=3', line, '/td/tr' Change it to: output += 'trtd colspan=3' + line +

Re: How to modify this script?

2013-01-06 Thread chaouche yacine
: Re: How to modify this script? Den 06/01/13 15.01, chaouche yacine wrote: Well, I'm not answering your question since I am rewriting the script, because I prefer it this way :) def addline(line):       return tr%s/tr\n % line [cut] I surpose I shall put your code between $ and ? printed