Code formatting in TypePad blog

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 for Javascript.

Thanks, Jeremy!

“Copy As HTML”

VS CopyAsHtml

Result:

VS CopyAsHtml 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:

ProductivityTool

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:


<pre class="prettyprint">
Your code here
</pre>

Result:

Google Code Prettify Result


Comments

12 responses to “Code formatting in TypePad blog”

  1. Dear Aaron,
    Way cool, man!
    Way to go!
    Keep them coming!
    Thank you!
    Cheers, Jeremy.

  2. By the way, talking about Gogle and Yahoo…
    My son recommended that I use
    https://duckduckgo.com
    Does that work for you?
    They guarantee not to track your information, provide more transparent search algorithms, are completely open source and easily extensible:
    http://duckduckhack.com
    Is duckduckgo accessible from China?
    Cheers, Jeremy.

  3. At home, not accessible.
    In office, accessible.
    Thanks Jeremy, a new choice for me :)

  4. Steeloncall Avatar
    Steeloncall

    For construction use, buy best brands of steel materials from steeloncall.com. https://steeloncall.com/brands/KAY2 https://steeloncall.com/brands/ms-life https://steeloncall.com/brands/simhadri-tmt

  5. https://vidmate.icu is a free android app that allows you to #download #videos, #music, movies from your favourite sites such as #Youtube Facebook, Instagram, Tiktok. #vidmateicu you to download it for free.

  6. Come on bro that you need youtube downloader app like Vidmate at vid-mate.mobi try it it’s free for downloading videos and music directly from the Internet

  7. Come on bro that you need youtube downloader app like Vidmate at try it it’s free for downloading videos and music directly from the Internet

  8. namaste Avatar
    namaste

    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

  9. Mol pol

  10. Pople goa ia

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading