• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

How can I get code examples to look right

 
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.
 
Trailboss
Posts: 23036
IntelliJ IDE Firefox Browser 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: 23036
IntelliJ IDE Firefox Browser 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: 23036
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Servlet forum now has HTML turned off.
See if that helps.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!