How to Post Codes in Your Blog

Mar 23, 2013

Desktop website browsers, including most mobile browsers, use languages such as HTML and XML to render the various elements of a web page. So without special tags, a blog post containing a line/s of raw code will appear on the published post as the actual element the code describes. Blog authors can use special scripts, tags and plugins to display raw code on a blog post instead of the interpretation of that code.

So, you have a code and want to post this to your blog. What will you do so that it will be displayed correctly? I recommend this tool. It is very easy to use. 

Use the Blogcrowds Parse HTML tool. This was designed specifically to help bloggers post code to their blogs. Visit their website and paste the raw HTML code into the text box. Click the "Parse" button. Copy the code that appears in the box and paste it into a blog post. Simple, right? Let me give you an example...

For example you want to post this code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> if ( $('.archivedate').hasClass('expanded') ) { $('.archivedate').removeClass('expanded'); $('.archivedate').addClass('collapsed'); } </script>

Head over to Blogcrowds and copy the code above. This will result to this:
&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt; 
if ( $(&#039;.archivedate&#039;).hasClass(&#039;expanded&#039;) )
{
 $(&#039;.archivedate&#039;).removeClass(&#039;expanded&#039;);
$(&#039;.archivedate&#039;).addClass(&#039;collapsed&#039;);
}
&lt;/script&gt;
This will be the code you will place in your blog post so that it will be displayed correctly.

Hope this helped. Got questions? Post it below. :)

@NicoCalunia

No comments:

Post a Comment