Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I get code examples to look right  RSS feed

 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Over in "Java", I tried to put in a code example for Paul. It looked fine in my edit box, but on the page all the indentation has vanished. What's wierd is that the line breaks are still there, so obviously the software has not just dumped the text out as HTML.
Is there anything I can do in future to ensure code examples
are properly formatted?
Frank.
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, use the HTML PRE tags. Before the code type
PRE
with angle brackets around it and then at the end of your code put
/PRE
with angle brackets around it.
Example
<pre>
bla bla bla
bla bla bla

bla bla bla

</pre>
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I feel dumb now. I really should have known that. On every edit page I look at the "HTML is ON" label, but so far I've just ignored it.
Sigh.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's dig up an old thread.
Is there any way to make html code listings look even slightly reasonable. By default, most of what's entered simply doesn't appear. This kind of problem is increasingly likely to occur in my servlets forum, and a real example posted a few days ago has prompted me to ask.
I have tried several solutions, and ultimately ended up replacing all the angle brackets with & lt ; etc.
Html PRE tags still process most of the tagged information, making things like head, body, title, links, servlet tags etc invisible. UBB CODE tags seem to process all the html tags, so that's even worse. Html XMP tags almost work, but string all the lines together separated by BR tags which don't get rendered, making for a very long and incorrect example..
Is there any way of turning html processing of on a per-message or (even better) region-of-message basis?
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible for me to turn HTML off for a forum. Would that help?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, give it a try. As you can imagine, I'll be the first to moan if it creates more problems than it solves
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Servlet forum now has HTML turned off.
See if that helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!