Maybe there are many reasons that you want show the source code in your MT entries, such as HTML, C++, Perl etc. However, if you simply type that code in while writing the entry, the resulting page will not show the tags and code. So how do you display code in entries? There are several methods and currently my method is using code2HTML and design a CSS style for it.
First, Get the code2HTML from the author’s page or just use the CGI script to translate your code to HTML. Then copy the result HTML code to your MT entry field. For example, you code is like below:
#include<iostram> using namespace std; int main { return 0; }
Transform the code and add your CSS class “codeblock” for this <pre> section.This is the result:
BTY, this is my CSS sytle file section for code :
.codeblock { width:auto; border:1px solid #4A4A4A; background-color:#FFF4F4; padding:10px; }
Copy the above HTML code into your MT entry input box, and you will see the finally code section looks like this:
#include<iostram> using namespace std; int main { return 0; }
How about this code style? Is it looks beatiful.Hmmmm… at least, I think so.