Click here to get back home

better/easy way to displaying c source code in html

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
better/easy way to displaying c source code in html gkumar007 07-18-2006
Posted by gkumar007 on July 18, 2006, 5:44 am
Please log in for more thread options


Greetings,
Are there any HTML editors which support syntax highlighting of c
program source code.

Let's say I write my html code as follows:
<html>
<body>

<code>
#include<stdio.h>
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = ;
int main()
{
int d;
for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
printf("%d\n",array[d+1]);
return 0;
}
</code>
</body>
</html>

And the tool generates the real html code as displayed in colours as
shown here:
http://www.gowrikumar.com/c/index.html

Currently I'm using gvim to convert the c programs to HTML and then
including them
in the larger html page. But I soon found that it's becoming very
difficult to manage the website.

Also any other pointers for solutions for this sort web authoring,
where the site would predominantly contains c language source code, is
greatly appreciated.

Thanks in advance.

Regards,
Gowri Kumar


Posted by Andy Dingley on July 18, 2006, 7:04 am
Please log in for more thread options


gkumar007@gmail.com wrote:

> Are there any HTML editors which support syntax highlighting of c
> program source code.

jEdit Just configure it so that it thinks HTML files (or even
".chtml" files) are C source.


OTOH, I wouldn't do this. HTML is HTML, C is C. Edit them as separate
files, then combine them through a pre-processor like SSI. If you edit
"C source" inside a HTML page then you can't test it and you'll see
errors sneaking through.


Posted by axlq on July 18, 2006, 11:53 am
Please log in for more thread options


>Are there any HTML editors which support syntax highlighting of c
>program source code.

First, I know you have C program source, but I wanted to mention
that for highlighting PHP source, this is trivial to do inside HTML
files that incorporate PHP. There's a highlight_file() function
already built in. See the documentation for highlight_file() at
http://us2.php.net/manual/en/function.highlight-file.php

For highlighting code in C++ or many other languages, you need the PEAR
Text_Highlighter package add-on to PHP (it's free).
http://pear.php.net/manual/en/package.text.text-highlighter.php

-Alex

Posted by Adrienne Boswell on July 19, 2006, 3:11 am
Please log in for more thread options


Gazing into my crystal ball I observed gkumar007@gmail.com writing in

> Greetings,
> Are there any HTML editors which support syntax highlighting of c
> program source code.
>
> Let's say I write my html code as follows:
><html>
><body>
>
><code>
> #include<stdio.h>
> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
> int array[] = ;
> int main()
> {
> int d;
> for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
> printf("%d\n",array[d+1]);
> return 0;
> }
></code>
></body>
></html>
>
> And the tool generates the real html code as displayed in colours as
> shown here:
> http://www.gowrikumar.com/c/index.html
>
> Currently I'm using gvim to convert the c programs to HTML and then
> including them
> in the larger html page. But I soon found that it's becoming very
> difficult to manage the website.
>
> Also any other pointers for solutions for this sort web authoring,
> where the site would predominantly contains c language source code, is
> greatly appreciated.

You may want to try HTML-Kit, an excellent HTML editor, with syntax
highlighting for myriad languages. There are hundreds of plugins
available, and this one <http://www.chami.com/html-
kit/plugins/info/codepublisher/> may be the one you are looking for.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


Posted by gkumar007 on July 24, 2006, 6:21 am
Please log in for more thread options


Greetings,
Thanks for all the replies. I would try following the suggestions
provided and
would come back if I find any difficulty.

Regards,
Gowri Kumar

AdriHenne Boswell wrote:
> Gazing into my crystal ball I observed gkumar007@gmail.com writing in
>
> > Greetings,
> > Are there any HTML editors which support syntax highlighting of c
> > program source code.
> >
> > Let's say I write my html code as follows:
> ><html>
> ><body>
> >
> ><code>
> > #include<stdio.h>
> > #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
> > int array[] = ;
> > int main()
> > {
> > int d;
> > for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
> > printf("%d\n",array[d+1]);
> > return 0;
> > }
> ></code>
> ></body>
> ></html>
> >
> > And the tool generates the real html code as displayed in colours as
> > shown here:
> > http://www.gowrikumar.com/c/index.html
> >
> > Currently I'm using gvim to convert the c programs to HTML and then
> > including them
> > in the larger html page. But I soon found that it's becoming very
> > difficult to manage the website.
> >
> > Also any other pointers for solutions for this sort web authoring,
> > where the site would predominantly contains c language source code, is
> > greatly appreciated.
>
> You may want to try HTML-Kit, an excellent HTML editor, with syntax
> highlighting for myriad languages. There are hundreds of plugins
> available, and this one <http://www.chami.com/html-
> kit/plugins/info/codepublisher/> may be the one you are looking for.
>
> --
> Adrienne Boswell at Home
> Arbpen Web Site Design Services
> http://www.cavalcade-of-coding.info
> Please respond to the group so others can share


Similar ThreadsPosted
Can't locate problem in HTML code IE ignores but Firefox is displaying. November 29, 2004, 2:01 pm
Displaying code with
December 30, 2005, 8:55 pm
What's all that stuff in the source code? August 25, 2004, 9:04 pm
Code added to my XHTML source files giving problems November 18, 2005, 6:56 pm
forcing ie to save the contents of the html instead of displaying it September 9, 2005, 5:47 pm
Can an HTML source file be specified in unicode ? March 13, 2005, 12:29 pm
Can an HTML source file be specified in unicode ? October 12, 2006, 8:08 am
Lenth of lines in html source? July 7, 2008, 9:33 pm
Why can't I save this page as a file and where's the source html? June 22, 2005, 2:08 am
Are there any open source ajax html editors? September 27, 2006, 6:32 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap