开发者

Why do I get incorrect line breaks in my source code?

I'm encountering a weird problem with how a php file's code (read: source code) is rendered in some browser's source code view (I've tested Firefox 4, Chrome 10, IE9).

So basically I use Wordpress to show a category, hence using the category.php. The process then would be to copy the output source code into a new .html file and use that as an email newsletter. This has worked wonderfully the last 10 instances, but this time the browser (as stated above, basically any browser) messes with the source code as in omitting line breaks (not <br />s, but 'new lines' in the code itself, inserting line breaks at other points (for example right between an object and its attribute), and in doing so messes the whole code up. The page still renders okay, but as I need the source code this is a bit of a problem for me.

Examples

Original code in .php file:

<table width="758" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF">
    <tr height="256">
        <td colspan="27" height="256">
            <a href="http://www.motoscoot.es/shop/" target="_blank" style="border:none;text-decoration:none;">
                <img src="https://www.motoscoot.es/img/newsletter/MsNewsletter_top4.gif" alt="Motoscoot.es Novedades" width="758" height="256" longdesc="Motoscoot.es Novedades" border="0" style="border:none;">
            </a>
        </td>



<!-- ...and so on -->

Processed Source Code:

<table
width="758" border="0" cellpadding="0" cellspacing="0" align="center"
bgcolor="#FFFFFF"><tr
height="256"><td
colspan="27" height="256"> <a
href="http://www.motoscoot.es/shop/" target="_blank" style="border:none;text-decoration:none;"><img
src="https://www.motoscoot.es/img/newsletter/MsNewsletter_top4.gif" alt="Motoscoot.es Novedades" width="758" height="256" longdesc="Motoscoot.es Novedades" border="0"
style="border:none;"></a></td></tr><tr
id="main_content_row"><td


<!-- ...and so on -->

I can't give you an online link right now as this is all still happening on localhost.

So with the smooshed output code I can of course create the html site, because as I said before, the rendering still works fine. But to really be able to work with it, that's just plain impossible. At fir开发者_如何学Gost I thought it might be an editor error. I usually work with Dreamweaver, so I tried editing and saving the .php in UltraEdit and in Notepad++, both yielding the same result though.

How do I solve this mess?


Run the HTML through HTML Tidy before you try to edit it. You can also download your own copy if you want to run it from a batch script or something like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜