Site Search:

Why you should avoid pre tab in blogger post

Back>

Here is what you type in HTML

<pre>List<Object> a= new ArrayList<>();</pre>

the following is what you saw on the published post after a few flip back and forth from Compose to HTML tab


blogger
 List a = new ArrayList<>(); 


Here is what's the screwed HTML looks like:

<pre> List<object> a = new ArrayList&lt;&gt;(); </object></pre>

Reason: 

blogger HTML tab is basically a web application module, it is a translator instead of a plain HTML editor. Once you submitted your HTML code to server side by either click Publish or click away triggering javascript, it try to escape special characters, "fix bad html" (yes, your java generic code) code, etc. either at browser side javascript or at google server side application layer.

Solution:

wrap your code inside a div with a class, you can add css later for the class.
step 1, in HTML tab, write:
<div class="code">my code here</code>

step 2, click Compose, replace "my code here" String with your code

step 3, click HTML, then click Compose, remove the second last line, which is a blank line added by google wudu.

step 4, click Publish to finalize.