Forum Moderators: open

Message Too Old, No Replies

posting code samples with indent

how to keep indent intact

         

daveVk

7:26 am on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is best way to this. "code" tag loses indent completely "pre" seems to do some space removal also?

phranque

9:28 am on Mar 22, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



convert blanks to  

coopster

8:12 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



  won't work
(I think daveVk is asking how to format using the 'pre' ubbcodes.
[pre]no space 
1 or 2 spaces
4 spaces
6 spaces
8 spaces
  will not put a single spaced line in
If you try to use a single space line, following lines get thrown off:

Left a blank line there
2 spaces
4 spaces
6 spaces
8 spaces
[pre]


For every space you want, add an extra space. Also add extra spaces when you are going to use an exclamation point or a question mark.

daveVk

11:46 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks coopster, thats what I am talking about, seems awkward process to me. Confused how you managed to get a mix of normal and small font in your last post, at least thats what I see. Also note that if I preview prior to posting spaces are being lost.

Test Example


2222 2 spaces
4444 4 spaces
6666 6 spaces

Ok can see know that preview is not good indication of post font

[edited by: daveVk at 11:50 pm (utc) on Mar. 22, 2007]

coopster

10:35 am on Mar 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




Confused how you managed to get a mix of normal and small font in your last post, at least thats what I see.

Confuses me too, but that is what happens in the forum if you leave a blank line inside the "pre" style codes. I noticed a long time ago when viewing the source code that a single newline entry is replaced by a <br> element whereas two or more newlines are replaced by <p> elements, even inside of <pre> elements.

I find it easiest to put code in the forum using the "pre" style codes, replacing a single space with two spaces when I need indentation, and don't leave blank lines in between.

jatar_k

1:38 pm on Mar 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



pretty quick to format

grab your snippet you want to post and replace tabs with two spaces then remove newlines

when you post code, if you preview it, go back in your browser to the original paste to submit or change it

daveVk

5:18 am on Mar 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks all for your help, it would be useful if this advice was added to the "HTML Style Codes" page [webmasterworld.com...]

jatar_k

1:53 pm on Mar 24, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



posting code is something we discourage because huge code dumps are common so we don't facilitate it too much ;)

daveVk

3:05 am on Mar 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



posting code is something we discourage because huge code dumps are common so we don't facilitate it too much ;)

I take your point about large dumps, however for forums such as HTML, XML, Javascript to name a few, presenting examples without indent seems impolite, and encouraging bad practice. Perhaps it would be better to limit the size of all posts.