• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Indenting code in posted text

 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I begin to read many threads here, it occurs to me that many of them include code snippets that would be easier to read if the indentation were preserved. I'm sure the style-conscious Sheriff Wheaton would agree. Is there a straightforward way to do this?
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes!
I usually use the HTML <PRE> and </PRE> tags around my code fragment to do this, although there are UBB CODE tags that can do this too (click on the "UBB Code is ON" link when you are writing a message for more info).
Some forums have HTML turned off, so you would need to use the UBB tags.

[This message has been edited by Paul Wheaton (edited August 27, 2000).]
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ahh... I see," said the blind man!

Nice.
However, I did a brief survey of Ranch postings that include code that needs indentation and found that there are about 5 times as many such postings that don't use this than those that do (10:2). I wonder if a note on the text entry page to encourage this feature's use would help?
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the text entry page you are thinking of?
(I fixed the tags in that message above - I should double check these things more often!)
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also bear in mind that CODE and PRE are not quite as smart as most people would like. They both "eat" empty lines, so if you want blank lines to appear in your code examples, you need to put a space or two at the start of the empty lines:
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sheriff: The "text entry page" I reffered to is the one I'm typing on right now to post this reply -- the one where UBB accepts a new topic or reply. What I was thinking of was maybe a note somewhere near this big key-in field (maybe just below the moose head?) sayin' somethin' like "If yer gonna put indented code in yer post, wrap it up with CODE tags like granny in her quilt."
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like a good idea. The only downside is rooting through the source code to find where that particular page is created and stuff in a bit of html. How about to the left where it says "Smilies Legend"?
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even better, 'cause it's closer to where you type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic