我想在我的博客中包含这个java代码(这是封闭的前缀):
<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>
但是因为它有几个尖括号,Blogger进入并自动填充所有推断的标签,将该块转换为以下内容:
<pre class="prettyprint">public Vector<instruction> decodeTree(Tree<string> gene) {
Vector<instruction> ret = new Vector<instruction>();
ret.add(decodeString(gene.getValue()));
Vector<tree tring="">> currentLayer = gene.getChildren();
Vector<tree tring="">> nextLayer = new Vector<tree tring="">>();
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>
然后显示为:
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);
}
}
这与我试图呈现的代码不同。我认为这个问题源于html将我的东西与带有HTML标签的尖括号混淆。有没有办法让解析器忽略所有这些?我尝试将所有尖括号更改为&amp; gt和&amp; lt并获得以下输出:
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);
}
}
答案 0 :(得分:0)
html实体以分号终止:
<
>