Re: Cleaning up HTML table structure
| From: | Jens Lehmann | Date: | Mon, 10 Mar 2003 15:51:36 +0000 |
| Subject: | Re: Cleaning up HTML table structure | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138966@lists.php.net to get a copy of this message | ||
Beau Hartshorne wrote:
Jens, I would suggest that you try writing a script that keeps track of how many tags have been opened (look for "<"), versus how many tags have been closed ("[^>]*/>") on a line-by-line basis. Using that number, you should be able to indent the code properly.I need to count how often the important tags (table, tr, td) have been opened, but that's only a part of the solution. It doesn't make sense to count every < and > because most of the tags don't play a role (in the script I should write).
Let us know what you've got so far.I solved the problem by first getting all position of the table, tr and td-tags. After that I go serially from the first to the last occurence of a tag and keep track how often it was opened and closed. Additionally I have a variable which counts the numbers of bytes I added to the text. After that I reduce the linelength to less than $maxlength chars. Jens PS: If you want a tool which really cleans up HTML you should use HTMLTidy of course. :)