So I have just started using the Blogger Engine for my code archive blog. The first challenge I face when creating new posts is how will I be able to provide code markup within my posts that makes it easy for others to copy from?
Solution
I began my search online and stumbled upon another Blogger user who has solved the same problem. You can find his post here on his blog.
After performing the steps. Here is the result:
using System; ////// Summary description for Class1 /// public class Class1 { public Class1() { // // TODO: Add constructor logic here // } // Comment public class Testing { public Testing() { } public void Method() { /* Another Comment on multiple lines */ int x = 9; } } }
You can use other brushes if you need to. This brush I used was for C#.
I soon realized after posting the example that the code I pasted wasn't indented correctly. So I began another search to find out how I can auto format the code. I found nothing that worked as good as sticking with Visual Studio. So I found this guy's blog post which explains how to force Visual Studio to auto format your code.
After performing the steps. Here is the result:
using System; ////// Summary description for Class1 /// public class Class1 { public Class1() { // // TODO: Add constructor logic here // } // Comment public class Testing { public Testing() { } public void Method() { /* Another Comment on multiple lines */ int x = 9; } } }
I did find other syntax highlighters such as this one. But it seems to me that its too much HTML markup.
Conclusion
Well, I wish it was a bit easier, but this will have to do. I am satisfied with doing it this way until better tools are available. If you have a better suggestion or easier way to do the formatting and syntax highlighting, please comment.
No comments:
Post a Comment