Lively discussions on the graphic arts and publishing — in print or on the web

Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 02-18-2008, 11:53 PM   #2
iamback's Avatar
Join Date: Oct 2005
Location: Amsterdam, NL
Posts: 4,894

Originally Posted by CarlSeiler View Post
I'm surprised I haven't been able to find such an animal. What I'm looking for is something that pretty prints php but will also clean up (X)HTML. While I realize it may be a challenge for the embedded HTML inside the php, I'm thinking it wouldn't be all that difficult for a formatter to clean up HTML that's outside of the php tags.

My problem is that I can't seem to find something that does both.
I think that "pretty printers" may have gone out of fashion, actually.

The idea of course is to create "pretty" code off the bat, and decent text editors will help you these days with auto-indent features (even language-savvy auto-indent), so there's hardly any excuse left (for a human) to not write code that's well-indented. The other cause may be that there are many possible "rules" for indenting code (and software projects may impose theirs), which may not match whatever a pretty printer "thinks" it should be.

The only real problem left is that of code-generated-by-code (any language, not necessarily PHP). It takes real discipline (and a little practice) to write the generating code in such a way that the resulting code (HTML or whatever) is readable and has its own proper indenting.

But "HTML embedded into PHP" is a real problem if you don't write it yourself such that the result will be "correct": there are just too many ways that PHP syntax allows you to generate code (and what it generates can be any code, not just HTML, but also any flavor of XML, PS, RTF, you name it), and a pretty printer cannot "see" what the result should be when it cannot interpret when what would be produced where: that is in the logic of the generating code. It would take a PHP interpreter, not just reading a single file but also includes, even conditional includes, which also detects what language is being generated and knows its syntax and the rules to be applied, to be able to automate how to indent the resulting code.

That is so hard, and, frankly, so useless, no one will likely even try to tackle it. Just write your code so that it produces well-laid-out code.

As an exercise, try this little problem:
Given an array of three elements in PHP, write out all the different ways you can produce a simple unordered list in HTML from that. The <ul> should have a class, and each of the <li> elements should also have a (single) class. How many can you find?

Marjolein Katsma
Look through my eyes on Cultural Surfaces (soon!), My ArtFlakes shop and Flickr.
Occasionally I am also connecting online dots... and sometimes you can follow me on Marjolein's Travel Blog
iamback is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML is Dead. Long live HTML. Five that is... CarlSeiler Web Design 3 07-30-2007 11:04 PM
XLS to HTML dthomsen8 Web Site Building & Maintenance 3 08-07-2006 03:53 PM
If you like HTML even a little... iamback Web Design 0 06-09-2006 12:15 AM
Semantic HTML? ktinkel Web Design 7 08-30-2005 11:50 AM
Help, Pretty Please? Franca Images 13 04-10-2005 03:34 PM

All times are GMT -8. The time now is 04:53 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Contents copyright 2004–2018 Desktop Publishing Forum and its members.