Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I want to include this java code in my blog (this is with the enclosing pre's):

<pre class="prettyprint">
public Vector<Instruction> decodeTree(Tree<String> gene) {
    Vector<Instruction> ret = new Vector<Instruction>();
    ret.add(decodeString(gene.getValue()));
    Vector<Tree<String>> currentLayer = gene.getChildren();
    Vector<Tree<String>> nextLayer = new Vector<Tree<String>>();
    for(int i=0; i<currentLayer.size(); i++) {
        for(Tree<String> t: currentLayer.get(i).getChildren()) {
        nextLayer.add(t);
    }
}
</pre>

But because it has several angle brackets, Blogger goes in and autocompletes all the inferred tags, transforming that chunk into the following:

<pre class="prettyprint">public Vector<instruction> decodeTree(Tree<string> gene) {
    Vector<instruction> ret = new Vector<instruction>();
    ret.add(decodeString(gene.getValue()));
    Vector<tree tring="">&gt; currentLayer = gene.getChildren();
    Vector<tree tring="">&gt; nextLayer = new Vector<tree tring="">&gt;();
    for(int i=0; i<currentlayer .size="" for="" i="" ree="" tring=""> t: currentLayer.get(i).getChildren()) {
        nextLayer.add(t);
    }
}
</currentlayer></tree></tree></tree></instruction></instruction></string></instruction></pre>

Which then shows up as:

public Vector decodeTree(Tree gene) {
    Vector ret = new Vector();
    ret.add(decodeString(gene.getValue()));
    Vector> currentLayer = gene.getChildren();
    Vector> nextLayer = new Vector>();
    for(int i=0; i t: currentLayer.get(i).getChildren()) {
        nextLayer.add(t);
    }
}

Which is different from the code I'm trying to present. I think the problem originates in the html confusing my things with angle brackets with HTML tags. Is there a way I could get the parser to ignore all that? I tried changing all the angle brackets to &gt and &lt and got the following output:

public Vector&ltInstruction&gt decodeTree(Tree&ltString&gt gene) {
    Vector&ltInstruction&gt ret = new Vector&ltInstruction&gt();
    ret.add(decodeString(gene.getValue()));
    Vector&ltTree&ltString&gt&gt currentLayer = gene.getChildren();
    Vector&ltTree&ltString&gt&gt nextLayer = new Vector&ltTree&ltString&gt&gt();
    for(int i=0; i&ltcurrentLayer.size(); i++) {
        for(Tree&ltString&gt t: currentLayer.get(i).getChildren()) {
        nextLayer.add(t);
    }
}
share|improve this question
    
Perhaps you can try your luck with this answer:webapps.stackexchange.com/a/37830/29140 –  Jacob Jan Tuinstra May 22 '13 at 18:22
add comment

1 Answer

up vote 1 down vote accepted

You're putting this into a post? In the post-editor, in the bar at the right, there's a Options section near the bottom, which allows you to say "do not interpret HTML" code. Choosing this option makes Blogger present exactly what you entered.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.