Page 1 of 1
A html formatting script
Posted: Thu Nov 25, 2004 9:54 pm
by Todd_Z
I'm looking for a script that when I feed it a file, it reads through the html and source formats it.... Anyone seen one of these? Thanks.
Posted: Thu Nov 25, 2004 10:00 pm
by John Cartwright
describe: "formats it"
http://www.domain.com?page=htmlsource.html
Code: Select all
<?php
$page = file_get_contents($_GET['page']);
echo $page;
?>
Note: You will want to validate where the file is coming from first else users would be able to run harmful errors.
Posted: Thu Nov 25, 2004 10:23 pm
by Todd_Z
For example, it would turn
<table><tr>
<td><B></b>random text</td></tr>
</table>
to =>
<table>
<tr>
<td>Random text</td>
</tr>
</table>
With the right spacing, which i can't do here...
Posted: Thu Nov 25, 2004 10:30 pm
by josh
Phenom wrote:describe: "formats it"
I think he means "clean up the code" like indent and put tags on their own lines like
Code: Select all
<table><tr><td>stuff</td></tr></table>
would format to
Code: Select all
<table>
<tr>
<td>stuff</td>
</tr>
</table>
Posted: Thu Nov 25, 2004 11:13 pm
by jl
Posted: Thu Nov 25, 2004 11:57 pm
by Todd_Z
Hmmm.... well that seems to be a program, im looking for a script at runtime... like a php script in itself that i can have read the url given and format it.
Posted: Fri Nov 26, 2004 12:36 am
by timvw
http://www.php.net/tidy no need to spawn a differenct process
Posted: Fri Nov 26, 2004 10:42 am
by Todd_Z
It looks like that has no spacing, i'm really looking for a script, not built in functions so that i can tweak it to make the style how i want it to be...
Posted: Fri Nov 26, 2004 4:52 pm
by Steveo31
Bunch on google... "html code beautifier" will bring back a bunch. Most you gotta pay for, if not all.
Posted: Fri Nov 26, 2004 6:01 pm
by Todd_Z
Im looking for a runtime script, those all look like programs...
Posted: Fri Nov 26, 2004 6:14 pm
by rehfeld
have you tried hotscripts.com ?
Posted: Fri Nov 26, 2004 7:50 pm
by timvw
tidy can clean up... and make it valid xhtml.. which is xml... thus you can write an xslt that transforms it to whatever you like..