This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Ranch Office and the fly likes How can I get code examples to look right Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » This Site » Ranch Office
Reply Bookmark "How can I get code examples to look right" Watch "How can I get code examples to look right" New topic
Author

How can I get code examples to look right

Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
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.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 19672
    ∞

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>


permaculture forums
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
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

Joined: Jan 07, 1999
Posts: 6913
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

Joined: Dec 14, 1998
Posts: 19672
    ∞

It is possible for me to turn HTML off for a forum. Would that help?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
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

Joined: Dec 14, 1998
Posts: 19672
    ∞

The Servlet forum now has HTML turned off.
See if that helps.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How can I get code examples to look right
 
Similar Threads
Doubt on wrapper class
Java and patterns
EL
Servlet resource: learning Servlets
Wheres the HttpServletRequest/HttpServletResponse implemented