The Article In Previous Attempt, I Was Trying To Make My Code Blocks To Looks Like A Real Code Blocks In Post Manually. I Do This In A Few Post And Got Sick Of Setting Custom Span Class Or Each Part And A Custom Css Styling Which Is Very Tedious And Not Practical At All. I Thought Of Writing My Own Script. But What If Someone Else Already Write That ? Then I Meet With Prettyprint By Google, A Handy JavaScript That Automatically Detect What Kind Of Language For Your Code And Make It Pretty With Syntax Highlighting. Pretty Print Is Very Easy To Use And It Got About Five Styling To Choose From. Include Prettify.js To Use Prettyprint, I First Have To Include The Javascript File Into My Theme File. Simply Copy And Paste The Following Code Before The Closing Tag. Choose The Styling There Are Five Different Styling Available To Choose Upon. Though Some Modification Might Be Needed To Suits Your Need: 1. Default 2. Desert 3. Sunburst 4. Son-of-obsidian 5. Doxy To Look How Each One Of These Styling Looks Click HERE. Then To Use These Styling I Simply Add The Name Of The Style Of My Choice At The End Of My Script Src Like This ..run_prettify.js?skin=son-of-obsidian". The Code Now Look Like This: Using Prettyprint On The Block Code Now That I Have Properly Include Both Prettyprint Scripting And Styling Into My Theme I Should Test It In My Post. To Apply Prettyprint Into A Blockcode, I Add Prettyprint Class To My Pre Or Code Tag Which Contain My Code Block.this Is How It Looks In The Blogger..
Di kongsi oleh NoxAsch