By Aaron Lu
It is a pain to insert code block in typepad blog, so I yahoo!ed (can't google in China :(), did not find much useful informaiton, fortunately the next day I searched again, yahoo! brought me to Jeremy's blog! There is a nice article describing how he handles it using VS plugin Copy As HTML for .net code and Google code prettify for Javascript.
Thanks, Jeremy!
"Copy As HTML"
Result:
Since typepad's post display width is fixed with 520px, we have to wrap code text if it is too long (more than 70 characters). But how should we know a line of code exceeds 70 characters quickly? I found a VS plugin for that:
Productivity Power Tools helps to add a column guide mark at any specific column:
If you think this tool is too heavy, you can modify VS's registry, this is how.
"Google code prettify"
Jeremy used the js file in typepad rather than from google site, but I found it still connects to googlecode.com to retrieve some .css files which is extremely slow in China, so I replaced most of google related URLs in "run_prettify.js" and uploaded it with some .css files to typepad,
I also changed the comment color in the prettify.css file from .com{color:#800} to .com{color:#008000} because it is more consistent with visual studio.
now the new script is here: http://adndevblog.typepad.com/files/run_prettify-3.js.
(I wonder whether there is any better free CDN site of which the speed is also good for China.)
so the code html node is this:
<script type="text/javascript" src="https://adndevblog.typepad.com/files/run_prettify-3.js"/></script> <pre class="prettyprint"> Your code here </pre>
Result: