Forum Moderators: open

Message Too Old, No Replies

Posting code on WebmasterWorld

What are the best style code tags to use...

         

dmorison

7:33 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dunno about anyone else but i've always struggled to post code nicely on WebmasterWorld - what are the best tags to use if you just want to paste in, say, 10-15 lines of PHP?

j4mes

12:32 pm on Aug 7, 2005 (gmt 0)

10+ Year Member



Provided there are no other tags inside, [pre] ... [/pre] works well (putting tags inside closes the html <pre> tag in the source and re-opens with <font>, which is still monopaced but is a different size - odd behaviour!).

Otherwise I give each line a [code] ... [/code], which *seems* to work :-)

jatar_k

8:52 pm on Aug 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I usually go with pre tags and replace all tabs in the code with spaces, does not a bad job of formatting the code, some multi level indents get collapsed but it works.

dmorison

8:59 pm on Aug 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Interesting - could be half the problem cutting code out of my editor containing tabs... quick test



function foo($bar)
{
if ($bar)
{
return 1;
}
else
{
return 0;
}
}

edit: seems to help, what happens if you wrap in [ quote ] which is a nice way to separate code from commment...

[edited by: jatar_k at 9:09 pm (utc) on Aug. 8, 2005]
[edit reason] fixed quote tag [/edit]

jatar_k

9:11 pm on Aug 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that looks pretty good, hadn't thought of that

Brett_Tabke

3:43 pm on Aug 12, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I am sorry we can't "save" the spaces, but with some phones and older command line browers just cranking out raw spaces in any forms, we have to strip them out or the db could be over run with junk.

moltar

4:21 pm on Aug 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



we have to strip them out or the db could be over run with junk.

You can replace it with tabs when you store it in the database and then replace with spaces after you read it.

I post a lot of code, and dislike the way indents work very much! That's the only pet peeve on the whole WebmasterWorld! I can't sleep because of that :)

dmorison

6:09 pm on Aug 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is a [ code ] tag which combines the effect of [ pre ] without losing spaces a possibility?

vincevincevince

9:44 am on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or a non-breaking space support? Last time I tried indenting code using non-breaking spaces it didn't keep them either...

whoisgregg

8:24 pm on Aug 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Small request -- the post preview page uses different settings for [ code ] than the actual thread uses.

Even knowing this, I still wonder each time I preview code why my [ code ] is normal font-weight and smaller than it should be.

       Webmasterworld does accept non breaking spaces. But, I think you'll have to zap those as they would break PHP.

moltar

9:26 pm on Aug 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think we all should be allowed to use regular HTML. We are all webmasters and most likely familiar with tags. Why reinvent the wheel with bbcode and such when we simply can use proper tags for the job...