Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Syntax highlighting and Ocaml/PHP integration
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dario Teixeira  
View profile  
 More options Oct 1 2008, 11:21 am
Newsgroups: fa.caml
From: Dario Teixeira <darioteixe...@yahoo.com>
Date: Wed, 01 Oct 2008 15:21:12 UTC
Local: Wed, Oct 1 2008 11:21 am
Subject: [Caml-list] Syntax highlighting and Ocaml/PHP integration
Hi,

I'm looking for a GPL-compatible syntax highlighting library with support
for most common programming languages and markups.  Obviously I would
prefer a native Ocaml library, though something in C would also be
acceptable due the relative ease of writing bindings.

One library that looks competent is GeSHi [1].  Unfortunately it is
written in PHP.  However, for lack of alternatives, I am looking into
ways of integrating GeSHi with Ocaml.

I reckon that a shell invocation of PHP is straightforward, but I bet
that it would entail a huge performance penalty due to the startup time.
Therefore, I am looking into somehow integrating the PHP interpreter
within the main Ocaml programme.  Something like Apache's mod_php.
Does anyone have any experience with this?  (Note that I have *zero*
experience with PHP).

If all else fails, my backup solution is simply to run a small webserver
with GeSHi and transform the library call into a web service.  Though I
would rather avoid this convoluted option.

Thanks in advance for your input!
Best regards,
Dario Teixeira

P.S.  Another (possibly far-fetched) solution is to take advantage of the
      syntax highlighting capabilities of Vim or Emacs.  Something along
      the lines of embedding or remotely invoking one of these editors,
      with the sole purpose of asking them to highlight a text file.
      Is this even possible?

[1] http://qbnz.com/highlighter/

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Benjamin  
View profile  
 More options Oct 1 2008, 11:28 am
Newsgroups: fa.caml
From: Dave Benjamin <d...@ramenlabs.com>
Date: Wed, 01 Oct 2008 15:28:37 UTC
Local: Wed, Oct 1 2008 11:28 am
Subject: Re: [Caml-list] Syntax highlighting and Ocaml/PHP integration

Dario Teixeira wrote:
> I'm looking for a GPL-compatible syntax highlighting library with support
> for most common programming languages and markups.  Obviously I would
> prefer a native Ocaml library, though something in C would also be
> acceptable due the relative ease of writing bindings.

I have had decent results opening a pipe to GNU source-highlight. I'm
mainly using it on JSON, so I can't vouch for its support of other
languages but it seems pretty comprehensive.

let pipe program input =
   let (in_channel, out_channel) = Unix.open_process program in
   output_string out_channel input;
   close_out out_channel;
   let result = ref [] in
   begin
     try
       while true do
         result := input_line in_channel :: !result
       done
     with End_of_file -> ()
   end;
   ignore (Unix.close_process (in_channel, out_channel));
   String.concat "\n" (List.rev !result)

let pre_body = Pcre.regexp ~flags:[`DOTALL] ".*<pre>(.*)</pre>.*"

let source_highlight lang code =
   let result = pipe ("source-highlight -s " ^ lang) code in
   Pcre.replace ~rex:pre_body ~templ:"$1" result

Caveat: The "pipe" function above will block on large inputs due to
buffering deadlock. It should probably be rewritten using Unix.select.

Dave

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Jambon  
View profile  
 More options Oct 1 2008, 11:34 am
Newsgroups: fa.caml
From: Martin Jambon <martin.jam...@ens-lyon.org>
Date: Wed, 01 Oct 2008 15:34:23 UTC
Local: Wed, Oct 1 2008 11:34 am
Subject: Re: [Caml-list] Syntax highlighting and Ocaml/PHP integration

On Wed, 1 Oct 2008, Dario Teixeira wrote:
> P.S.  Another (possibly far-fetched) solution is to take advantage of the
>      syntax highlighting capabilities of Vim or Emacs.  Something along
>      the lines of embedding or remotely invoking one of these editors,
>      with the sole purpose of asking them to highlight a text file.
>      Is this even possible?

I've used vim a little bit for my static webpages, here's the result:

http://martin.jambon.free.fr/hello.c.html
http://martin.jambon.free.fr/quine.sh.html
http://martin.jambon.free.fr/micmatch/Makefile.html

The script is:

#!/bin/sh -e

# Usage : any2html <file1> [<file2> ...]
# Requires : vim

[ $# -lt 1 ] && echo "Usage : $0 <fic1> <fic2> ..." && exit 1

while [ -n "$1" ]
do
     file=`basename "$1"`
     cp -f "$1" /tmp
     vim -f +"syn on" +"so \\\$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" /tmp/"$file"
     cp -f /tmp/"$file".html "$1".html
     shift
done
###########################################################

Martin
--
http://mjambon.com/

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Re : [Caml-list] Syntax highlighting and Ocaml/PHP integration" by Adrien
Adrien  
View profile  
 More options Oct 1 2008, 11:45 am
Newsgroups: fa.caml
From: Adrien <camarade...@gmail.com>
Date: Wed, 01 Oct 2008 15:45:26 UTC
Local: Wed, Oct 1 2008 11:45 am
Subject: Re : [Caml-list] Syntax highlighting and Ocaml/PHP integration
Hi,

You might try Highlight[1] and Caml2html[2]. I know I've tried
Highlight but I simply can't remember how the result looked like, most
probably because I needed to write to a tex file (I still don't know
if there's anything with color support). Caml2html generates nice
pages but only supports the ocaml language, it's written in ocaml
however.

OK, tried hightlight again... Its output is less colorized than vim's
but still alright and this can be changed. It's GPLv2. The drawback is
that it's written in C++ so probably not the best solution if you want
to hack it. (* I've been going through (p)7zip to write bindings, why
does C++ have to be that horrible ? *) The code might be perfectly
understandable though, I've not looked at it.

[1] http://www.andre-simon.de/doku/highlight/highlight.html
[2] http://martin.jambon.free.fr/caml2html.html

 ---

Adrien Nader

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Re : Re : [Caml-list] Syntax highlighting and Ocaml/PHP integration" by Adrien
Adrien  
View profile  
 More options Oct 1 2008, 11:47 am
Newsgroups: fa.caml
From: Adrien <camarade...@gmail.com>
Date: Wed, 01 Oct 2008 15:47:26 UTC
Local: Wed, Oct 1 2008 11:47 am
Subject: Re : Re : [Caml-list] Syntax highlighting and Ocaml/PHP integration
Btw, geshi is not the fastest code highlighter around.

 ---

Adrien Nader

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Syntax highlighting and Ocaml/PHP integration" by Dario Teixeira
Dario Teixeira  
View profile  
 More options Oct 3 2008, 11:22 am
Newsgroups: fa.caml
From: Dario Teixeira <darioteixe...@yahoo.com>
Date: Fri, 03 Oct 2008 15:22:18 UTC
Local: Fri, Oct 3 2008 11:22 am
Subject: Re: [Caml-list] Syntax highlighting and Ocaml/PHP integration
Hi,

> I'm looking for a GPL-compatible syntax highlighting library
> with support for most common programming languages and markups.
> Obviously I would prefer a native Ocaml library, though
> something in C would also be acceptable due the relative ease
> of writing bindings.

Thank you all for your replies.   GNU source-highlight seems
like the best long term solution, though currently the set of
languages it supports it's still limited.   For the time being,
however, I'll be using Martin's cool Vim hack...

Cheers,
Dario

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rvanmelle  
View profile  
 More options Oct 7 2008, 9:08 am
Newsgroups: fa.caml
From: rvanmelle <rvanme...@gmail.com>
Date: Tue, 7 Oct 2008 06:08:01 -0700 (PDT)
Local: Tues, Oct 7 2008 9:08 am
Subject: Re: Syntax highlighting and Ocaml/PHP integration
You can setup something very similar to the Vim hack as an emacs hack
if that is more preferable.  Depending on your needs and how it is
being used, you can setup the nice (arguably) integrated documentation
system for emacs called "muse" (http://www.emacswiki.org/cgi-bin/wiki/
EmacsMuse) which we have been using for a while.  It allows you to
write simple text buffers as shown below with code blocks in any of
the supported emacs modes, which is pretty much every language,
script, and interactive mode in existence.  Underneath is uses an
emacs module called "htmlize" with which you can extract your exact
emacs colour scheme as CSS declarations.  If you have an emacs mode
which you love, you can duplicate this easily in your documentation
using this system.

When all is said and done, you can run the muse documentation
generation from the command line with something like:

% emacs -q -batch -l muse-init.el -f muse-project-batch-publish
"Articles"

This requires a bit more investment than the nice VIM idea, but it
will likely be more malleable in-the-end if you have grander designs.

**************
This is my article on ocaml with the following source code in first
ocaml:

<src lang="ocaml">
let foo bar = 3 * bar
;;
</src>

And I also have some C code:

<src lang="c">
int main(int argc, char *argv[]);
</src>
****************

Regards

Reid


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google