|
|
|
date: Wed, 24 Oct 2007 19:10:34 +0100,
group: uk.net.web.authoring
back
Stripy tables (Dreamweaver plugin or other tool wanted)
Does anyone know of a Dreamweaver plug-in (or a free-standing app) which
will apply a class to alternate (or every third, or whatever) table
rows, so that, for example:
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
can be changed to, say,
<tr class="odd"><td>1</td></tr>
<tr><td>2</td></tr>
<tr class="odd"><td>3</td></tr>
<tr><td>4</td></tr>
and then
<tr class="odd"><td>1</td></tr>
<tr class="even"><td>2</td></tr>
<tr class="odd"><td>3</td></tr>
<tr class="even"><td>4</td></tr>
or, better, without the intermediate step?
If not, does anyone know a good forum to suggest that someone with the
necessary skills develop one?
--
Andy Mabbett
* Say "NO!" to compulsory ID Cards: <http://www.no2id.net/>
* Free Our Data: <http://www.freeourdata.org.uk>
* Are you using Microformats, yet: <http://microformats.org/> ?
date: Wed, 24 Oct 2007 19:10:34 +0100
author: Andy Mabbett
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Andy Mabbett wrote:
> Does anyone know of a Dreamweaver plug-in (or a free-standing app) which
> will apply a class to alternate (or every third, or whatever) table
> rows, so that, for example:
>
> <tr><td>1</td></tr>
> <tr><td>2</td></tr>
> <tr><td>3</td></tr>
> <tr><td>4</td></tr>
>
> can be changed to, say,
>
> <tr class="odd"><td>1</td></tr>
> <tr><td>2</td></tr>
> <tr class="odd"><td>3</td></tr>
> <tr><td>4</td></tr>
>
> and then
>
> <tr class="odd"><td>1</td></tr>
> <tr class="even"><td>2</td></tr>
> <tr class="odd"><td>3</td></tr>
> <tr class="even"><td>4</td></tr>
>
> or, better, without the intermediate step?
>
> If not, does anyone know a good forum to suggest that someone with the
> necessary skills develop one?
>
One of the best things about Dreamweaver is that it has "Regular
Expressions" (see Help). Took me 5 minutes to get this working
correctly - but I'm rusty!
Start the Find/Replace dialogue (Control-F). At the top, choose:
Find in: "Current Document" (or otherwise, as appropriate)
Search: Source Code.
At the bottom, tick "Use Regular Expressions", and think about whether
"Match Case" is appropriate for the code in front of you.
Then, in the large "Find:" box, type this:
<tr>(.*)</tr>(\s*)<tr>(.*)</tr>
.. and in the "Replace:" box, type this:
<tr class="odd">$1</tr>$2<tr class="even">$3</tr>
Click "Replace All" and the job's done - you may need to adapt the
expression to suit more complex code.
Notes:
1) Anything within parentheses () in the Find string can be retrieved
using $n in the Replace string, with n starting at 1 and incrementing
each time a pair of parentheses is found. I've used three of them here.
2) "." matches any character, and ".*" matches any number (from 0) of
any character.
3) "\s" matches any whitespace character (used here with a "*", and in
parentheses to preserve the layout characters)
4) Regular Expressions are real "Power Tools". If you use them without
making a backup copy first, you WILL one day regret it...
War story: Once came into work and found my Boss had been there for
three hours already trying to edit a flat file of 900,000 BT network
location codes, needed in a different format for another system. After
three hours' work, the progress bar in his editor still showed 0%. My
offer of help was accepted - I threw away his three hours work (tee
hee), wrote a one-line RegEx and had the job done 15m later (took 10m to
process on a fast Unix box). That's power. (B****r never forgave me
for being such a smartass.)
Phil, London
date: Thu, 25 Oct 2007 11:52:35 +0100
author: Philip Herlihy
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Philip Herlihy wrote:
> Andy Mabbett wrote:
>> Does anyone know of a Dreamweaver plug-in (or a free-standing app) which
>> will apply a class to alternate (or every third, or whatever) table
>> rows, so that, for example:
>>
>> <tr><td>1</td></tr>
>> <tr><td>2</td></tr>
>> <tr><td>3</td></tr>
>> <tr><td>4</td></tr>
>>
>> can be changed to, say,
>>
>> <tr class="odd"><td>1</td></tr>
>> <tr><td>2</td></tr>
>> <tr class="odd"><td>3</td></tr>
>> <tr><td>4</td></tr>
>>
>> and then
>>
>> <tr class="odd"><td>1</td></tr>
>> <tr class="even"><td>2</td></tr>
>> <tr class="odd"><td>3</td></tr>
>> <tr class="even"><td>4</td></tr>
>>
>> or, better, without the intermediate step?
>>
>> If not, does anyone know a good forum to suggest that someone with the
>> necessary skills develop one?
>>
>
> One of the best things about Dreamweaver is that it has "Regular
> Expressions" (see Help). Took me 5 minutes to get this working
> correctly - but I'm rusty!
>
> Start the Find/Replace dialogue (Control-F). At the top, choose:
> Find in: "Current Document" (or otherwise, as appropriate)
> Search: Source Code.
>
> At the bottom, tick "Use Regular Expressions", and think about whether
> "Match Case" is appropriate for the code in front of you.
>
> Then, in the large "Find:" box, type this:
> <tr>(.*)</tr>(\s*)<tr>(.*)</tr>
>
> .. and in the "Replace:" box, type this:
> <tr class="odd">$1</tr>$2<tr class="even">$3</tr>
>
> Click "Replace All" and the job's done - you may need to adapt the
> expression to suit more complex code.
>
> Notes:
> 1) Anything within parentheses () in the Find string can be retrieved
> using $n in the Replace string, with n starting at 1 and incrementing
> each time a pair of parentheses is found. I've used three of them here.
>
> 2) "." matches any character, and ".*" matches any number (from 0) of
> any character.
>
> 3) "\s" matches any whitespace character (used here with a "*", and in
> parentheses to preserve the layout characters)
>
> 4) Regular Expressions are real "Power Tools". If you use them without
> making a backup copy first, you WILL one day regret it...
>
> War story: Once came into work and found my Boss had been there for
> three hours already trying to edit a flat file of 900,000 BT network
> location codes, needed in a different format for another system. After
> three hours' work, the progress bar in his editor still showed 0%. My
> offer of help was accepted - I threw away his three hours work (tee
> hee), wrote a one-line RegEx and had the job done 15m later (took 10m to
> process on a fast Unix box). That's power. (B****r never forgave me
> for being such a smartass.)
>
> Phil, London
Afterthought - you do occasionally get die-hards here declaring that
anyone who uses anything other than Notepad to create webpages is some
sort of cissy. Try that in Notepad...
Phil
date: Thu, 25 Oct 2007 12:06:02 +0100
author: Philip Herlihy
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
On Thu, 25 Oct 2007 12:06:02 +0100, Philip Herlihy
wrote:
>Afterthought - you do occasionally get die-hards here declaring that
>anyone who uses anything other than Notepad to create webpages is some
>sort of cissy.
No, good text editors, not Notepad.
We do it because it's _faster_ than DW.
(I'd suggest Eclipse or jEdit for starters)
date: Thu, 25 Oct 2007 22:08:10 +0100
author: Andy Dingley
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Message-ID: from Andy
Dingley contained the following:
>>Afterthought - you do occasionally get die-hards here declaring that
>>anyone who uses anything other than Notepad to create webpages is some
>>sort of cissy.
>
>No, good text editors, not Notepad.
Indeed and it wouldn't be much help to me since most of my tables are
generated from external data. Hence a one liner like
$style=($count%2==1)?" style='background-color:#CC99CC'":"";
is usually all that's needed to create stripes.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
date: Fri, 26 Oct 2007 11:25:48 +0100
author: Geoff Berrow
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Geoff Berrow wrote:
> Message-ID: from Andy
> Dingley contained the following:
>
>>> Afterthought - you do occasionally get die-hards here declaring that
>>> anyone who uses anything other than Notepad to create webpages is some
>>> sort of cissy.
>> No, good text editors, not Notepad.
>
> Indeed and it wouldn't be much help to me since most of my tables are
> generated from external data. Hence a one liner like
>
> $style=($count%2==1)?" style='background-color:#CC99CC'":"";
>
> is usually all that's needed to create stripes.
>
That's a very different task from the OP's problem - you're writing
(neat!) server-side scripts which generate HTML; the OP has existing
page(s) of HTML which he wants to edit with "help" from some utility.
He's already using Dreamweaver - it has a lot of handy tools built-in,
and Regular Expressions are one of them.
I wouldn't disagree that there are plenty of good and useful text
editors out there (I tend to fall back on Vi for some tasks!) and I
certainly wouldn't argue with anyone who preferred to use one of those
instead of Dreamweaver. I happen to like Dreamweaver, which is
essentially a text editor with a lot of "conveniences" built in - like
templates, an FTP client, etc, etc - which I'm happy to take advantage
of. They save me time, and Dreamweaver, unlike some tools, doesn't
create a barrier to the underlying code, and it isn't confused when you
hack it directly. Similarly some people will use a decent text editor
to write program code, while others prefer an integrated environment
like Visual Studio (I can't do without a debugger). Tools can save time
and solve problems, but some do distance you from the end product.
There are still people who pore over and grumble at the assembler code
produced by their compilers - it's an extreme version of the same argument.
I guess what provoked my comment was posts I've seen here and elsewhere
advising beginners to stick to Notepad. Fine if you're consciously
setting out to learn HTML and CSS in a particularly austere way (I think
you'd learn much faster from working in Dreamweaver's "split" view, and
using the CSS tools provided) but most people asking at this level just
want to get the Tennis Club dance details up on the web. They'd learn
more of relevance to them from starting with a crude tool matched to the
job, and for people who will never be interested in the code they
produce, saving a document as HTML from Word or Publisher will meet
their needs. We may shudder at the raw code, but why would you and I be
looking at that code in the first place? I don't ride a tricycle
anymore, but there was a time it suited me!
I've broken one of my own rules in this thread - while it's ok to
disagree on issues and ideas, it's best not to criticise people, even a
vague "them" (like the Notepad advocates). It usually polarises opinion
rapidly and doesn't achieve anything. I shouldn't have brought it up.
Phil
date: Fri, 26 Oct 2007 15:20:54 +0100
author: Philip Herlihy
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
On 26 Oct, 11:25, Geoff Berrow wrote:
> $style=($count%2==1)?" style='background-color:#CC99CC'":"";
How about doing it right instead and using a class rather than an
inlined style?
I'm up to my neck in pages like this, with inlined CSS all over the
place. If you do it badly enough, then you really can bloat them to
the point where their load times are compromised.
date: Fri, 26 Oct 2007 09:17:33 -0700
author: Andy Dingley
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Message-ID: from
Andy Dingley contained the following:
>> $style=($count%2==1)?" style='background-color:#CC99CC'":"";
>How about doing it right instead and using a class rather than an
>inlined style?
It would be better, that's true but often I work with 'designers' whose
style sheets leave a lot to be desired. In these cases I prefer to
leave their style sheets alone and style inline to avoid any possible
conflicts.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
date: Sat, 27 Oct 2007 10:11:07 +0100
author: Geoff Berrow
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Geoff Berrow wrote:
> Message-ID: from
> Andy Dingley contained the following:
>
>>> $style=($count%2==1)?" style='background-color:#CC99CC'":"";
>> How about doing it right instead and using a class rather than an
>> inlined style?
>
> It would be better, that's true but often I work with 'designers' whose
> style sheets leave a lot to be desired. In these cases I prefer to
> leave their style sheets alone and style inline to avoid any possible
> conflicts.
>
Geoff, what _does_ your signature mean?
Phil
date: Sat, 27 Oct 2007 11:16:38 +0100
author: Philip Herlihy
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Message-ID: <ffv35r$6a0$1$8300dec7@news.demon.co.uk> from Philip Herlihy
contained the following:
>> It would be better, that's true but often I work with 'designers' whose
>> style sheets leave a lot to be desired. In these cases I prefer to
>> leave their style sheets alone and style inline to avoid any possible
>> conflicts.
>>
>
>Geoff, what _does_ your signature mean?
http://www.roubaixinteractive.com/PlayGround/Binary_Conversion/Binary_To_Text.asp
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
date: Sun, 28 Oct 2007 10:57:56 +0000
author: Geoff Berrow
|
Re: Stripy tables (Dreamweaver plugin or other tool wanted)
Geoff Berrow wrote:
> Message-ID: <ffv35r$6a0$1$8300dec7@news.demon.co.uk> from Philip Herlihy
> contained the following:
>
>>> It would be better, that's true but often I work with 'designers' whose
>>> style sheets leave a lot to be desired. In these cases I prefer to
>>> leave their style sheets alone and style inline to avoid any possible
>>> conflicts.
>>>
>> Geoff, what _does_ your signature mean?
>
> http://www.roubaixinteractive.com/PlayGround/Binary_Conversion/Binary_To_Text.asp
>
:-)
date: Sun, 28 Oct 2007 23:56:14 +0000
author: Philip Herlihy
|
|
|