better/easy way to displaying c source code in html

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gkumar007@gmail.com

    better/easy way to displaying c source code in html

    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[] = {23,34,12,17,20 4,99,16};
    int main()
    {
    int d;
    for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
    printf("%d\n",a rray[d+1]);
    return 0;
    }
    </code>
    </body>
    </html>

    And the tool generates the real html code as displayed in colours as
    shown here:


    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

  • Andy Dingley

    #2
    Re: better/easy way to displaying c source code in html

    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.

    Comment

    • axlq

      #3
      Re: better/easy way to displaying c source code in html

      In article <1153215891.261 956.320750@m79g 2000cwm.googleg roups.com>,
      <gkumar007@gmai l.comwrote:
      >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


      For highlighting code in C++ or many other languages, you need the PEAR
      Text_Highlighte r package add-on to PHP (it's free).


      -Alex

      Comment

      • Adrienne Boswell

        #4
        Re: better/easy way to displaying c source code in html

        Gazing into my crystal ball I observed gkumar007@gmail .com writing in
        news:1153215891 .261956.320750@ m79g2000cwm.goo glegroups.com:
        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[] = {23,34,12,17,20 4,99,16};
        int main()
        {
        int d;
        for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
        printf("%d\n",a rray[d+1]);
        return 0;
        }
        ></code>
        ></body>
        ></html>
        >
        And the tool generates the real html code as displayed in colours as
        shown here:

        >
        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

        Please respond to the group so others can share

        Comment

        • gkumar007@gmail.com

          #5
          Re: better/easy way to displaying c source code in html

          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
          news:1153215891 .261956.320750@ m79g2000cwm.goo glegroups.com:
          >
          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[] = {23,34,12,17,20 4,99,16};
          int main()
          {
          int d;
          for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
          printf("%d\n",a rray[d+1]);
          return 0;
          }
          </code>
          </body>
          </html>

          And the tool generates the real html code as displayed in colours as
          shown here:


          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

          Please respond to the group so others can share

          Comment

          Working...