dispalying html source

General technological topics without their own forum go here

dispalying html source

Post by whitedragon1 on Wed May 23, 2012 7:04 am
([msg=66548]see dispalying html source[/msg])

i have a question about viewing the html source code. I've started the realistic missions and most of the html source code has no line breaks in it, it comes out as one or two very long strings which makes it difficult to analyze. I was trying to figure out why it displays this way and if there's a way to easily add in the line breaks to make it more readable. thanks for any help.
whitedragon1
New User
New User
 
Posts: 1
Joined: Wed May 23, 2012 7:00 am
Blog: View Blog (0)


Re: dispalying html source

Post by limdis on Wed May 23, 2012 7:14 am
([msg=66550]see Re: dispalying html source[/msg])

I believe this was done by design on purpose. Unfortunately some web admins don't keep their code organized and you end up with one hell of a mess. It's just something you have to work through. I've copied the source down and dropped it in word a few times to keep from having to scroll way across notepad. This is why Ctrl+f is your friend. Firebug can also help in some cases.
"The quieter you become, the more you are able to hear..."
"Drink all the booze, hack all the things."
User avatar
limdis
Moderator
Moderator
 
Posts: 981
Joined: Mon Jun 28, 2010 5:45 pm
Blog: View Blog (0)


Re: dispalying html source

Post by tgoe on Wed May 23, 2012 7:57 am
([msg=66554]see Re: dispalying html source[/msg])

You should never rely on ctrl+u to give you nice code. Stuff is ugly for bandwidth reasons, usually :)
User avatar
tgoe
Contributor
Contributor
 
Posts: 527
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)


Re: dispalying html source

Post by M4GG1U771 on Wed May 23, 2012 12:33 pm
([msg=66563]see Re: dispalying html source[/msg])

For bandwidth reasons? Please explain...

I'm thinking about writing a really simple C program that can reformat code as follows.
1) prompt user for file that needs to be reformatted
2) Program opens file, adds line breaks after every semi-colon, and then adds an additional tab (or 4 spaces, or 3, or maybe it can be a parameter set by the user) for every thinking nested within { }.
M4GG1U771
New User
New User
 
Posts: 5
Joined: Mon May 21, 2012 7:31 pm
Blog: View Blog (0)


Re: dispalying html source

Post by centip3de on Wed May 23, 2012 1:53 pm
([msg=66565]see Re: dispalying html source[/msg])

M4GG1U771 wrote:I'm thinking about writing a really simple C program that can reformat code as follows.
1) prompt user for file that needs to be reformatted
2) Program opens file, adds line breaks after every semi-colon, and then adds an additional tab (or 4 spaces, or 3, or maybe it can be a parameter set by the user) for every thinking nested within { }.


What does this have to do with bandwidth?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1217
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)


Re: dispalying html source

Post by edone automaton on Wed May 23, 2012 3:48 pm
([msg=66568]see Re: dispalying html source[/msg])

centip3de wrote:
What does this have to do with bandwidth?


I think he is referring to OPs problem with reading the source code due to it being set out in a manner non consistent with best programming practices, so he is proposing something to make it look nice and easier to read again ;)
A wise man can learn more from a foolish question than a fool can learn from a wise answer.
-Bruce Lee
User avatar
edone automaton
Poster
Poster
 
Posts: 189
Joined: Sat May 21, 2011 7:09 am
Blog: View Blog (0)


Re: dispalying html source

Post by centip3de on Wed May 23, 2012 4:35 pm
([msg=66569]see Re: dispalying html source[/msg])

edone automaton wrote:I think he is referring to OPs problem with reading the source code due to it being set out in a manner non consistent with best programming practices, so he is proposing something to make it look nice and easier to read again ;)


Ah, gotcha. Makes much more sense. Though, his method will only work for C like languages.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1217
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)


Re: dispalying html source

Post by M4GG1U771 on Wed May 23, 2012 10:37 pm
([msg=66573]see Re: dispalying html source[/msg])

centip3de wrote:
edone automaton wrote:I think he is referring to OPs problem with reading the source code due to it being set out in a manner non consistent with best programming practices, so he is proposing something to make it look nice and easier to read again ;)


Ah, gotcha. Makes much more sense. Though, his method will only work for C like languages.


Not true it will work for a plethora of programming and scripting languages. I guess it depends what you consider "c like". And, if you create a function which passes the delimiter[s] as an argument (instead of hard coding { } and ; as the delimiters), it would work for most languages. A simple if statement could be used to locate one line conditionals that don't need to be nested between { }

Also, can someone explain to me this whole "bandwidth" reason? I think I'm reading into it wrong?

I will probably never get to it anyway, at least until work dies down. Can anyone think of a better pseudo algorithm?
M4GG1U771
New User
New User
 
Posts: 5
Joined: Mon May 21, 2012 7:31 pm
Blog: View Blog (0)


Re: dispalying html source

Post by tgoe on Thu May 24, 2012 11:08 pm
([msg=66594]see Re: dispalying html source[/msg])

For bandwidth reasons? Please explain...


For example, have a look at jquery.com. Notice the size difference between the "production" and "development" versions of the library above the download button. While functionally equivalent, the production version is minified (uglified) and only meant to be read by a computer. When you view-source a website you're not getting the version of the code that gets worked on. A smaller filesize is cheaper to distribute, so no formatting characters(whitespace) or comments, etc.
User avatar
tgoe
Contributor
Contributor
 
Posts: 527
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)


Re: dispalying html source

Post by M4GG1U771 on Fri May 25, 2012 8:13 am
([msg=66601]see Re: dispalying html source[/msg])

Oh, I get it. Development code is :D the exact code that was created by the developer and resides on the server. But, when a client sends a request to the website (merely by visiting it), that code is render into production code by trimming, removal of comments, and removal of all non functional characters.

the more you know!
M4GG1U771
New User
New User
 
Posts: 5
Joined: Mon May 21, 2012 7:31 pm
Blog: View Blog (0)


Next

Return to General

Who is online

Users browsing this forum: No registered users and 0 guests