Page 1 of 1

How to clean up messy table code

Posted: Thu Oct 25, 2007 6:06 pm
by TJINAK
Thank you for reading,

I'm working on moving a site into cmsms.  This old site has lots of tables with messy code.  Here is an example:

Code: Select all

<tr>
            <td valign="top" width="60">
            <div align="left"><font size="4"><strong>0.52</strong></font></div>
            </td>
            <td valign="top" width="360">
            <div align="left"><font size="4"><strong>Building lot on Ninilchik Drive.</strong></font></div>
            </td>
            <td valign="top" width="72">
            <div align="left"><font size="4"><strong>$7,000</strong></font></div>
            </td>
            <td valign="top" width="120">
            <div align="left"><strong><a href=""><span><font size="4">07-15674</font></span></a></strong></div>
            </td>
        </tr>
I'm going to do the formating with CSS so I need nice clean code like this:

Code: Select all

 <tr>
            <td>0.42</td>
            <td>Res. Building lot on Alaik Drive.</td>
            <td>$30,000</td>
            <td><a href="">SOLD</td>
        </tr>
I'm currently deleting the messy code by hand, very time consuming anyone have suggestions on how I can do this in a more productive manner, without having to retype the data in each row?

Thank you,
TJ

Re: How to clean up messy table code

Posted: Fri Oct 26, 2007 4:14 am
by Jack @ PharSide
Try a "search and replace" within Dreamweaver, TextPad or Notepad. Since all TD are the same (with a few sizes differences), simply search and replace each table data tag with individual sizes.

Like this:

Search for:
Replace with:

Obviously do this for each TD tag that is different. You can also do the end of a TD tag as well.

If you wanted to get rid of the text formatting as well:


Search for:
Replace with:

Re: How to clean up messy table code

Posted: Fri Oct 26, 2007 12:12 pm
by Pierre M.
May be tidy or a similar tool can help you.
Pierre M.

Re: How to clean up messy table code

Posted: Fri Oct 26, 2007 6:17 pm
by TJINAK
Is it possible to integrate tidy with cmsms?

Re: How to clean up messy table code

Posted: Sat Oct 27, 2007 2:31 pm
by Pierre M.
I think what you are looking for is cleaning existing material before you put it inside CMSms (as Jack as suggested too). There is mod_tidy to integrate tidy with Apache v2. wget cleaned material then put it in standard CMSms.

Pierre M.