24
May

Embedding Code in HTML Page

Here’s a method for embedding code in an HTML page using a quick and painless tool called code2html. code2html is available in most distribution repositories, so installing it is just a matter of calling your package manager like yum install code2html. After installing it, here’s an example of how to use it:

code2html -l plain -o html-nocolor myprogram.c > myprogram.c.html

OR

cat myprogram.c | code2html -l plain -o html-nocolor - > myprogram.c.html

When finished, you can then copy/paste the contents into another webpage. In my example, I chose to have a plain conversion and no colors so that I can use the <pre> tag to make my output look like I want it to.

Be sure to check out the code2html man page for plenty of other examples and usage information.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 0 Comment So Far

Share your thoughts, leave a comment!