Jump to content

source code formatting


thescientist

Recommended Posts

Hey, just had a question for the community. I take a good deal of pride in writing my code, as novice as I am, because I like how well formatted, indented, code looks, and makes things easier to read and follow. In my text editor (TextWrangler for OSX) I have my indents set for two spaces, and I can achieve the look I like no problem. However, I've been doing some PHP work on my soon to be site redesign and I was interested to see how the source code looks, and lo and behold, most of nice formatting was not there. The first few lines looked ok, but even for non-PHP generated source code, some of indents where way off, i.e. to far to the right, some line breaks where in the wrong place. Nothing terrible, but it would certainly give the impression of looking somewhat amateurish, and if I was asking the great mind of the W3Schools community to give me feedback of my site, and it looked the way it did, I wouldn't be surprised if i got a few of these :) .Short story, anyone know of any general settings to look for in my text editor preferences that would help to maintain the formatting I've so carefully worked for while coding to be translated when viewing the the source via the browser? I'm using FF. Do web developers think much of the source code as its viewed in the browser? Or only what you see in your text editor window?TIA! :)

Link to comment
Share on other sites

To be honest, I'm not bothered what the source code looks like and it only really matters on one occasion:I think on tutorial sites where people are going to look at the code to see how come tricks and stuff are done, then producing readable source code would be worth the effort.On anything else, I dont even look at the source code, unless its for a clients site and wants it redoing or just feel like been a bit nosey to see how something really cool was done, but then I dont expect a work of art in those situations.:)

Link to comment
Share on other sites

Anyway, that's what tools like Firebug and the Webkit Inspector help with, by formatting your code into a nice collapsible tree view.If you really really want your code to look nice, use output redirection to store the generated HTML in a string, then pass it through Tidy (example). Then it'll look perfect, no actual work required. :)

Link to comment
Share on other sites

sounds good. thanks for the feedback. I'll continue on in my text editor bubble and get back to work! :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...